Audacity 3.2.0
Public Member Functions | Protected Member Functions | Protected Attributes | Static Private Member Functions | Private Attributes | List of all members
HighlitClipButtonHandle Class Referenceabstract

#include <HighlitClipButtonHandle.h>

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

Public Member Functions

 HighlitClipButtonHandle (ClipButtonId id, std::shared_ptr< WaveTrack > track, std::shared_ptr< WaveTrack::Interval > clip)
 
void Enter (bool forward, AudacityProject *pProject) override
 
void Draw (TrackPanelDrawingContext &context, const wxRect &rect, unsigned iPass) override
 
Result Click (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Drag (const TrackPanelMouseEvent &event, AudacityProject *pProject) override
 
Result Cancel (AudacityProject *pProject) override
 
std::shared_ptr< const TrackFindTrack () const override
 
Result Release (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
 
virtual void DoDraw (const wxRect &args, wxDC &dc)=0
 
- 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 TrackFindTrack () 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)
 

Protected Member Functions

virtual Result DoRelease (const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
 
UIHandle::Result UpdateTrackSelection (const TrackPanelMouseEvent &event, AudacityProject *pProject)
 
UIHandle::Result SelectAt (const TrackPanelMouseEvent &event, AudacityProject *project)
 

Protected Attributes

ClipButtonId mButtonId
 
std::shared_ptr< WaveTrackmTrack
 
std::shared_ptr< WaveTrack::IntervalmClip
 
- Protected Attributes inherited from UIHandle
Result mChangeHighlight { 0 }
 

Static Private Member Functions

static void Highlight (const wxRect &rect, wxDC &dc)
 

Private Attributes

std::weak_ptr< TrackPanelCellmwCell
 

Additional Inherited Members

- Public Types inherited from UIHandle
using Result = unsigned
 
using Cell = TrackPanelCell
 
- Static Public Member Functions inherited from UIHandle
static UIHandle::Result NeedChangeHighlight (const UIHandle &, const UIHandle &)
 
static std::shared_ptr< const TrackTrackFromChannel (const std::shared_ptr< const Channel > &pChannel)
 A frequent convenience in the definition of UIHandles. More...
 
- 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)
 

Detailed Description

Definition at line 29 of file HighlitClipButtonHandle.h.

Constructor & Destructor Documentation

◆ HighlitClipButtonHandle()

HighlitClipButtonHandle::HighlitClipButtonHandle ( ClipButtonId  id,
std::shared_ptr< WaveTrack track,
std::shared_ptr< WaveTrack::Interval clip 
)

Audacity: A Digital Audio Editor

HighlitClipButtonHandle.cpp

Matthieu Hodgkinson

Definition at line 30 of file HighlitClipButtonHandle.cpp.

33 : mButtonId { id }
34 , mTrack { std::move(track) }
35 , mClip { std::move(clip) }
36{
37}
std::shared_ptr< WaveTrack > mTrack
std::shared_ptr< WaveTrack::Interval > mClip

Member Function Documentation

◆ Cancel()

UIHandle::Result HighlitClipButtonHandle::Cancel ( AudacityProject pProject)
overridevirtual

Implements UIHandle.

Definition at line 92 of file HighlitClipButtonHandle.cpp.

93{
94 return 0;
95}

◆ Click()

UIHandle::Result HighlitClipButtonHandle::Click ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 55 of file HighlitClipButtonHandle.cpp.

57{
58 mwCell = event.pCell;
59 return 0;
60}
std::weak_ptr< TrackPanelCell > mwCell

References mwCell.

◆ DoDraw()

virtual void HighlitClipButtonHandle::DoDraw ( const wxRect &  args,
wxDC &  dc 
)
pure virtual

Implemented in ClipOverflowButtonHandle, and ClipPitchAndSpeedButtonHandle.

Referenced by Draw().

Here is the caller graph for this function:

◆ DoRelease()

virtual Result HighlitClipButtonHandle::DoRelease ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
protectedpure virtual

Implemented in ClipOverflowButtonHandle, and ClipPitchAndSpeedButtonHandle.

Referenced by Release().

Here is the caller graph for this function:

◆ Drag()

UIHandle::Result HighlitClipButtonHandle::Drag ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
overridevirtual

Implements UIHandle.

Definition at line 62 of file HighlitClipButtonHandle.cpp.

64{
65 const auto cancelCode = RefreshCode::RefreshCell | RefreshCode::Cancelled;
66 if (event.pCell != mwCell.lock())
67 return cancelCode;
68
69 // It's the right cell; check that the mouse is still over the button.
71 mButtonId, { *mClip, ViewInfo::Get(*pProject), event.rect });
72 if (!buttonRect.has_value())
73 return cancelCode;
74
75 const auto mousePos = event.event.GetPosition();
76 if (!buttonRect->Contains(mousePos))
77 return cancelCode;
78
79 return 0;
80}
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
std::optional< wxRect > GetButtonRectangle(ClipButtonId buttonId, const RectangleArgs &args)
std::shared_ptr< TrackPanelCell > pCell

References RefreshCode::Cancelled, ViewInfo::Get(), LowlitClipButton::Detail::GetButtonRectangle(), mButtonId, mClip, mwCell, TrackPanelMouseEvent::pCell, and RefreshCode::RefreshCell.

Here is the call graph for this function:

◆ Draw()

void HighlitClipButtonHandle::Draw ( TrackPanelDrawingContext context,
const wxRect &  rect,
unsigned  iPass 
)
overridevirtual

Reimplemented from TrackPanelDrawable.

Definition at line 39 of file HighlitClipButtonHandle.cpp.

42{
43 if (iPass != TrackArtist::PassSnapping)
44 return;
45 const auto artist = TrackArtist::Get(context);
46 const auto& zoomInfo = *artist->pZoomInfo;
48 mButtonId, { *mClip, zoomInfo, affordanceRect });
49 if (!rect)
50 return;
51 Highlight(*rect, context.dc);
52 DoDraw(*rect, context.dc);
53}
static void Highlight(const wxRect &rect, wxDC &dc)
virtual void DoDraw(const wxRect &args, wxDC &dc)=0
static TrackArtist * Get(TrackPanelDrawingContext &)
Definition: TrackArtist.cpp:69
std::optional< wxRect > GetButtonInnerRectangle(ClipButtonId buttonId, const RectangleArgs &args)

References TrackPanelDrawingContext::dc, DoDraw(), TrackArtist::Get(), LowlitClipButton::Detail::GetButtonInnerRectangle(), Highlight(), mButtonId, mClip, and TrackArtist::PassSnapping.

Here is the call graph for this function:

◆ Enter()

void HighlitClipButtonHandle::Enter ( bool  forward,
AudacityProject pProject 
)
overridevirtual

Reimplemented from UIHandle.

Definition at line 125 of file HighlitClipButtonHandle.cpp.

126{
128}
Result mChangeHighlight
Definition: UIHandle.h:152

References UIHandle::mChangeHighlight, and RefreshCode::RefreshCell.

◆ FindTrack()

std::shared_ptr< const Track > HighlitClipButtonHandle::FindTrack ( ) const
overridevirtual
Returns
pointer to associated track, if any

Implements UIHandle.

Definition at line 120 of file HighlitClipButtonHandle.cpp.

121{
122 return mTrack;
123}

References mTrack.

◆ Highlight()

void HighlitClipButtonHandle::Highlight ( const wxRect &  rect,
wxDC &  dc 
)
staticprivate

Definition at line 130 of file HighlitClipButtonHandle.cpp.

131{
132 constexpr auto penWidth = 0;
133 const auto col = theTheme.Colour(clrClipAffordanceStroke);
134 wxDCBrushChanger brush { dc, col };
135 wxDCPenChanger pen { dc, { wxPenInfo { col, penWidth } } };
136 constexpr auto radius = 3;
137 dc.DrawRoundedRectangle(rect, radius);
138}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), and theTheme.

Referenced by Draw().

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

◆ Release()

UIHandle::Result HighlitClipButtonHandle::Release ( const TrackPanelMouseEvent event,
AudacityProject pProject,
wxWindow *  pParent 
)
overridevirtual

Implements UIHandle.

Definition at line 82 of file HighlitClipButtonHandle.cpp.

85{
87 // Select before calling `DoRelease`.
88 const auto result = UpdateTrackSelection(event, pProject);
89 return result | DoRelease(event, pProject, pParent);
90}
virtual Result DoRelease(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent)=0
UIHandle::Result UpdateTrackSelection(const TrackPanelMouseEvent &event, AudacityProject *pProject)

References DoRelease(), UIHandle::mChangeHighlight, RefreshCode::RefreshNone, and UpdateTrackSelection().

Here is the call graph for this function:

◆ SelectAt()

UIHandle::Result HighlitClipButtonHandle::SelectAt ( const TrackPanelMouseEvent event,
AudacityProject project 
)
protected

◆ UpdateTrackSelection()

UIHandle::Result HighlitClipButtonHandle::UpdateTrackSelection ( const TrackPanelMouseEvent event,
AudacityProject pProject 
)
protected

Definition at line 97 of file HighlitClipButtonHandle.cpp.

99{
100 auto& trackList = TrackList::Get(*pProject);
101
102 if (const auto track = trackList.Lock<Track>(mTrack))
103 {
104 auto& selectionState = SelectionState::Get(*pProject);
105 selectionState.SelectNone(trackList);
106 selectionState.SelectTrack(*track, true, true);
107
108 auto& viewInfo = ViewInfo::Get(*pProject);
109 viewInfo.selectedRegion.setTimes(
110 mClip->GetPlayStartTime(), mClip->GetPlayEndTime());
111
112 ProjectHistory::Get(*pProject).ModifyState(false);
113
115 }
116
118}
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
static SelectionState & Get(AudacityProject &project)
Abstract base class for an object holding data associated with points on a time axis.
Definition: Track.h:110
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:314

References RefreshCode::Cancelled, ProjectHistory::Get(), ViewInfo::Get(), SelectionState::Get(), TrackList::Get(), mClip, ProjectHistory::ModifyState(), mTrack, RefreshCode::RefreshAll, and RefreshCode::RefreshNone.

Referenced by Release().

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

Member Data Documentation

◆ mButtonId

ClipButtonId HighlitClipButtonHandle::mButtonId
protected

Definition at line 69 of file HighlitClipButtonHandle.h.

Referenced by Drag(), and Draw().

◆ mClip

std::shared_ptr<WaveTrack::Interval> HighlitClipButtonHandle::mClip
protected

◆ mTrack

std::shared_ptr<WaveTrack> HighlitClipButtonHandle::mTrack
protected

◆ mwCell

std::weak_ptr<TrackPanelCell> HighlitClipButtonHandle::mwCell
private

Definition at line 75 of file HighlitClipButtonHandle.h.

Referenced by Click(), and Drag().


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