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 27 of file CommonTrackPanelCell.cpp.

28{
29}

Member Function Documentation

◆ DefaultPreview()

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

Reimplemented from TrackPanelCell.

Definition at line 31 of file CommonTrackPanelCell.cpp.

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

◆ DoContextMenu()

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

Reimplemented from TrackPanelCell.

Definition at line 45 of file CommonTrackPanelCell.cpp.

47{
48 const auto items = GetMenuItems( rect, pPoint, pProject );
49 if (items.empty())
51
52 // Set up command context with extras
53 CommandContext context{ *pProject };
54 SelectedRegion region;
55 if (pPoint) {
56 auto time = ViewInfo::Get(*pProject).PositionToTime(pPoint->x, rect.x);
57 region = { time, time };
58 context.temporarySelection.pSelectedRegion = &region;
59 }
60 context.temporarySelection.pTrack = FindTrack().get();
61
62 auto &commandManager = CommandManager::Get(*pProject);
63 auto flags = MenuManager::Get( *pProject ).GetUpdateFlags();
64
65 // Common dispatcher for the menu items
66 auto dispatcher = [&]( wxCommandEvent &evt ){
67 auto idx = evt.GetId() - 1;
68 if (idx >= 0 && idx < items.size()) {
69 if (auto &action = items[idx].action)
70 action( context );
71 else
72 commandManager.HandleTextualCommand(
73 items[idx].symbol.Internal(), context, flags, false);
74 }
75 };
76
77 wxMenu menu;
78 int ii = 1;
79 for (const auto &item: items) {
80 if ( const auto &commandID = item.symbol.Internal();
81 commandID.empty() )
82 menu.AppendSeparator();
83 else {
84 // Generate a menu item with the same shortcut key as in the toolbar
85 // menu, and as determined by keyboard preferences
86 auto label =
87 commandManager.FormatLabelForMenu( commandID, &item.symbol.Msgid() );
88 menu.Append( ii, label );
89 menu.Bind( wxEVT_COMMAND_MENU_SELECTED, dispatcher );
90 bool enabled = item.enabled &&
91 (item.action || commandManager.GetEnabled( commandID ));
92 menu.Enable( ii, enabled );
93 }
94 ++ii;
95 }
96
97 BasicUI::Point point;
98 if (pPoint)
99 point = { pPoint->x, pPoint->y };
100 BasicMenu::Handle{ &menu }.Popup(
101 wxWidgetsWindowPlacement{ pParent },
102 point
103 );
104
106}
TranslatableString label
Definition: TagsEditor.cpp:163
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:71
CommandFlag GetUpdateFlags(bool checkActive=false) const
Definition: Menus.cpp:553
Defines a selected portion of a project.
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
double PositionToTime(wxInt64 position, wxInt64 origin=0, bool ignoreFisheye=false) const
Definition: ZoomInfo.cpp:41
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::StartEditNameOfMatchingClip(), 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 38 of file CommonTrackPanelCell.cpp.

41{
42 return {};
43}

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 108 of file CommonTrackPanelCell.cpp.

110{
111 auto &hook = MouseWheelHook::Get();
112 return hook ? hook( evt, pProject ) : RefreshCode::Cancelled;
113}
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: