Audacity 3.2.0
Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
MinimizeButtonHandle Class Referencefinal

#include <TrackButtonHandles.h>

Inheritance diagram for MinimizeButtonHandle:
[legend]
Collaboration diagram for MinimizeButtonHandle:
[legend]

Public Member Functions

 MinimizeButtonHandle (const std::shared_ptr< Track > &pTrack, const wxRect &rect)
 
MinimizeButtonHandleoperator= (const MinimizeButtonHandle &)=default
 
virtual ~MinimizeButtonHandle ()
 
- 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 ChannelFindChannel () 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< MinimizeButtonHandle > &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 &) 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 ChannelFindChannel () 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

 MinimizeButtonHandle (const MinimizeButtonHandle &)=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 mIsDragging {}
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Detailed Description

Definition at line 18 of file TrackButtonHandles.h.

Constructor & Destructor Documentation

◆ MinimizeButtonHandle() [1/2]

MinimizeButtonHandle::MinimizeButtonHandle ( const MinimizeButtonHandle )
privatedelete

◆ MinimizeButtonHandle() [2/2]

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

Definition at line 28 of file TrackButtonHandles.cpp.

30 : ButtonHandle{ pTrack, rect }
31{}
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26

◆ ~MinimizeButtonHandle()

MinimizeButtonHandle::~MinimizeButtonHandle ( )
virtual

Definition at line 33 of file TrackButtonHandles.cpp.

34{
35}

Member Function Documentation

◆ CommitChanges()

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

Implements ButtonHandle.

Definition at line 37 of file TrackButtonHandles.cpp.

39{
40 using namespace RefreshCode;
41
42 if (auto pTrack = mpTrack.lock()) {
43 auto channels = pTrack->Channels();
44 bool wasMinimized = ChannelView::Get(**channels.begin()).GetMinimized();
45 for (auto pChannel : channels)
46 ChannelView::Get(*pChannel).SetMinimized( !wasMinimized );
47 ProjectHistory::Get(*pProject).ModifyState(true);
48
49 // Redraw all tracks when any one of them expands or contracts
50 // (Could we invent a return code that draws only those at or below
51 // the affected track?)
53 }
54
55 return RefreshNone;
56}
std::weak_ptr< Track > mpTrack
Definition: ButtonHandle.h:74
static ChannelView & Get(Channel &channel)
bool GetMinimized() const
Definition: ChannelView.h:68
void SetMinimized(bool minimized)
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16

References RefreshCode::FixScrollbars, ProjectHistory::Get(), ChannelView::Get(), ChannelView::GetMinimized(), ProjectHistory::ModifyState(), ButtonHandle::mpTrack, RefreshCode::RefreshAll, RefreshCode::RefreshNone, and ChannelView::SetMinimized().

Here is the call graph for this function:

◆ HitTest()

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

Definition at line 66 of file TrackButtonHandles.cpp.

69{
70 wxRect buttonRect;
71 CommonTrackInfo::GetMinimizeRect(rect, buttonRect);
72
73 if (buttonRect.Contains(state.m_x, state.m_y)) {
74 auto pTrack = static_cast<CommonTrackPanelCell*>(pCell)->FindTrack();
75 auto result = std::make_shared<MinimizeButtonHandle>( pTrack, buttonRect );
76 result = AssignUIHandlePtr(holder, result);
77 return result;
78 }
79 else
80 return {};
81}
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:159
AUDACITY_DLL_API void GetMinimizeRect(const wxRect &rect, wxRect &dest)
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:537

References AssignUIHandlePtr(), anonymous_namespace{TrackPanel.cpp}::FindTrack(), and CommonTrackInfo::GetMinimizeRect().

Referenced by CommonTrackControls::HitTest().

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

◆ operator=()

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

◆ Tip()

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

Implements ButtonHandle.

Definition at line 58 of file TrackButtonHandles.cpp.

60{
61 auto pTrack = GetTrack();
62 return ChannelView::Get(*pTrack->GetChannel(0)).GetMinimized()
63 ? XO("Expand") : XO("Collapse");
64}
XO("Cut/Copy/Paste")
std::shared_ptr< Track > GetTrack() const
Definition: ButtonHandle.h:30

References ChannelView::Get(), ChannelView::GetMinimized(), ButtonHandle::GetTrack(), and XO().

Here is the call graph for this function:

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