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

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 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< 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 ()
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 mIsClicked {}
- 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 )

◆ MinimizeButtonHandle() [2/2]

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

Definition at line 28 of file TrackButtonHandles.cpp.

30  : ButtonHandle{ pTrack, rect }
31 {}

◆ ~MinimizeButtonHandle()

MinimizeButtonHandle::~MinimizeButtonHandle ( )

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 

Implements ButtonHandle.

Definition at line 37 of file TrackButtonHandles.cpp.

39 {
40  using namespace RefreshCode;
42  auto pTrack = mpTrack.lock();
43  if (pTrack)
44  {
45  auto channels = TrackList::Channels(pTrack.get());
46  bool wasMinimized = TrackView::Get( **channels.begin() ).GetMinimized();
47  for (auto channel : channels)
48  TrackView::Get( *channel ).SetMinimized( !wasMinimized );
49  ProjectHistory::Get( *pProject ).ModifyState(true);
51  // Redraw all tracks when any one of them expands or contracts
52  // (Could we invent a return code that draws only those at or below
53  // the affected track?)
54  return RefreshAll | FixScrollbars;
55  }
57  return RefreshNone;
58 }

References TrackList::Channels(), RefreshCode::FixScrollbars, ProjectHistory::Get(), TrackView::Get(), TrackView::GetMinimized(), ProjectHistory::ModifyState(), ButtonHandle::mpTrack, RefreshCode::RefreshAll, RefreshCode::RefreshNone, and TrackView::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 

Definition at line 68 of file TrackButtonHandles.cpp.

71 {
72  wxRect buttonRect;
73  TrackInfo::GetMinimizeRect(rect, buttonRect);
75  if (buttonRect.Contains(state.m_x, state.m_y)) {
76  auto pTrack = static_cast<CommonTrackPanelCell*>(pCell)->FindTrack();
77  auto result = std::make_shared<MinimizeButtonHandle>( pTrack, buttonRect );
78  result = AssignUIHandlePtr(holder, result);
79  return result;
80  }
81  else
82  return {};
83 }

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

◆ Tip()

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

Implements ButtonHandle.

Definition at line 60 of file TrackButtonHandles.cpp.

62 {
63  auto pTrack = GetTrack();
64  return TrackView::Get( *pTrack ).GetMinimized()
65  ? XO("Expand") : XO("Collapse");
66 }

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

Here is the call graph for this function:

The documentation for this class was generated from the following files:
void ModifyState(bool bWantsAutoSave)
Definition: ProjectHistory.cpp:124
@ FixScrollbars
Definition: RefreshCode.h:27
@ RefreshAll
Definition: RefreshCode.h:26
static TrackView & Get(Track &)
Definition: TrackView.cpp:63
void SetMinimized(bool minimized)
Definition: TrackView.cpp:77
@ RefreshNone
Definition: RefreshCode.h:21
bool GetMinimized() const
Definition: TrackView.h:49
static auto Channels(TrackType *pTrack) -> TrackIterRange< TrackType >
Definition: Track.h:1484
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
A UIHandle for a TrackPanel button, such as the Mute and Solo buttons.
Definition: ButtonHandle.h:26
std::shared_ptr< Track > FindTrack(TrackPanelCell *pCell)
Definition: TrackPanel.cpp:530
AUDACITY_DLL_API void GetMinimizeRect(const wxRect &rect, wxRect &dest)
Definition: TrackInfo.cpp:507
std::shared_ptr< Subclass > AssignUIHandlePtr(std::weak_ptr< Subclass > &holder, const std::shared_ptr< Subclass > &pNew)
Definition: UIHandle.h:151
Definition: CommonTrackPanelCell.h:28
Namespace containing an enum 'what to do on a refresh?'.
Definition: RefreshCode.h:16
static ProjectHistory & Get(AudacityProject &project)
Definition: ProjectHistory.cpp:26