Audacity  3.0.3
TrackPanelCell.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 TrackPanelCell.h
6 
7 Paul 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 
19 class AudacityProject;
20 struct HitTestPreview;
24 class ViewInfo;
25 class wxKeyEvent;
26 class wxPoint;
27 class wxRect;
28 class wxWindow;
29 
30 class UIHandle;
31 using UIHandlePtr = std::shared_ptr<UIHandle>;
32 
33 #include <vector>
34 
37 class AUDACITY_DLL_API /* not final */ TrackPanelNode
38  : public TrackPanelDrawable
39 {
40 public:
42  virtual ~TrackPanelNode() = 0;
43 };
44 
45 // A node of the TrackPanel that contains other nodes.
46 class AUDACITY_DLL_API TrackPanelGroup /* not final */ : public TrackPanelNode
47 {
48 public:
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 
73 class AUDACITY_DLL_API TrackPanelCell /* not final */ : public TrackPanelNode
74 {
75 public:
76  TrackPanelCell() = default;
77  TrackPanelCell( const TrackPanelCell & ) PROHIBITED;
78  TrackPanelCell &operator=( const TrackPanelCell & ) PROHIBITED;
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,
118  AudacityProject *project);
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,
124  AudacityProject *project);
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,
130  AudacityProject *project);
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,
136  AudacityProject *project);
137 };
138 
139 #endif
TrackPanelGroup::Refinement
std::vector< Child > Refinement
Definition: TrackPanelCell.h:64
TrackPanelGroup::Subdivision
std::pair< Axis, Refinement > Subdivision
Definition: TrackPanelCell.h:65
TrackPanelCell::HitTest
virtual std::vector< UIHandlePtr > HitTest(const TrackPanelMouseState &state, const AudacityProject *pProject)=0
TrackPanelDrawingContext
Definition: TrackPanelDrawingContext.h:22
ViewInfo
Definition: ViewInfo.h:169
TrackPanelGroup::Children
virtual Subdivision Children(const wxRect &rect)=0
TrackPanelCell::TrackPanelCell
TrackPanelCell()=default
TrackPanelGroup::Child
std::pair< wxCoord, std::shared_ptr< TrackPanelNode > > Child
Definition: TrackPanelCell.h:63
UIHandle
Short-lived drawing and event-handling object associated with a TrackPanelCell.
Definition: UIHandle.h:35
TrackPanelNode
The TrackPanel is built up of nodes, subtrees of the CellularPanel's area Common base class for Track...
Definition: TrackPanelCell.h:39
UIHandlePtr
std::shared_ptr< UIHandle > UIHandlePtr
Definition: CellularPanel.h:28
TrackPanelCell
Definition: TrackPanelCell.h:74
HitTestPreview
Definition: HitTestResult.h:20
TrackPanelDrawable.h
TrackPanelGroup
Definition: TrackPanelCell.h:47
TrackPanelCell::TrackPanelCell
TrackPanelCell(const TrackPanelCell &) PROHIBITED
TrackPanelCell::ContextMenuDelegate
virtual std::shared_ptr< TrackPanelCell > ContextMenuDelegate()
Definition: TrackPanelCell.h:104
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
TrackPanelCell::operator=
TrackPanelCell & operator=(const TrackPanelCell &) PROHIBITED
TrackPanelMouseEvent
Definition: TrackPanelMouseEvent.h:46
TrackPanelMouseState
Definition: TrackPanelMouseEvent.h:28
TrackPanelGroup::Axis
Axis
Definition: TrackPanelCell.h:52
TrackPanelDrawable
Drawing interface common to cells, groups of cells, and temporary handles in CellularPanel.
Definition: TrackPanelDrawable.h:22