Audacity 3.2.0
CommonTrackPanelCell.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5CommonTrackPanelCell.h
6
7Paul Licameli split from TrackPanel.cpp
8
9**********************************************************************/
10
11#ifndef __AUDACITY_COMMON_TRACK_PANEL_CELL__
12#define __AUDACITY_COMMON_TRACK_PANEL_CELL__
13
14#include "TrackPanelCell.h"
15#include "TrackAttachment.h" // to inherit
16
17#include <stdlib.h>
18#include <memory>
19#include <functional>
21#include "GlobalVariable.h"
22
23#include "XMLTagHandler.h"
24
25class Channel;
26class ChannelGroup;
27class CommandContext;
28class Track;
29class XMLWriter;
30
31class AUDACITY_DLL_API CommonTrackPanelCell /* not final */
32 : public TrackPanelCell
33{
34public:
35 // Function to dispatch mouse wheel events
36 struct AUDACITY_DLL_API MouseWheelHook : GlobalHook<MouseWheelHook,
37 unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
38 >{};
39
41 {}
42
43 virtual ~CommonTrackPanelCell() = 0;
44
45 // Default to the arrow cursor
47 (const TrackPanelMouseState &, const AudacityProject *) override;
48
49 std::shared_ptr<Track> FindTrack() { return DoFindTrack(); }
50 std::shared_ptr<const Track> FindTrack() const
51 { return const_cast<CommonTrackPanelCell*>(this)->DoFindTrack(); }
52
53 struct MenuItem {
54 using Action = std::function< void(const CommandContext &) >;
55
56 MenuItem() = default;
58 Action action = {}, bool enabled = true )
59 : symbol{ internal, msgid }, action{ move(action) }, enabled{ enabled }
60 {}
61
64 bool enabled;
65 };
66
68
83 virtual std::vector<MenuItem> GetMenuItems(
84 const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject );
85
86protected:
87 virtual std::shared_ptr<Track> DoFindTrack() = 0;
88
89 unsigned DoContextMenu(
90 const wxRect &rect,
91 wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
92 override;
93
94 unsigned HandleWheelRotation
95 (const TrackPanelMouseEvent &event,
96 AudacityProject *pProject) override;
97
98};
99
100class AUDACITY_DLL_API CommonTrackCell /* not final */
102{
103public:
105 CommonTrackCell(const std::shared_ptr<Track> &pTrack, size_t iChannel);
106
108
111 CommonTrackCell(ChannelGroup &group, size_t iChannel);
112
114
115 std::shared_ptr<Track> DoFindTrack() override;
116
117 void Reparent( const std::shared_ptr<Track> &parent ) override;
118
119 size_t GetChannelIndex() const { return miChannel; }
120
122 std::shared_ptr<Channel> FindChannel();
123
125 std::shared_ptr<const Channel> FindChannel() const;
126
127private:
128 std::weak_ptr< Track > mwTrack;
129 const size_t miChannel;
130};
131
132#endif
abstract base class for structures that user interface associates with 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
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
std::weak_ptr< Track > mwTrack
size_t GetChannelIndex() const
std::shared_ptr< Track > FindTrack()
std::shared_ptr< const Track > FindTrack() const
virtual std::shared_ptr< Track > DoFindTrack()=0
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Global function-valued variable, adding a convenient Call()
An explicitly nonlocalized string, not meant for the user to see.
Definition: Identifier.h:22
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:122
virtual unsigned DoContextMenu(const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
virtual HitTestPreview DefaultPreview(const TrackPanelMouseState &state, const AudacityProject *pProject)
virtual unsigned HandleWheelRotation(const TrackPanelMouseEvent &event, AudacityProject *pProject)
Holds a msgid for the translation catalog; may also bind format arguments.
Base class for XMLFileWriter and XMLStringWriter that provides the general functionality for creating...
Definition: XMLWriter.h:25
MenuItem(const Identifier &internal, const TranslatableString &msgid, Action action={}, bool enabled=true)
std::function< void(const CommandContext &) > Action
ComponentInterfaceSymbol symbol