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 CommandContext;
26class Track;
27class XMLWriter;
28
29class AUDACITY_DLL_API CommonTrackPanelCell /* not final */
30 : public TrackPanelCell
31{
32public:
33 // Function to dispatch mouse wheel events
34 struct AUDACITY_DLL_API MouseWheelHook : GlobalHook<MouseWheelHook,
35 unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject)
36 >{};
37
39 {}
40
41 virtual ~CommonTrackPanelCell() = 0;
42
43 // Default to the arrow cursor
45 (const TrackPanelMouseState &, const AudacityProject *) override;
46
47 std::shared_ptr<Track> FindTrack() { return DoFindTrack(); }
48 std::shared_ptr<const Track> FindTrack() const
49 { return const_cast<CommonTrackPanelCell*>(this)->DoFindTrack(); }
50
51 struct MenuItem {
52 using Action = std::function< void(const CommandContext &) >;
53
54 MenuItem() = default;
56 Action action = {}, bool enabled = true )
57 : symbol{ internal, msgid }, action{ move(action) }, enabled{ enabled }
58 {}
59
62 bool enabled;
63 };
64
66
81 virtual std::vector<MenuItem> GetMenuItems(
82 const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject );
83
84protected:
85 virtual std::shared_ptr<Track> DoFindTrack() = 0;
86
87 unsigned DoContextMenu(
88 const wxRect &rect,
89 wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
90 override;
91
92 unsigned HandleWheelRotation
93 (const TrackPanelMouseEvent &event,
94 AudacityProject *pProject) override;
95
96};
97
98class AUDACITY_DLL_API CommonTrackCell /* not final */
100{
101public:
102 explicit CommonTrackCell( const std::shared_ptr<Track> &pTrack );
103
105
106 std::shared_ptr<Track> DoFindTrack() override;
107
108 void Reparent( const std::shared_ptr<Track> &parent ) override;
109
110private:
111 std::weak_ptr< Track > mwTrack;
112};
113
114#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
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:162
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