Audacity 3.2.0
TrackPanelCell.h
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5TrackPanelCell.h
6
7Paul Licameli
8
9**********************************************************************/
10
11#ifndef __AUDACITY_TRACK_PANEL_CELL__
12#define __AUDACITY_TRACK_PANEL_CELL__
13
14
15
16#include <memory>
17#include "TrackPanelDrawable.h" // to inherit
18
19class AudacityProject;
20struct HitTestPreview;
24class ViewInfo;
25class wxKeyEvent;
26class wxPoint;
27class wxRect;
28class wxWindow;
29
30class UIHandle;
31using UIHandlePtr = std::shared_ptr<UIHandle>;
32
33#include <vector>
34
37class AUDACITY_DLL_API /* not final */ TrackPanelNode
38 : public TrackPanelDrawable
39{
40public:
42 virtual ~TrackPanelNode() = 0;
43};
44
45// A node of the TrackPanel that contains other nodes.
46class AUDACITY_DLL_API TrackPanelGroup /* not final */ : public TrackPanelNode
47{
48public:
50 virtual ~TrackPanelGroup();
51
52 enum class Axis { X, Y };
53
54 // A refinement of a given rectangle partitions it along one of its axes
55 // and associates TrackPanelNodes with the partition.
56 // The sequence of coordinates should be increasing, giving left or top
57 // coordinates of sub-rectangles.
58 // Null pointers are permitted to define empty spaces with no cell object.
59 // If the first coordinate is right of or below the rectangle boundary,
60 // then that also defines an empty space at the edge.
61 // Sub-rectangles may be defined partly or wholly out of the bounds of the
62 // given rectangle. Such portions are ignored.
63 using Child = std::pair< wxCoord, std::shared_ptr<TrackPanelNode> >;
64 using Refinement = std::vector< Child >;
65 using Subdivision = std::pair< Axis, Refinement >;
66
67 // Report a subdivision of one of the axes of the given rectangle
68 virtual Subdivision Children( const wxRect &rect ) = 0;
69};
70
73class AUDACITY_DLL_API TrackPanelCell /* not final */ : public TrackPanelNode
74{
75public:
76 TrackPanelCell() = default;
77 TrackPanelCell( const TrackPanelCell & ) = delete;
79
80 virtual ~TrackPanelCell () = 0;
81
82 // May supply default cursor, status message, and tooltip, when there is no
83 // handle to hit at the mouse position, or the handle does not supply them.
84 virtual HitTestPreview DefaultPreview
85 (const TrackPanelMouseState &state, const AudacityProject *pProject);
86
87 // Return pointers to objects that can be queried for a status
88 // bar message and cursor appropriate to the point, and that dispatch
89 // mouse button events.
90 // The button-down state passed to the function is as it will be at click
91 // time -- not necessarily as it is now.
92 virtual std::vector<UIHandlePtr> HitTest
93 (const TrackPanelMouseState &state,
94 const AudacityProject *pProject) = 0;
95
96 // Return value is a bitwise OR of RefreshCode values
97 // Include Cancelled in the flags to indicate that the event is not handled.
98 // Default does only that.
99 virtual unsigned HandleWheelRotation
100 (const TrackPanelMouseEvent &event,
101 AudacityProject *pProject);
102
103 // A cell may delegate context menu handling to another one
104 virtual std::shared_ptr<TrackPanelCell> ContextMenuDelegate()
105 { return {}; }
106
107 // The pPosition parameter indicates mouse position but may be NULL
108 // Return value is a bitwise OR of RefreshCode values
109 // Default implementation does nothing
110 virtual unsigned DoContextMenu
111 (const wxRect &rect,
112 wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject);
113
114 // Return value is a bitwise OR of RefreshCode values
115 // Default skips the event and does nothing
116 virtual unsigned CaptureKey
117 (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent,
119
120 // Return value is a bitwise OR of RefreshCode values
121 // Default skips the event and does nothing
122 virtual unsigned KeyDown
123 (wxKeyEvent & event, ViewInfo &viewInfo, wxWindow *pParent,
125
126 // Return value is a bitwise OR of RefreshCode values
127 // Default skips the event and does nothing
128 virtual unsigned KeyUp
129 (wxKeyEvent & event, ViewInfo &viewInfo, wxWindow *pParent,
131
132 // Return value is a bitwise OR of RefreshCode values
133 // Default skips the event and does nothing
134 virtual unsigned Char
135 (wxKeyEvent & event, ViewInfo &viewInfo, wxWindow *pParent,
137
138 // Return value is a bitwise OR of RefreshCode values
139 // Notification to the focused cell that the CellularPanel is losing focus
140 // Default does nothing, returns RefreshCode::RefreshNone
141 virtual unsigned LoseFocus(AudacityProject *project);
142};
143
144#endif
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
virtual std::shared_ptr< TrackPanelCell > ContextMenuDelegate()
TrackPanelCell & operator=(const TrackPanelCell &)=delete
TrackPanelCell()=default
TrackPanelCell(const TrackPanelCell &)=delete
virtual std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject)=0
Drawing interface common to cells, groups of cells, and temporary handles in CellularPanel.
virtual Subdivision Children(const wxRect &rect)=0
std::pair< Axis, Refinement > Subdivision
std::vector< Child > Refinement
std::pair< wxCoord, std::shared_ptr< TrackPanelNode > > Child
The TrackPanel is built up of nodes, subtrees of the CellularPanel's area Common base class for Track...
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:36