Audacity 3.2.0
SyncLock.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5@file SyncLock.cpp
6@brief Defines groupings of tracks that should keep contents synchronized
7
8Paul Licameli split from Track.cpp
9
10**********************************************************************/
11#ifndef __AUDACITY_SYNC_LOCK__
12#define __AUDACITY_SYNC_LOCK__
13
14#include "Prefs.h"
15#include "Track.h" // for TrackIterRange
17#include "Observer.h"
18
20struct SyncLockChangeMessage{ const bool on; };
21
22class TRACK_SELECTION_API SyncLockState final
23 : public ClientData::Base
24 , public Observer::Publisher<SyncLockChangeMessage>
25{
26public:
28 static const SyncLockState &Get( const AudacityProject &project );
30 SyncLockState( const SyncLockState & ) = delete;
32
33 bool IsSyncLocked() const;
34 void SetSyncLock(bool flag);
35
36private:
38 bool mIsSyncLocked{ false };
39};
40
41class TRACK_SELECTION_API SyncLock {
42public:
44 static bool IsSyncLockSelected(const Track &track);
45
48
51 static bool IsSyncLockSelectedP(const Track *pTrack)
52 { return pTrack && IsSyncLockSelected(*pTrack); }
53
55 static bool IsSelectedOrSyncLockSelected(const Track &track);
56
58
61 static bool IsSelectedOrSyncLockSelectedP(const Track *pTrack)
62 { return pTrack && IsSelectedOrSyncLockSelected(*pTrack); }
63
65 static TrackIterRange<Track> Group(Track &track);
66
69 {
70 return Group(const_cast<Track&>(track)).Filter<const Track>();
71 }
72};
73
75enum class SyncLockPolicy {
76 Isolated,
77 Grouped,
79};
80
81struct GetSyncLockPolicyTag;
82
86 GetSyncLockPolicyTag,
88 const Track
89>;
91
92extern TRACK_SELECTION_API BoolSetting SyncLockTracks;
93
94#endif
Utility for non-intrusive definition of a new method on a base class.
SyncLockPolicy
Describes how a track participates in sync-lock groupings.
Definition: SyncLock.h:75
@ EndSeparator
Delimits the end of a group (of which it is a part)
@ Grouped
Can be part of a group.
@ Isolated
Never part of a group.
DECLARE_EXPORTED_ATTACHED_VIRTUAL(TRACK_SELECTION_API, GetSyncLockPolicy)
TRACK_SELECTION_API BoolSetting SyncLockTracks
Definition: SyncLock.cpp:163
const auto project
declares abstract base class Track, TrackList, and iterators over TrackList
static std::once_flag flag
Class template generates single-dispatch, open method registry tables.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
This specialization of Setting for bool adds a Toggle method to negate the saved value.
Definition: Prefs.h:346
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
static bool IsSyncLockSelectedP(const Track *pTrack)
Definition: SyncLock.h:51
static TrackIterRange< const Track > Group(const Track &track)
Definition: SyncLock.h:68
static bool IsSelectedOrSyncLockSelectedP(const Track *pTrack)
Definition: SyncLock.h:61
SyncLockState & operator=(const SyncLockState &)=delete
SyncLockState(const SyncLockState &)=delete
AudacityProject & mProject
Definition: SyncLock.h:37
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:202
MenuRegistry::GroupItem< MenuRegistry::Traits > Group
Definition: MenuHelper.h:11
A convenient default parameter for class template Site.
Definition: ClientData.h:29
Sent after sync lock setting changes, with its new state.
Definition: SyncLock.h:20
Range between two TrackIters, usable in range-for statements, and with Visit member functions.
Definition: Track.h:682