Audacity  3.0.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
CloseButtonHandle Class Referencefinal

#include <TrackButtonHandles.h>

Inheritance diagram for CloseButtonHandle:
Collaboration diagram for CloseButtonHandle:

Public Member Functions

 CloseButtonHandle (const std::shared_ptr< Track > &pTrack, const wxRect &rect)
CloseButtonHandleoperator= (const CloseButtonHandle &)=default
virtual ~CloseButtonHandle ()
- 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 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< CloseButtonHandle > &holder, const wxMouseState &state, const wxRect &rect, 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 &project) const override
bool StopsOnKeystroke () 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

 CloseButtonHandle (const CloseButtonHandle &)=delete

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 70 of file TrackButtonHandles.h.

Constructor & Destructor Documentation

◆ CloseButtonHandle() [1/2]

CloseButtonHandle::CloseButtonHandle ( const CloseButtonHandle )

◆ CloseButtonHandle() [2/2]

CloseButtonHandle::CloseButtonHandle ( const std::shared_ptr< Track > &  pTrack,
const wxRect &  rect 

Definition at line 142 of file TrackButtonHandles.cpp.

144  : ButtonHandle{ pTrack, rect }
145 {}

◆ ~CloseButtonHandle()

CloseButtonHandle::~CloseButtonHandle ( )

Definition at line 147 of file TrackButtonHandles.cpp.

148 {
149 }

Member Function Documentation

◆ CommitChanges()

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

Implements ButtonHandle.

Definition at line 151 of file TrackButtonHandles.cpp.

153 {
154  using namespace RefreshCode;
155  Result result = RefreshNone;
157  auto pTrack = mpTrack.lock();
158  if (pTrack)
159  {
160  auto toRemove = pTrack->SubstitutePendingChangedTrack();
161  ProjectAudioManager::Get( *pProject ).StopIfPaused();
162  if (!ProjectAudioIO::Get( *pProject ).IsAudioActive()) {
163  // This pushes an undo item:
164  TrackUtilities::DoRemoveTrack(*pProject, toRemove.get());
165  // Redraw all tracks when any one of them closes
166  // (Could we invent a return code that draws only those at or below
167  // the affected track?)
169  }
170  }
172  return result;
173 }

References RefreshCode::DestroyedCell, TrackUtilities::DoRemoveTrack(), RefreshCode::FixScrollbars, ProjectAudioIO::Get(), ProjectAudioManager::Get(), ProjectAudioIO::IsAudioActive(), ButtonHandle::mpTrack, RefreshCode::RefreshAll, RefreshCode::RefreshNone, RefreshCode::Resize, and ProjectAudioManager::StopIfPaused().

Here is the call graph for this function:

◆ HitTest()

UIHandlePtr CloseButtonHandle::HitTest ( std::weak_ptr< CloseButtonHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
TrackPanelCell pCell 

Definition at line 189 of file TrackButtonHandles.cpp.

192 {
193  wxRect buttonRect;
194  TrackInfo::GetCloseBoxRect(rect, buttonRect);
196  if (buttonRect.Contains(state.m_x, state.m_y)) {
197  auto pTrack = static_cast<CommonTrackPanelCell*>(pCell)->FindTrack();
198  auto result = std::make_shared<CloseButtonHandle>( pTrack, buttonRect );
199  result = AssignUIHandlePtr(holder, result);
200  return result;
201  }
202  else
203  return {};
204 }

References AssignUIHandlePtr(), anonymous_namespace{TrackPanel.cpp}::FindTrack(), and TrackInfo::GetCloseBoxRect().

Referenced by CommonTrackControls::HitTest().

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

◆ operator=()

CloseButtonHandle& CloseButtonHandle::operator= ( const CloseButtonHandle )

◆ StopsOnKeystroke()

bool CloseButtonHandle::StopsOnKeystroke ( )

Reimplemented from UIHandle.

Definition at line 82 of file TrackButtonHandles.h.

82 { return true; }

◆ Tip()

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

Implements ButtonHandle.

Definition at line 175 of file TrackButtonHandles.cpp.

177 {
178  auto name = XO("Close");
179  auto focused =
180  TrackFocus::Get( project ).Get() == GetTrack().get();
181  if (!focused)
182  return name;
184  auto &commandManager = CommandManager::Get( project );
185  ComponentInterfaceSymbol command{ wxT("TrackClose"), name };
186  return commandManager.DescribeCommandsAndShortcuts( &command, 1u );
187 }

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:

The documentation for this class was generated from the following files:
@ FixScrollbars
Definition: RefreshCode.h:27
static ProjectAudioManager & Get(AudacityProject &project)
Definition: ProjectAudioManager.cpp:55
@ RefreshAll
Definition: RefreshCode.h:26
@ RefreshNone
Definition: RefreshCode.h:21
AUDACITY_DLL_API void GetCloseBoxRect(const wxRect &rect, wxRect &dest)
Definition: TrackInfo.cpp:462
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
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:72
#define XO(s)
Definition: Internat.h:31
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:30
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:22
bool IsAudioActive() const
Definition: ProjectAudioIO.cpp:51
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterfaceSymbol.h:27
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26
unsigned Result
Definition: UIHandle.h:38
const TranslatableString name
Definition: Distortion.cpp:98
@ Resize
Definition: RefreshCode.h:28
Track * Get()
Definition: TrackPanelAx.cpp:755
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:530
@ DestroyedCell
Definition: RefreshCode.h:34
void DoRemoveTrack(AudacityProject &project, Track *toRemove)
Definition: TrackUtilities.cpp:163
void StopIfPaused()
Definition: ProjectAudioManager.cpp:1220
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
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16