Audacity  3.0.3
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:
Collaboration diagram for MenuButtonHandle:

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 (AudacityProject *pProject)
virtual bool HandlesRightClick ()
 Whether the handle has any special right-button handling. More...
virtual bool StopsOnKeystroke ()
virtual void OnProjectChange (AudacityProject *pProject)
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 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 ()
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 mIsClicked {}
- 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 )

◆ MenuButtonHandle() [2/2]

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

Definition at line 208 of file TrackButtonHandles.cpp.

211  : ButtonHandle{ pTrack, rect }
212  , mpCell{ pCell }
213 {}

◆ ~MenuButtonHandle()

MenuButtonHandle::~MenuButtonHandle ( )

Definition at line 215 of file TrackButtonHandles.cpp.

216 {
217 }

Member Function Documentation

◆ CommitChanges()

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

Implements ButtonHandle.

Definition at line 219 of file TrackButtonHandles.cpp.

221 {
222  auto &trackPanel = TrackPanel::Get( *pProject );
223  auto pCell = mpCell.lock();
224  if (!pCell)
225  return RefreshCode::Cancelled;
226  auto pTrack =
227  static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
228  if (!pTrack)
229  return RefreshCode::Cancelled;
230  trackPanel.CallAfter(
231  [&trackPanel,pTrack]{ trackPanel.OnTrackMenu( pTrack.get() ); } );
233 }

References RefreshCode::Cancelled, anonymous_namespace{TrackPanel.cpp}::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 

Definition at line 249 of file TrackButtonHandles.cpp.

253 {
254  wxRect buttonRect;
255  TrackInfo::GetTitleBarRect(rect, buttonRect);
257  if (buttonRect.Contains(state.m_x, state.m_y)) {
258  auto pTrack = static_cast<CommonTrackPanelCell*>(pCell.get())->FindTrack();
259  auto result = std::make_shared<MenuButtonHandle>( pCell, pTrack, buttonRect );
260  result = AssignUIHandlePtr(holder, result);
261  return result;
262  }
263  else
264  return {};
265 }

References AssignUIHandlePtr(), anonymous_namespace{TrackPanel.cpp}::FindTrack(), and TrackInfo::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 )

◆ Tip()

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

Implements ButtonHandle.

Definition at line 235 of file TrackButtonHandles.cpp.

237 {
238  auto name = XO("Open menu...");
239  auto focused =
240  TrackFocus::Get( project ).Get() == GetTrack().get();
241  if (!focused)
242  return name;
244  auto &commandManager = CommandManager::Get( project );
245  ComponentInterfaceSymbol command{ wxT("TrackMenu"), name };
246  return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
247 }

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

Here is the call graph for this function:

Member Data Documentation

◆ mpCell

std::weak_ptr<TrackPanelCell> MenuButtonHandle::mpCell

Definition at line 126 of file TrackButtonHandles.h.

Referenced by CommitChanges().

The documentation for this class was generated from the following files:
@ RefreshNone
Definition: RefreshCode.h:21
Subclass & Get(const RegisteredFactory &key)
Get reference to an attachment, creating on demand if not present, down-cast it to Subclass.
Definition: ClientData.h:309
@ Cancelled
Definition: RefreshCode.h:23
static TrackPanel & Get(AudacityProject &project)
Definition: TrackPanel.cpp:227
#define XO(s)
Definition: Internat.h:31
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:30
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
AUDACITY_DLL_API void GetTitleBarRect(const wxRect &rect, wxRect &dest)
Definition: TrackInfo.cpp:479
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26
const TranslatableString name
Definition: Distortion.cpp:98
Track * Get()
Definition: TrackPanelAx.cpp:755
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:530
std::weak_ptr< TrackPanelCell > mpCell
Definition: TrackButtonHandles.h:126
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
Definition: CommonTrackPanelCell.h:28
static CommandManager & Get(AudacityProject &project)
Definition: CommandManager.cpp:207