Audacity 3.2.0
LabelDefaultClickHandle.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5LabelDefaultClickHandle.cpp
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11
13
14#include "LabelTrackView.h"
15#include "../../../HitTestResult.h"
16#include "../../../LabelTrack.h"
17#include "../../../RefreshCode.h"
18#include "../../../TrackPanelMouseEvent.h"
19#include <wx/event.h>
20
22{
23}
24
26{
27}
28
30 std::vector<
31 std::pair< std::weak_ptr<LabelTrack>, LabelTrackView::Flags >
33};
34
36{
37 mLabelState = std::make_shared<LabelState>();
38 auto &pairs = mLabelState->mPairs;
39 auto &tracks = TrackList::Get( *pProject );
40
41 for (auto lt : tracks.Any<LabelTrack>()) {
42 auto &view = LabelTrackView::Get( *lt );
43 pairs.push_back( std::make_pair(
44 lt->SharedPointer<LabelTrack>(), view.SaveFlags() ) );
45 }
46}
47
49{
50 if ( mLabelState ) {
51 for ( const auto &pair : mLabelState->mPairs )
52 if (auto pLt = TrackList::Get( *pProject ).Lock(pair.first)) {
53 auto &view = LabelTrackView::Get( *pLt );
54 view.RestoreFlags( pair.second );
55 }
56 mLabelState.reset();
57 }
58}
59
61(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
62{
63 using namespace RefreshCode;
64 // Redraw to show the change of text box selection status
66
67 if (evt.event.LeftDown())
68 {
69 SaveState( pProject );
70
71 const auto pLT = evt.pCell.get();
72 for (auto lt : TrackList::Get(*pProject).Any<LabelTrack>()) {
73 if (pLT != &ChannelView::Get(*lt)) {
74 auto &view = LabelTrackView::Get( *lt );
75 view.ResetFlags();
76 }
77 }
78 }
79
80 return result;
81}
82
84(const TrackPanelMouseEvent &WXUNUSED(evt), AudacityProject *WXUNUSED(pProject))
85{
87}
88
90(const TrackPanelMouseEvent &WXUNUSED(evt), AudacityProject *WXUNUSED(pProject),
91 wxWindow *WXUNUSED(pParent))
92{
93 mLabelState.reset();
95}
96
98{
100 RestoreState( pProject );
101 return result;
102}
const auto tracks
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
static ChannelView & Get(Channel &channel)
Result Release(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
std::shared_ptr< LabelState > mLabelState
Result Drag(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void RestoreState(AudacityProject *pProject)
Result Click(const TrackPanelMouseEvent &event, AudacityProject *pProject) override
void SaveState(AudacityProject *pProject)
Result Cancel(AudacityProject *pProject) override
A LabelTrack is a Track that holds labels (LabelStruct).
Definition: LabelTrack.h:87
static LabelTrackView & Get(LabelTrack &)
std::shared_ptr< Subclass > Lock(const std::weak_ptr< Subclass > &wTrack)
Definition: Track.h:1246
auto Any() -> TrackIterRange< TrackType >
Definition: Track.h:1097
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:347
unsigned Result
Definition: UIHandle.h:39
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
std::vector< std::pair< std::weak_ptr< LabelTrack >, LabelTrackView::Flags > > mPairs
std::shared_ptr< TrackPanelCell > pCell