| 1 |
/* SPDX-License-Identifier: GPL-2.0-or-later */ |
| 2 |
/*!******************************************************************** |
| 3 |
|
| 4 |
Audacity: A Digital Audio Editor |
| 5 |
|
| 6 |
HighlitClipButtonHandle.h |
| 7 |
|
| 8 |
A `UIHandle` implementation to interact with the clip buttons when they are |
| 9 |
highlit, i.e., when the mouse hovers over them. |
| 10 |
|
| 11 |
Matthieu Hodgkinson |
| 12 |
|
| 13 |
**********************************************************************/ |
| 14 |
#pragma once |
| 15 |
|
| 16 |
#include "ClipButtonId.h" |
| 17 |
#include "UIHandle.h" |
| 18 |
#include "WaveTrack.h" |
| 19 |
#include <functional> |
| 20 |
|
| 21 |
class wxRect; |
| 22 |
class wxPoint; |
| 23 |
class Channel; |
| 24 |
class TrackPanelMouseEvent; |
| 25 |
class AudacityProject; |
| 26 |
class wxWindow; |
| 27 |
class AffordanceHandle; |
| 28 |
|
| 29 |
class HighlitClipButtonHandle /* not final */ : public UIHandle |
| 30 |
{ |
| 31 |
public: |
| 32 |
HighlitClipButtonHandle( |
| 33 |
ClipButtonId id, std::shared_ptr<WaveTrack> track, |
| 34 |
std::shared_ptr<WaveTrack::Interval> clip); |
| 35 |
|
| 36 |
void Enter(bool forward, AudacityProject* pProject) override; |
| 37 |
|
| 38 |
void Draw( |
| 39 |
TrackPanelDrawingContext& context, const wxRect& rect, |
| 40 |
unsigned iPass) override; |
| 41 |
|
| 42 |
Result |
| 43 |
Click(const TrackPanelMouseEvent& event, AudacityProject* pProject) override; |
| 44 |
|
| 45 |
Result |
| 46 |
Drag(const TrackPanelMouseEvent& event, AudacityProject* pProject) override; |
| 47 |
|
| 48 |
Result Cancel(AudacityProject* pProject) override; |
| 49 |
|
| 50 |
std::shared_ptr<const Track> FindTrack() const override; |
| 51 |
|
| 52 |
Result Release( |
| 53 |
const TrackPanelMouseEvent& event, AudacityProject* pProject, |
| 54 |
wxWindow* pParent) override; |
| 55 |
|
| 56 |
virtual void DoDraw(const wxRect& args, wxDC& dc) = 0; |
| 57 |
|
| 58 |
protected: |
| 59 |
virtual Result DoRelease( |
| 60 |
const TrackPanelMouseEvent& event, AudacityProject* pProject, |
| 61 |
wxWindow* pParent) = 0; |
| 62 |
|
| 63 |
UIHandle::Result UpdateTrackSelection( |
| 64 |
const TrackPanelMouseEvent& event, AudacityProject* pProject); |
| 65 |
|
| 66 |
UIHandle::Result |
| 67 |
SelectAt(const TrackPanelMouseEvent& event, AudacityProject* project); |
| 68 |
|
| 69 |
ClipButtonId mButtonId; |
| 70 |
std::shared_ptr<WaveTrack> mTrack; |
| 71 |
std::shared_ptr<WaveTrack::Interval> mClip; |
| 72 |
|
| 73 |
private: |
| 74 |
static void Highlight(const wxRect& rect, wxDC& dc); |
| 75 |
std::weak_ptr<TrackPanelCell> mwCell; |
| 76 |
}; |