Audacity  2.2.2
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:
ButtonHandle UIHandle

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 ()
 
virtual void DrawExtras (DrawingPass pass, wxDC *dc, const wxRegion &updateRegion, const wxRect &panelRect)
 
virtual void OnProjectChange (AudacityProject *pProject)
 
Result GetChangeHighlight () const
 
void SetChangeHighlight (Result val)
 

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 &)
 

Protected Member Functions

Result CommitChanges (const wxMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
wxString Tip (const wxMouseState &state) 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) 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

 CloseButtonHandle (const CloseButtonHandle &)=delete
 

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

Constructor & Destructor Documentation

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

Definition at line 77 of file TrackButtonHandles.cpp.

78  : ButtonHandle{ pTrack, rect }
79 {}
CloseButtonHandle::~CloseButtonHandle ( )
virtual

Definition at line 81 of file TrackButtonHandles.cpp.

82 {
83 }

Member Function Documentation

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

Implements ButtonHandle.

Definition at line 86 of file TrackButtonHandles.cpp.

References RefreshCode::DestroyedCell, RefreshCode::FixScrollbars, AudacityProject::IsAudioActive(), RefreshCode::RefreshAll, RefreshCode::RefreshNone, AudacityProject::RemoveTrack(), RefreshCode::Resize, and AudacityProject::StopIfPaused().

87 {
88  using namespace RefreshCode;
89  Result result = RefreshNone;
90 
91  auto pTrack = mpTrack.lock();
92  if (pTrack)
93  {
94  pProject->StopIfPaused();
95  if (!pProject->IsAudioActive()) {
96  // This pushes an undo item:
97  pProject->RemoveTrack(pTrack.get());
98  // Redraw all tracks when any one of them closes
99  // (Could we invent a return code that draws only those at or below
100  // the affected track?)
102  }
103  }
104 
105  return result;
106 }
unsigned Result
Definition: UIHandle.h:37
bool IsAudioActive() const
Definition: Project.cpp:1457
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:69
void RemoveTrack(Track *toRemove)
Removes the specified track. Called from HandleClosing.
Definition: Project.cpp:5765
void StopIfPaused()
Definition: Menus.cpp:2378
UIHandlePtr CloseButtonHandle::HitTest ( std::weak_ptr< CloseButtonHandle > &  holder,
const wxMouseState &  state,
const wxRect &  rect,
TrackPanelCell pCell 
)
static

Definition at line 123 of file TrackButtonHandles.cpp.

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

Referenced by TrackControls::HitTest().

125 {
126  wxRect buttonRect;
127  TrackInfo::GetCloseBoxRect(rect, buttonRect);
128 
129  if (buttonRect.Contains(state.m_x, state.m_y)) {
130  auto pTrack = static_cast<CommonTrackPanelCell*>(pCell)->FindTrack();
131  auto result = std::make_shared<CloseButtonHandle>( pTrack, buttonRect );
132  result = AssignUIHandlePtr(holder, result);
133  return result;
134  }
135  else
136  return {};
137 }
static void GetCloseBoxRect(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
CloseButtonHandle& CloseButtonHandle::operator= ( const CloseButtonHandle )
default
bool CloseButtonHandle::StopsOnKeystroke ( )
inlineoverrideprotectedvirtual

Reimplemented from UIHandle.

Definition at line 55 of file TrackButtonHandles.h.

55 { return true; }
wxString CloseButtonHandle::Tip ( const wxMouseState &  state) const
overrideprotectedvirtual

Implements ButtonHandle.

Definition at line 108 of file TrackButtonHandles.cpp.

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

109 {
110  auto name = _("Close");
111  auto project = ::GetActiveProject();
112  auto focused =
113  project->GetTrackPanel()->GetFocusedTrack() == GetTrack().get();
114  if (!focused)
115  return name;
116 
117  auto commandManager = project->GetCommandManager();
118  TranslatedInternalString command{ wxT("TrackClose"), name };
119  return commandManager->DescribeCommandsAndShortcuts( &command, 1u );
120 }
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:309

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