Audacity  3.2.0
SelectionState.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  SelectionState.h
6 
7  **********************************************************************/
8 
9 #ifndef __AUDACITY_SELECTION_STATE__
10 #define __AUDACITY_SELECTION_STATE__
11 
12 class AudacityProject;
13 class Track;
14 class TrackList;
15 class ViewInfo;
16 #include "ClientData.h"
17 #include <memory>
18 #include <vector>
19 
20 // State relating to the set of selected tracks
21 class AUDACITY_DLL_API SelectionState final
22  : public ClientData::Base
23 {
24 public:
25  SelectionState() = default;
26  SelectionState( const SelectionState & ) PROHIBITED;
27  SelectionState &operator=( const SelectionState & ) PROHIBITED;
28 
29  static SelectionState &Get( AudacityProject &project );
30  static const SelectionState &Get( const AudacityProject &project );
31 
32  static void SelectTrackLength
33  ( ViewInfo &viewInfo, Track &track, bool syncLocked );
34 
35  void SelectTrack(
36  Track &track, bool selected, bool updateLastPicked );
37  // Inclusive range of tracks, the limits specified in either order:
38  void SelectRangeOfTracks
39  ( TrackList &tracks, Track &sTrack, Track &eTrack );
40  void SelectNone( TrackList &tracks );
41  void ChangeSelectionOnShiftClick
42  ( TrackList &tracks, Track &track );
43  void HandleListSelection
44  ( TrackList &tracks, ViewInfo &viewInfo, Track &track,
45  bool shift, bool ctrl, bool syncLocked );
46 
47 private:
48  friend class SelectionStateChanger;
49 
50  std::weak_ptr<Track> mLastPickedTrack;
51 };
52 
53 // For committing or rolling-back of changes in selectedness of tracks.
54 // When rolling back, it is assumed that no tracks have been added or removed.
55 class AUDACITY_DLL_API SelectionStateChanger
56 {
57 public:
61 
63  void Commit();
64 
65 private:
68  std::weak_ptr<Track> mInitialLastPickedTrack;
69  std::vector<bool> mInitialTrackSelection;
70 };
71 
72 #endif
SelectionState::operator=
SelectionState & operator=(const SelectionState &) PROHIBITED
SelectionState::mLastPickedTrack
std::weak_ptr< Track > mLastPickedTrack
Definition: SelectionState.h:50
SelectionStateChanger::operator=
SelectionStateChanger & operator=(const SelectionStateChanger &)=delete
SelectionStateChanger::mTracks
TrackList & mTracks
Definition: SelectionState.h:67
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1288
ViewInfo
Definition: ViewInfo.h:188
SelectionStateChanger
Definition: SelectionState.h:56
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
SelectionStateChanger::SelectionStateChanger
SelectionStateChanger(const SelectionStateChanger &)=delete
ClientData.h
Utility ClientData::Site to register hooks into a host class that attach client data.
SelectionStateChanger::mpState
SelectionState * mpState
Definition: SelectionState.h:66
SelectionState::SelectionState
SelectionState(const SelectionState &) PROHIBITED
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
SelectionState::SelectionState
SelectionState()=default
SelectionState
Definition: SelectionState.h:23
Track
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:224
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
SelectUtilities::SelectNone
void SelectNone(AudacityProject &project)
Definition: SelectUtilities.cpp:80
SelectionStateChanger::mInitialLastPickedTrack
std::weak_ptr< Track > mInitialLastPickedTrack
Definition: SelectionState.h:68
SelectionStateChanger::mInitialTrackSelection
std::vector< bool > mInitialTrackSelection
Definition: SelectionState.h:69