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 *pTrack );
45
47 static bool IsSelectedOrSyncLockSelected( const Track *pTrack );
48
50 static TrackIterRange< Track > Group( Track *pTrack );
51
54 {
55 return Group(const_cast<Track*>(pTrack)).Filter<const Track>();
56 }
57};
58
60enum class SyncLockPolicy {
61 Isolated,
62 Grouped,
64};
65
66struct GetSyncLockPolicyTag;
67
71 GetSyncLockPolicyTag,
73 const Track
74>;
76
77extern TRACK_SELECTION_API BoolSetting SyncLockTracks;
78
79#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:60
@ 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:173
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:344
An object that sends messages to an open-ended list of subscribed callbacks.
Definition: Observer.h:108
static TrackIterRange< const Track > Group(const Track *pTrack)
Definition: SyncLock.h:53
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:122
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
MenuRegistry::GroupItem< MenuRegistry::Traits > Group
Definition: MenuHelper.h:11
A convenient default parameter for class template Site.
Definition: ClientData.h:28
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:807