Audacity 3.2.0
AColor.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 AColor.h
6
7 Dominic Mazzoni
8
9 Manages color brushes and pens and provides utility
10 drawing functions
11
12**********************************************************************/
13
14#ifndef __AUDACITY_COLOR__
15#define __AUDACITY_COLOR__
16
17#include <memory>
18#include <wx/brush.h> // member variable
19#include <wx/pen.h> // member variable
20
21class wxDC;
22class wxGraphicsContext;
23class wxRect;
24
25class THEME_API AColor {
26 public:
27
29 ColorGradientUnselected = 0,
33
34 ColorGradientTotal // keep me last
35 };
36
37 static void Init();
38 static void ReInit();
39
40 static void Arrow(wxDC & dc, wxCoord x, wxCoord y, int width, bool down = true);
41
42 // Draw a line, INCLUSIVE of both endpoints
43 // (unlike what wxDC::DrawLine() documentation specifies)
44 static void Line(wxDC & dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
45 static void Line(wxDC & dc, const wxPoint &from, const wxPoint &to);
46
47 // Draw lines, INCLUSIVE of all endpoints
48 static void Lines(wxDC &dc, size_t nPoints, const wxPoint points[]);
49
50 static void DrawFocus(wxDC & dc, wxRect & r);
51 static void Bevel(wxDC & dc, bool up, const wxRect & r);
52 static void Bevel2
53 (wxDC & dc, bool up, const wxRect & r, bool bSel=false, bool bHighlight = false);
54 // Draw image filling the rect.
55 // In horizontal direction only center pixels are stretched.
56 // In vertical direction image stretched proportionally.
57 static void DrawHStretch(wxDC& dc, const wxRect& rect, wxBitmap& bitmap);
58 static void DrawFrame(wxDC& dc, const wxRect& r, wxBitmap& bitmap, int mid);
62 static void ButtonStretch(wxDC& dc, bool up, const wxRect& r, bool selected = false, bool highlight = false);
63 static void BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight = false);
64 static wxColour Blend(const wxColour & c1, const wxColour & c2);
65
66 static void UseThemeColour( wxDC * dc, int iBrush, int iPen=-1, int alpha = 255 );
67 static void UseThemeColour( wxGraphicsContext * gc, int iBrush, int iPen=-1, int alpha = 255 );
68 static void TrackPanelBackground(wxDC * dc, bool selected);
69
70 static void Light(wxDC * dc, bool selected, bool highlight = false);
71 static void Medium(wxDC * dc, bool selected);
72 static void MediumTrackInfo(wxDC * dc, bool selected);
73 static void Dark(wxDC * dc, bool selected, bool highlight = false);
74
75 static void CursorColor(wxDC * dc);
76 static void IndicatorColor(wxDC * dc, bool bIsNotRecording);
77
78 static void Mute(wxDC * dc, bool on, bool selected, bool soloing);
79 static void Solo(wxDC * dc, bool on, bool selected);
80
81 // In all of these, channel is 1-indexed (1 through 16); if out of bounds
82 // (either due to being explicitly set to 0 or due to an allegro file with
83 // more than 16 channels) a gray color is returned.
84
85 static void MIDIChannel(wxDC * dc, int channel /* 1 - 16 */ );
86 static void LightMIDIChannel(wxDC * dc, int channel /* 1 - 16 */ );
87 static void DarkMIDIChannel(wxDC * dc, int channel /* 1 - 16 */ );
88
89 static void TrackFocusPen(wxDC * dc, int level /* 0 - 2 */);
90 static void SnapGuidePen(wxDC * dc);
91
92 static void PreComputeGradient();
93
94 static void ApplyUpdatedImages();
95
96 // Member variables
97
98 static wxBrush lightBrush[2];
99 static wxBrush mediumBrush[2];
100 static wxBrush darkBrush[2];
101 static wxPen lightPen[2];
102 static wxPen mediumPen[2];
103 static wxPen darkPen[2];
104
105 static wxPen cursorPen;
106 static wxPen indicatorPen[2];
107 static wxBrush indicatorBrush[2];
108 // static wxPen playRegionPen[2];
109 static wxBrush playRegionBrush[1];
110
111 static wxBrush muteBrush[2];
112 static wxBrush soloBrush;
113
114 static wxPen clippingPen;
115
116 static wxPen envelopePen;
117 static wxPen WideEnvelopePen;
118 static wxBrush envelopeBrush;
119
120 static wxBrush labelTextNormalBrush;
121 static wxBrush labelTextEditBrush;
122 static wxBrush labelUnselectedBrush;
123 static wxBrush labelSelectedBrush;
124 static wxBrush labelSyncLockSelBrush;
126 static wxPen labelSurroundPen;
127
128 static wxPen trackFocusPens[3];
129 static wxPen snapGuidePen;
130
131 static wxPen tooltipPen;
132 static wxBrush tooltipBrush;
133
134 static bool gradient_inited;
135 static const int colorSchemes = 4;
136 static const int gradientSteps = 256;
137 static unsigned char gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3];
138
139 // For experiments in mouse-over highlighting only
140 static wxPen uglyPen;
141 static wxBrush uglyBrush;
142
143 private:
144 static wxPen sparePen;
145 static wxBrush spareBrush;
146 static bool inited;
147
148};
149
150inline void GetColorGradient(float value,
152 int colorScheme,
153 unsigned char * __restrict red,
154 unsigned char * __restrict green,
155 unsigned char * __restrict blue) {
156
157 int idx = value * (AColor::gradientSteps - 1);
158
159 *red = AColor::gradient_pre[selected][colorScheme][idx][0];
160 *green = AColor::gradient_pre[selected][colorScheme][idx][1];
161 *blue = AColor::gradient_pre[selected][colorScheme][idx][2];
162}
163
164#endif
void GetColorGradient(float value, AColor::ColorGradientChoice selected, int colorScheme, unsigned char *__restrict red, unsigned char *__restrict green, unsigned char *__restrict blue)
Definition: AColor.h:150
AColor Manages color brushes and pens.
Definition: AColor.h:25
static wxBrush labelSelectedBrush
Definition: AColor.h:123
static wxPen clippingPen
Definition: AColor.h:114
static wxPen WideEnvelopePen
Definition: AColor.h:117
static wxPen sparePen
Definition: AColor.h:144
ColorGradientChoice
Definition: AColor.h:28
@ ColorGradientTimeAndFrequencySelected
Definition: AColor.h:31
@ ColorGradientEdge
Definition: AColor.h:32
@ ColorGradientTimeSelected
Definition: AColor.h:30
static wxBrush uglyBrush
Definition: AColor.h:141
static bool inited
Definition: AColor.h:146
static wxPen labelSurroundPen
Definition: AColor.h:126
static wxPen cursorPen
Definition: AColor.h:105
static wxPen tooltipPen
Definition: AColor.h:131
static wxBrush envelopeBrush
Definition: AColor.h:118
static wxBrush labelTextNormalBrush
Definition: AColor.h:120
static wxBrush labelTextEditBrush
Definition: AColor.h:121
static wxPen uglyPen
Definition: AColor.h:140
static const int gradientSteps
Definition: AColor.h:136
static wxBrush labelSyncLockSelBrush
Definition: AColor.h:124
static wxPen envelopePen
Definition: AColor.h:116
static unsigned char gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3]
Definition: AColor.h:137
static wxBrush tooltipBrush
Definition: AColor.h:132
static wxBrush soloBrush
Definition: AColor.h:112
static wxBrush labelUnselectedBrush
Definition: AColor.h:122
static wxPen snapGuidePen
Definition: AColor.h:129
static wxBrush spareBrush
Definition: AColor.h:145
static bool gradient_inited
Definition: AColor.h:134
static wxPen labelSyncLockSelPen
Definition: AColor.h:125