Audacity 3.2.0
ClipOverflowButtonHandle.cpp
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*!********************************************************************
3
4 Audacity: A Digital Audio Editor
5
6 ClipOverflowButtonHandle.cpp
7
8 Matthieu Hodgkinson
9
10**********************************************************************/
12#include "AllThemeResources.h"
13#include "HitTestResult.h"
14#include "LowlitClipButton.h"
15#include "ProjectHistory.h"
16#include "RefreshCode.h"
17#include "Theme.h"
18#include "TrackArt.h"
19#include "TrackPanelCell.h"
21#include "ViewInfo.h"
22#include "WaveClip.h"
23#include "WaveTrack.h"
24#include <wx/dc.h>
25#include <wx/event.h>
26
27namespace
28{
31{
32 auto& viewInfo = ViewInfo::Get(project);
33 viewInfo.selectedRegion.setTimes(
34 interval.GetPlayStartTime(), interval.GetPlayEndTime());
36}
37} // namespace
38
40 const std::shared_ptr<WaveTrack>& track,
41 const std::shared_ptr<WaveTrack::Interval>& clip,
42 std::weak_ptr<TrackPanelCell> cell)
44 , mCell { std::move(cell) }
45{
46}
47
48void ClipOverflowButtonHandle::DoDraw(const wxRect& rect, wxDC& dc)
49{
50 const ClipInterface& clip = *mClip;
51 ClipButtonDrawingArgs args { rect, clip, dc };
53}
54
56 const TrackPanelMouseEvent& event, AudacityProject* pProject,
57 wxWindow* pParent)
58{
59 if (const auto cell = mCell.lock())
60 {
61 SelectInterval(*pProject, *mClip);
62 const wxPoint point { event.event.GetPosition() };
63 return cell->DoContextMenu(event.rect, pParent, &point, pProject);
64 }
66}
67
69 const TrackPanelMouseState& state, AudacityProject* pProject)
70{
71 return { XO("Click to open clip context menu."), nullptr };
72}
73
75 const ClipInterface&)
76{
77 return 30;
78}
79
81 const ClipInterface&)
82{
83 return true;
84}
85
88{
89 auto& dc = args.dc;
90 const auto& rect = args.rect;
91 constexpr auto penWidth = 0;
92 wxDCPenChanger pen { args.dc, { wxPenInfo { *wxBLACK, penWidth } } };
93 wxDCBrushChanger brush { dc, *wxBLACK_BRUSH };
94 constexpr auto numDots = 3;
95 constexpr auto radius = 1;
96 constexpr auto spacing = 4;
97 constexpr auto totalWidth = numDots * 2 * radius + 2 * spacing;
98 const auto dotY = rect.y + (rect.height + 1 - radius) / 2;
99 for (auto i = 0; i < numDots; ++i)
100 {
101 const auto dotX = rect.x + (rect.width + 1 - totalWidth) / 2 +
102 i * (2 * radius + spacing);
103 dc.DrawCircle(dotX, dotY, radius);
104 }
105}
ClipButtonId
Definition: ClipButtonId.h:14
XO("Cut/Copy/Paste")
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
std::weak_ptr< TrackPanelCell > mCell
void DoDraw(const wxRect &rect, wxDC &dc) override
Result DoRelease(const TrackPanelMouseEvent &event, AudacityProject *pProject, wxWindow *pParent) override
HitTestPreview Preview(const TrackPanelMouseState &state, AudacityProject *pProject) override
ClipOverflowButtonHandle(const std::shared_ptr< WaveTrack > &track, const std::shared_ptr< WaveTrack::Interval > &clip, std::weak_ptr< TrackPanelCell > cell)
std::shared_ptr< WaveTrack::Interval > mClip
void ModifyState(bool bWantsAutoSave)
static ProjectHistory & Get(AudacityProject &project)
unsigned Result
Definition: UIHandle.h:40
static ViewInfo & Get(AudacityProject &project)
Definition: ViewInfo.cpp:235
This allows multiple clips to be a part of one WaveTrack.
Definition: WaveClip.h:238
double GetPlayStartTime() const noexcept override
Definition: WaveClip.cpp:1753
double GetPlayEndTime() const override
Definition: WaveClip.cpp:1763
void SelectInterval(AudacityProject &project, const WaveTrack::Interval &interval)
STL namespace.
static int GetWidth(const ClipInterface &clip)
static void DrawOnClip(ClipButtonDrawingArgs &)
static bool NeedsDrawing(const ClipInterface &)