Audacity 3.2.0
LowlitClipButton.h
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 LowlitClipButton.h
7
8 Describes the buttons that appear on the audio clips in their "lowlit" state,
9 i.e., the opposite of the "highlit", or "highlighted", state. These buttons
10 are highlit when the mouse hovers over them, and lowlit otherwise.
11
12 Matthieu Hodgkinson
13
14**********************************************************************/
15#pragma once
16
17#include "ClipButtonId.h"
18#include "ClipParameters.h"
19#include "UIHandle.h"
20#include "WaveTrack.h"
21
22class wxRect;
23class wxPoint;
24class wxDC;
25class ClipInterface;
26class ZoomInfo;
27
29{
30 const wxRect& rect;
32 wxDC& dc;
33};
34
35template <ClipButtonId id> struct ClipButtonSpecializations
36{
37 static bool NeedsDrawing(const ClipInterface&);
39 static int GetWidth(const ClipInterface& clip);
40};
41
42template<>
44{
45 static bool NeedsDrawing(const ClipInterface& clip);
47 static int GetWidth(const ClipInterface& clip);
48};
49
50template<>
52{
53 static bool NeedsDrawing(const ClipInterface& clip);
55 static int GetWidth(const ClipInterface& clip);
56};
57
58template<>
60{
61 static bool NeedsDrawing(const ClipInterface& clip);
63 static int GetWidth(const ClipInterface& clip);
64};
65
67{
69{
72 // The upper ribbon of a track's rectangle, where the affordances of one or
73 // more clips are drawn.
74 const wxRect& trackAffordanceRect;
75};
76
77namespace Detail
78{
79std::optional<wxRect>
80GetButtonRectangle(ClipButtonId buttonId, const RectangleArgs& args);
81
82std::optional<wxRect>
84} // namespace Detail
85
86template <ClipButtonId id>
87bool HitTest(const RectangleArgs& args, const wxPoint& mousePos)
88{
90 return false;
91 const auto buttonRect = Detail::GetButtonRectangle(id, args);
92 return buttonRect.has_value() && buttonRect->Contains(mousePos);
93}
94
95template <ClipButtonId id>
96std::optional<wxRect> DrawOnClip(const RectangleArgs& args, wxDC& dc)
97{
99 return {};
100 const auto rect = Detail::GetButtonInnerRectangle(id, args);
101 if (!rect)
102 return {};
103 ClipButtonDrawingArgs drawingArgs { *rect, args.clip, dc };
105 return rect;
106}
107} // namespace LowlitClipButton
ClipButtonId
Definition: ClipButtonId.h:14
std::optional< wxRect > GetButtonRectangle(ClipButtonId buttonId, const RectangleArgs &args)
std::optional< wxRect > GetButtonInnerRectangle(ClipButtonId buttonId, const RectangleArgs &args)
std::optional< wxRect > DrawOnClip(const RectangleArgs &args, wxDC &dc)
bool HitTest(const RectangleArgs &args, const wxPoint &mousePos)
const ClipInterface & clip
static int GetWidth(const ClipInterface &clip)
static void DrawOnClip(ClipButtonDrawingArgs &)
static bool NeedsDrawing(const ClipInterface &)