Audacity  2.2.2
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
MenuButtonHandle Class Referencefinal

#include <TrackButtonHandles.h>

Inheritance diagram for MenuButtonHandle:
ButtonHandle UIHandle

Public Member Functions

 MenuButtonHandle (const std::shared_ptr< TrackPanelCell > &pCell, const std::shared_ptr< Track > &pTrack, const wxRect &rect)
 
MenuButtonHandleoperator= (const MenuButtonHandle &)=default
 
virtual ~MenuButtonHandle ()
 
- Public Member Functions inherited from ButtonHandle
std::shared_ptr< TrackGetTrack () const
 
bool IsClicked () const
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape () const
 
virtual bool Escape ()
 
virtual void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect)
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

Static Public Member Functions

static UIHandlePtr HitTest (std::weak_ptr< MenuButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, const std::shared_ptr< TrackPanelCell > &pCell)
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 

Protected Member Functions

Result CommitChanges (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
wxString Tip (const wxMouseState &state) const override
 
- Protected Member Functions inherited from ButtonHandle
 ButtonHandle (const std::shared_ptr< Track > &pTrack, const wxRect &rect)
 
ButtonHandleoperator= (const ButtonHandle &)=default
 
virtual ~ButtonHandle ()
 
void Enter (bool forward) finaloverride
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) finaloverride
 
HitTestPreview Preview (const TrackPanelMouseState &state, const AudacityProject *pProject) finaloverride
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) finaloverride
 
Result Cancel (AudacityProject *pProject) finaloverride
 

Private Member Functions

 MenuButtonHandle (const MenuButtonHandle &)=delete
 

Private Attributes

std::weak_ptr< TrackPanelCellmpCell
 

Additional Inherited Members

- Public Types inherited from UIHandle
enum  DrawingPass { Cells, Panel }
 
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Protected Attributes inherited from ButtonHandle
std::weak_ptr< TrackmpTrack
 
wxRect mRect
 
bool mWasIn { true }
 
bool mIsClicked {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 75 of file TrackButtonHandles.h.

Constructor & Destructor Documentation

MenuButtonHandle::MenuButtonHandle ( const MenuButtonHandle )
privatedelete
MenuButtonHandle::MenuButtonHandle ( const std::shared_ptr< TrackPanelCell > &  pCell,
const std::shared_ptr< Track > &  pTrack,
const wxRect &  rect 
)
explicit

Definition at line 142 of file TrackButtonHandles.cpp.

144  : ButtonHandle{ pTrack, rect }
145  , mpCell{ pCell }
146 {}
std::weak_ptr< TrackPanelCell > mpCell
MenuButtonHandle::~MenuButtonHandle ( )
virtual

Definition at line 148 of file TrackButtonHandles.cpp.

149 {
150 }

Member Function Documentation

UIHandle::Result MenuButtonHandle::CommitChanges ( const wxMouseEvent &  event,
AudacityProject pProject,
wxWindow *  pParent 
)
overrideprotectedvirtual

Implements ButtonHandle.

Definition at line 153 of file TrackButtonHandles.cpp.

References RefreshCode::Cancelled, AudacityProject::GetTrackPanel(), and RefreshCode::RefreshNone.

154 {
155  auto pPanel = pProject->GetTrackPanel();
156  auto pCell = mpCell.lock();
157  if (!pCell)
158  return RefreshCode::Cancelled;
159  auto pTrack =
160  static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
161  if (!pTrack)
162  return RefreshCode::Cancelled;
163  pPanel->CallAfter( [=]{ pPanel->OnTrackMenu( pTrack.get() ); } );
165 }
std::weak_ptr< TrackPanelCell > mpCell
TrackPanel * GetTrackPanel()
Definition: Project.h:307
UIHandlePtr MenuButtonHandle::HitTest ( std::weak_ptr< MenuButtonHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const std::shared_ptr< TrackPanelCell > &  pCell 
)
static

Definition at line 182 of file TrackButtonHandles.cpp.

References AssignUIHandlePtr(), and TrackInfo::GetTitleBarRect().

Referenced by TrackControls::HitTest().

185 {
186  wxRect buttonRect;
187  TrackInfo::GetTitleBarRect(rect, buttonRect);
188 
189  if (buttonRect.Contains(state.m_x, state.m_y)) {
190  auto pTrack = static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
191  auto result = std::make_shared<MenuButtonHandle>( pCell, pTrack, buttonRect );
192  result = AssignUIHandlePtr(holder, result);
193  return result;
194  }
195  else
196  return {};
197 }
static void GetTitleBarRect(const wxRect &rect, wxRect &dest)
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:162
MenuButtonHandle& MenuButtonHandle::operator= ( const MenuButtonHandle )
default
wxString MenuButtonHandle::Tip ( const wxMouseState &  state) const
overrideprotectedvirtual

Implements ButtonHandle.

Definition at line 167 of file TrackButtonHandles.cpp.

References _(), GetActiveProject(), ButtonHandle::GetTrack(), and name.

168 {
169  auto name = _("Open menu...");
170  auto project = ::GetActiveProject();
171  auto focused =
172  project->GetTrackPanel()->GetFocusedTrack() == GetTrack().get();
173  if (!focused)
174  return name;
175 
176  auto commandManager = project->GetCommandManager();
177  TranslatedInternalString command{ wxT("TrackMenu"), name };
178  return commandManager->DescribeCommandsAndShortcuts( &command, 1u );
179 }
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:28
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop")).Raw()), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom")).Raw()), OnMoveTrack)#define SET_TRACK_NAME_PLUGIN_SYMBOLclass SetTrackNameCommand:public AudacityCommand
const wxChar * name
Definition: Distortion.cpp:94
AUDACITY_DLL_API AudacityProject * GetActiveProject()
Definition: Project.cpp:308

Member Data Documentation

std::weak_ptr<TrackPanelCell> MenuButtonHandle::mpCell
private

Definition at line 101 of file TrackButtonHandles.h.


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