Audacity 3.2.0
Classes | Public Member Functions | Protected Member Functions | List of all members
CommonTrackPanelCell Class Referenceabstract

#include <CommonTrackPanelCell.h>

Inheritance diagram for CommonTrackPanelCell:
[legend]
Collaboration diagram for CommonTrackPanelCell:
[legend]

Classes

struct  MenuItem
 
struct  MouseWheelHook
 

Public Member Functions

 CommonTrackPanelCell ()
 
virtual ~CommonTrackPanelCell ()=0
 
HitTestPreview DefaultPreview (const TrackPanelMouseState &, const AudacityProject *) override
 
std::shared_ptr< TrackFindTrack ()
 
std::shared_ptr< const TrackFindTrack () const
 
virtual std::vector< MenuItemGetMenuItems (const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
 Return a list of items for DoContextMenu() (empties for separators) More...
 
- Public Member Functions inherited from TrackPanelCell
 TrackPanelCell ()=default
 
 TrackPanelCell (const TrackPanelCell &) PROHIBITED
 
TrackPanelCelloperator= (const TrackPanelCell &) PROHIBITED
 
virtual ~TrackPanelCell ()=0
 
virtual HitTestPreview DefaultPreview (const TrackPanelMouseState &state, const AudacityProject *pProject)
 
virtual std::vector< UIHandlePtrHitTest (const TrackPanelMouseState &state, const AudacityProject *pProject)=0
 
virtual unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
virtual std::shared_ptr< TrackPanelCellContextMenuDelegate ()
 
virtual unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject)
 
virtual unsigned CaptureKey (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyDown (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned KeyUp (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned Char (wxKeyEvent &event, ViewInfo &viewInfo, wxWindow *pParent, AudacityProject *project)
 
virtual unsigned LoseFocus (AudacityProject *project)
 
- Public Member Functions inherited from TrackPanelNode
 TrackPanelNode ()
 
virtual ~TrackPanelNode ()=0
 
- Public Member Functions inherited from TrackPanelDrawable
virtual ~TrackPanelDrawable ()=0
 
virtual void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass)
 
virtual wxRect DrawingArea (TrackPanelDrawingContext &context, const wxRect &rect, const wxRect &panelRect, unsigned iPass)
 

Protected Member Functions

virtual std::shared_ptr< TrackDoFindTrack ()=0
 
unsigned DoContextMenu (const wxRect &rect, wxWindow *pParent, const wxPoint *pPosition, AudacityProject *pProject) override
 
unsigned HandleWheelRotation (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 

Additional Inherited Members

- Static Public Member Functions inherited from TrackPanelDrawable
static wxRect MaximizeWidth (const wxRect &rect, const wxRect &panelRect)
 
static wxRect MaximizeHeight (const wxRect &rect, const wxRect &panelRect)
 

Detailed Description

Definition at line 29 of file CommonTrackPanelCell.h.

Constructor & Destructor Documentation

◆ CommonTrackPanelCell()

CommonTrackPanelCell::CommonTrackPanelCell ( )
inline

Definition at line 38 of file CommonTrackPanelCell.h.

39 {}

◆ ~CommonTrackPanelCell()

CommonTrackPanelCell::~CommonTrackPanelCell ( )
pure virtual

Definition at line 28 of file CommonTrackPanelCell.cpp.

29{
30}

Member Function Documentation

◆ DefaultPreview()

HitTestPreview CommonTrackPanelCell::DefaultPreview ( const TrackPanelMouseState ,
const AudacityProject  
)
overridevirtual

Reimplemented from TrackPanelCell.

Definition at line 32 of file CommonTrackPanelCell.cpp.

34{
35 static wxCursor defaultCursor{ wxCURSOR_ARROW };
36 return { {}, &defaultCursor, {} };
37}

◆ DoContextMenu()

unsigned CommonTrackPanelCell::DoContextMenu ( const wxRect &  rect,
wxWindow *  pParent,
const wxPoint *  pPosition,
AudacityProject pProject 
)
overrideprotectedvirtual

Reimplemented from TrackPanelCell.

Definition at line 46 of file CommonTrackPanelCell.cpp.

48{
49 const auto items = GetMenuItems( rect, pPoint, pProject );
50 if (items.empty())
52
53 // Set up command context with extras
54 CommandContext context{ *pProject };
55 SelectedRegion region;
56 if (pPoint) {
57 auto time = ViewInfo::Get(*pProject).PositionToTime(pPoint->x, rect.x);
58 region = { time, time };
59 context.temporarySelection.pSelectedRegion = &region;
60 }
61 context.temporarySelection.pTrack = FindTrack().get();
62
63 auto &commandManager = CommandManager::Get(*pProject);
64 auto flags = MenuManager::Get( *pProject ).GetUpdateFlags();
65
66 // Common dispatcher for the menu items
67 auto dispatcher = [&]( wxCommandEvent &evt ){
68 auto idx = evt.GetId() - 1;
69 if (idx >= 0 && idx < items.size()) {
70 if (auto &action = items[idx].action)
71 action( context );
72 else
73 commandManager.HandleTextualCommand(
74 items[idx].symbol.Internal(), context, flags, false);
75 }
76 };
77
78 wxMenu menu;
79 int ii = 1;
80 for (const auto &item: items) {
81 if ( const auto &commandID = item.symbol.Internal();
82 commandID.empty() )
83 menu.AppendSeparator();
84 else {
85 // Generate a menu item with the same shortcut key as in the toolbar
86 // menu, and as determined by keyboard preferences
87 auto label =
88 commandManager.FormatLabelForMenu( commandID, &item.symbol.Msgid() );
89 menu.Append( ii, label );
90 menu.Bind( wxEVT_COMMAND_MENU_SELECTED, dispatcher );
91 bool enabled = item.enabled &&
92 (item.action || commandManager.GetEnabled( commandID ));
93 menu.Enable( ii, enabled );
94 }
95 ++ii;
96 }
97
98 BasicUI::Point point;
99 if (pPoint)
100 point = { pPoint->x, pPoint->y };
101 BasicMenu::Handle{ &menu }.Popup(
102 wxWidgetsWindowPlacement{ pParent },
103 point
104 );
105
107}
TranslatableString label
Definition: TagsEditor.cpp:164
void Popup(const BasicUI::WindowPlacement &window, const Point &pos={})
Display the menu at pos, invoke at most one action, then hide it.
Definition: BasicMenu.cpp:209
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
static CommandManager & Get(AudacityProject &project)
std::shared_ptr< Track > FindTrack()
virtual std::vector< MenuItem > GetMenuItems(const wxRect &rect, const wxPoint *pPosition, AudacityProject *pProject)
Return a list of items for DoContextMenu() (empties for separators)
static MenuManager & Get(AudacityProject &project)
Definition: Menus.cpp:69
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:533
Defines a selected portion of a project.
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:234
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:34
A pair of screen coordinates, x increasing rightward, y downward.
Definition: BasicUIPoint.h:18
Window placement information for wxWidgetsBasicUI can be constructed from a wxWindow pointer.

References FindTrack(), ViewInfo::Get(), CommandManager::Get(), MenuManager::Get(), GetMenuItems(), MenuManager::GetUpdateFlags(), label, BasicMenu::Handle::Popup(), ZoomInfo::PositionToTime(), RefreshCode::RefreshNone, and BasicUI::Point::x.

Here is the call graph for this function:

◆ DoFindTrack()

virtual std::shared_ptr< Track > CommonTrackPanelCell::DoFindTrack ( )
protectedpure virtual

◆ FindTrack() [1/2]

std::shared_ptr< Track > CommonTrackPanelCell::FindTrack ( )
inline

Definition at line 47 of file CommonTrackPanelCell.h.

47{ return DoFindTrack(); }
virtual std::shared_ptr< Track > DoFindTrack()=0

Referenced by WaveTrackView::CaptureKey(), anonymous_namespace{SelectHandle.cpp}::ChooseBoundary(), CommonTrackView::ContextMenuDelegate(), WaveTrackView::CopySelectedText(), WaveTrackView::CutSelectedText(), SpectrumView::DetailedHitTest(), TimeTrackView::DetailedHitTest(), CommonTrackControls::DoContextMenu(), DoContextMenu(), WaveTrackVRulerControls::DoDraw(), SpectrumView::DoSetMinimized(), WaveformView::DoSetMinimized(), SelectHandle::Drag(), TimeShiftHandle::Drag(), LabelTrackView::Draw(), TrackPanelResizerCell::Draw(), NoteTrackAffordanceControls::Draw(), NoteTrackView::Draw(), NoteTrackVRulerControls::Draw(), SpectrumView::Draw(), WaveformView::Draw(), WaveTrackAffordanceControls::Draw(), TimeTrackView::Draw(), TimeTrackVRulerControls::Draw(), CommonTrackControls::Draw(), TrackVRulerControls::Draw(), WaveTrackAffordanceControls::ExitTextEditing(), LabelTrackView::FindLabelTrack(), TrackPanel::FindRulerRects(), WaveTrackView::GetAffordanceControls(), CommonTrackView::GetMinimizedHeight(), NoteTrackVRulerControls::HandleWheelRotation(), SpectrumVRulerControls::HandleWheelRotation(), WaveformVRulerControls::HandleWheelRotation(), TrackPanelResizerCell::HitTest(), CommonTrackView::HitTest(), SpectrumVRulerControls::HitTest(), WaveformVRulerControls::HitTest(), TimeTrackVRulerControls::HitTest(), CommonTrackControls::HitTest(), NoteTrackAffordanceControls::HitTest(), NoteTrackControls::HitTest(), NoteTrackVRulerControls::HitTest(), WaveTrackAffordanceControls::HitTest(), WaveTrackControls::HitTest(), SubViewCloseHandle::HitTest(), WaveClipTrimHandle::HitTest(), anonymous_namespace{BrushHandle.cpp}::isSpectralSelectionView(), anonymous_namespace{SelectHandle.cpp}::isSpectralSelectionView(), SelectHandle::MoveSnappingFreqSelection(), LabelTrackView::OnLabelAdded(), LabelTrackView::OnLabelDeleted(), LabelTrackView::OnLabelPermuted(), LabelTrackView::OnSelectionChange(), WaveTrackView::PasteText(), WaveTrackView::SelectAllText(), WaveTrackView::SelectNextClip(), TrackView::SetExpandedHeight(), TrackView::SetMinimized(), SpectrumView::SpectrumView(), WaveTrackAffordanceControls::StartEditSelectedClipName(), SelectHandle::StartFreqSelection(), NoteTrackVRulerControls::UpdateRuler(), SpectrumVRulerControls::UpdateRuler(), WaveformVRulerControls::UpdateRuler(), and TimeTrackVRulerControls::UpdateRuler().

◆ FindTrack() [2/2]

std::shared_ptr< const Track > CommonTrackPanelCell::FindTrack ( ) const
inline

Definition at line 48 of file CommonTrackPanelCell.h.

49 { return const_cast<CommonTrackPanelCell*>(this)->DoFindTrack(); }

◆ GetMenuItems()

auto CommonTrackPanelCell::GetMenuItems ( const wxRect &  rect,
const wxPoint *  pPosition,
AudacityProject pProject 
)
virtual

Return a list of items for DoContextMenu() (empties for separators)

If the vector is empty (as in the default), there is no context menu.

Commands are invoked with temporary selection fields of CommandContext set to a point selected region at the mouse pick, and the cell's track.

A function may be given, but if it is null, then the command can be found by name in the CommandManager.

An item in the list with no command name marks a menu separator.

The menu item is enabled only if it contains a true flag, but if looked up in the command manager, it must also satisfy the command manager's conditions.

Reimplemented in WaveTrackSubView, and BackgroundCell.

Definition at line 39 of file CommonTrackPanelCell.cpp.

42{
43 return {};
44}

Referenced by DoContextMenu().

Here is the caller graph for this function:

◆ HandleWheelRotation()

unsigned CommonTrackPanelCell::HandleWheelRotation ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overrideprotectedvirtual

Reimplemented from TrackPanelCell.

Definition at line 109 of file CommonTrackPanelCell.cpp.

111{
112 auto &hook = MouseWheelHook::Get();
113 return hook ? hook( evt, pProject ) : RefreshCode::Cancelled;
114}
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References RefreshCode::Cancelled, and GlobalVariable< MouseWheelHook, const std::function< unsigned(const TrackPanelMouseEvent &evt, AudacityProject *pProject) >, Options... >::Get().

Here is the call graph for this function:

The documentation for this class was generated from the following files: