Audacity 3.2.0
ProjectTimeRuler.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 ProjectTimeRuler.h
7
8 Dmitry Vedenko
9
10**********************************************************************/
11#include "ProjectTimeRuler.h"
12
13#include <cassert>
14
15#include "Observer.h"
16#include "Project.h"
18#include "TimeDisplayMode.h"
19
20#include "widgets/BeatsFormat.h"
22#include "widgets/Ruler.h"
23#include "widgets/TimeFormat.h"
24
26 [](AudacityProject& project) { return std::make_shared<ProjectTimeRuler>(project); }
27};
28
30{
31 return project.AttachedObjects::Get<ProjectTimeRuler&>(key);
32}
33
35{
36 return Get(const_cast<AudacityProject&>(project));
37}
38
40{
44 .Subscribe([this](const auto& msg) {
46 msg.newTempo,
47 msg.newUpperTimeSignature,
48 msg.newLowerTimeSignature);
49
51 }) }
52 , timeDisplayModeChanged { TimeDisplayModePreference.Subscribe(
53 [this](TimeDisplayMode newMode) {
54 switch (newMode)
55 {
57 ruler.SetFormat(&beatsFormat);
58 break;
61 break;
62 default:
63 assert(false);
64 break;
65 }
66 }) }
67 {
69 ruler.SetFormat(&beatsFormat);
70 }
71
73
76
78
79private:
82};
83
85 : mImpl { std::make_unique<Impl>(project) }
86{
87}
88
90{
91 return mImpl->updater;
92}
93
95{
96 return mImpl->updater;
97}
98
100{
101 return mImpl->beatsFormat;
102}
103
105{
106 return mImpl->beatsFormat;
107}
108
110{
111 return mImpl->ruler;
112}
113
115{
116 return mImpl->ruler;
117}
static const AttachedProjectObjects::RegisteredFactory key
const auto project
TimeDisplayModeSetting TimeDisplayModePreference
TimeDisplayMode
static CustomUpdaterValue updater
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
void SetData(double bpm, int timeSigUpper, int timeSigLower)
Definition: BeatsFormat.cpp:70
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:275
Enum ReadEnum() const
Definition: Prefs.h:534
A move-only handle representing a connection to a Publisher.
Definition: Observer.h:70
std::unique_ptr< Impl > mImpl
LinearUpdater & GetUpdater()
static ProjectTimeRuler & Get(AudacityProject &project)
BeatsFormat & GetBeatsFormat()
ProjectTimeRuler(AudacityProject &project)
Used to display a Ruler.
Definition: Ruler.h:34
void SetFormat(const RulerFormat *pFormat)
Definition: Ruler.cpp:104
void Invalidate()
Definition: Ruler.cpp:317
Observer::Subscription Subscribe(Callback callback)
static const TimeFormat & Instance()
Definition: TimeFormat.cpp:15
STL namespace.
Observer::Subscription timeDisplayModeChanged
Impl(AudacityProject &project)
Observer::Subscription projectTimeSignatureChanged