Audacity 3.2.0
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:
[legend]
Collaboration diagram for MenuButtonHandle:
[legend]

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 IsDragging () const override
 
- Public Member Functions inherited from UIHandle
virtual ~UIHandle ()=0
 
virtual void Enter (bool forward, AudacityProject *pProject)
 
virtual bool HasRotation () const
 
virtual bool Rotate (bool forward)
 
virtual bool HasEscape (AudacityProject *pProject) const
 
virtual bool Escape (AudacityProject *pProject)
 
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
 
virtual Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject)=0
 
virtual HitTestPreview Preview (const TrackPanelMouseState &state, AudacityProject *pProject)=0
 
virtual Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
virtual Result Cancel (AudacityProject *pProject)=0
 
virtual bool StopsOnKeystroke ()
 
virtual void OnProjectChange (AudacityProject *pProject)
 
virtual std::shared_ptr< const TrackFindTrack () const =0
 
virtual bool IsDragging () const
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 
- 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)
 

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 &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- 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)
 

Protected Member Functions

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

Private Member Functions

 MenuButtonHandle (const MenuButtonHandle &)=delete
 

Private Attributes

std::weak_ptr< TrackPanelCellmpCell
 

Additional Inherited Members

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

Detailed Description

Definition at line 99 of file TrackButtonHandles.h.

Constructor & Destructor Documentation

◆ MenuButtonHandle() [1/2]

MenuButtonHandle::MenuButtonHandle ( const MenuButtonHandle )
privatedelete

◆ MenuButtonHandle() [2/2]

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

Definition at line 207 of file TrackButtonHandles.cpp.

210 : ButtonHandle{ pTrack, rect }
211 , mpCell{ pCell }
212{}
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26
std::weak_ptr< TrackPanelCell > mpCell

◆ ~MenuButtonHandle()

MenuButtonHandle::~MenuButtonHandle ( )
virtual

Definition at line 214 of file TrackButtonHandles.cpp.

215{
216}

Member Function Documentation

◆ CommitChanges()

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

Implements ButtonHandle.

Definition at line 218 of file TrackButtonHandles.cpp.

220{
221 auto &trackPanel = TrackPanel::Get( *pProject );
222 auto pCell = mpCell.lock();
223 if (!pCell)
225 auto pTrack =
226 static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
227 if (!pTrack)
229 trackPanel.CallAfter(
230 [&trackPanel,pTrack]{ trackPanel.OnTrackMenu( pTrack.get() ); } );
232}
std::shared_ptr< const Track > FindTrack() const override
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:234

References RefreshCode::Cancelled, ButtonHandle::FindTrack(), TrackPanel::Get(), mpCell, and RefreshCode::RefreshNone.

Here is the call graph for this function:

◆ HitTest()

UIHandlePtr MenuButtonHandle::HitTest ( std::weak_ptr< MenuButtonHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
const std::shared_ptr< TrackPanelCell > &  pCell 
)
static

Definition at line 248 of file TrackButtonHandles.cpp.

252{
253 wxRect buttonRect;
254 CommonTrackInfo::GetTitleBarRect(rect, buttonRect);
255
256 if (buttonRect.Contains(state.m_x, state.m_y)) {
257 auto pTrack = static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
258 auto result = std::make_shared<MenuButtonHandle>( pCell, pTrack, buttonRect );
259 result = AssignUIHandlePtr(holder, result);
260 return result;
261 }
262 else
263 return {};
264}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:164
AUDACITY_DLL_API void GetTitleBarRect(const wxRect &rect, wxRect &dest)

References AssignUIHandlePtr(), ButtonHandle::FindTrack(), and CommonTrackInfo::GetTitleBarRect().

Referenced by CommonTrackControls::HitTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

MenuButtonHandle & MenuButtonHandle::operator= ( const MenuButtonHandle )
default

◆ Tip()

TranslatableString MenuButtonHandle::Tip ( const wxMouseState &  state,
AudacityProject project 
) const
overrideprotectedvirtual

Implements ButtonHandle.

Definition at line 234 of file TrackButtonHandles.cpp.

236{
237 auto name = XO("Open menu...");
238 auto focused =
239 TrackFocus::Get( project ).Get() == GetTrack().get();
240 if (!focused)
241 return name;
242
243 auto &commandManager = CommandManager::Get( project );
244 ComponentInterfaceSymbol command{ wxT("TrackMenu"), name };
245 return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
246}
wxT("CloseDown"))
const TranslatableString name
Definition: Distortion.cpp:76
XO("Cut/Copy/Paste")
const auto project
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:30
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:318
static CommandManager & Get(AudacityProject &project)
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Track * Get()
Definition: TrackFocus.cpp:156

References TrackFocus::Get(), CommandManager::Get(), ClientData::Site< Host, ClientData, ObjectCopyingPolicy, Pointer, ObjectLockingPolicy, RegistryLockingPolicy >::Get(), ButtonHandle::GetTrack(), name, project, wxT(), and XO().

Here is the call graph for this function:

Member Data Documentation

◆ mpCell

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

Definition at line 126 of file TrackButtonHandles.h.

Referenced by CommitChanges().


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