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
46 // Draw lines, INCLUSIVE of all endpoints
47 static void Lines(wxDC &dc, size_t nPoints, const wxPoint points[]);
48
49 static void DrawFocus(wxDC & dc, wxRect & r);
50 static void Bevel(wxDC & dc, bool up, const wxRect & r);
51 static void Bevel2
52 (wxDC & dc, bool up, const wxRect & r, bool bSel=false, bool bHighlight = false);
56 static void ButtonStretch(wxDC& dc, bool up, const wxRect& r, bool selected = false, bool highlight = false);
57 static void BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight = false);
58 static wxColour Blend(const wxColour & c1, const wxColour & c2);
59
60 static void UseThemeColour( wxDC * dc, int iBrush, int iPen=-1, int alpha = 255 );
61 static void UseThemeColour( wxGraphicsContext * gc, int iBrush, int iPen=-1, int alpha = 255 );
62 static void TrackPanelBackground(wxDC * dc, bool selected);
63
64 static void Light(wxDC * dc, bool selected, bool highlight = false);
65 static void Medium(wxDC * dc, bool selected);
66 static void MediumTrackInfo(wxDC * dc, bool selected);
67 static void Dark(wxDC * dc, bool selected, bool highlight = false);
68
69 static void CursorColor(wxDC * dc);
70 static void IndicatorColor(wxDC * dc, bool bIsNotRecording);
71
72 static void Mute(wxDC * dc, bool on, bool selected, bool soloing);
73 static void Solo(wxDC * dc, bool on, bool selected);
74
75 // In all of these, channel is 1-indexed (1 through 16); if out of bounds
76 // (either due to being explicitly set to 0 or due to an allegro file with
77 // more than 16 channels) a gray color is returned.
78
79 static void MIDIChannel(wxDC * dc, int channel /* 1 - 16 */ );
80 static void LightMIDIChannel(wxDC * dc, int channel /* 1 - 16 */ );
81 static void DarkMIDIChannel(wxDC * dc, int channel /* 1 - 16 */ );
82
83 static void TrackFocusPen(wxDC * dc, int level /* 0 - 2 */);
84 static void SnapGuidePen(wxDC * dc);
85
86 static void PreComputeGradient();
87
88 static void ApplyUpdatedImages();
89
90 // Member variables
91
92 static wxBrush lightBrush[2];
93 static wxBrush mediumBrush[2];
94 static wxBrush darkBrush[2];
95 static wxPen lightPen[2];
96 static wxPen mediumPen[2];
97 static wxPen darkPen[2];
98
99 static wxPen cursorPen;
100 static wxPen indicatorPen[2];
101 static wxBrush indicatorBrush[2];
102 // static wxPen playRegionPen[2];
103 static wxBrush playRegionBrush[1];
104
105 static wxBrush muteBrush[2];
106 static wxBrush soloBrush;
107
108 static wxPen clippingPen;
109
110 static wxPen envelopePen;
111 static wxPen WideEnvelopePen;
112 static wxBrush envelopeBrush;
113
114 static wxBrush labelTextNormalBrush;
115 static wxBrush labelTextEditBrush;
116 static wxBrush labelUnselectedBrush;
117 static wxBrush labelSelectedBrush;
118 static wxBrush labelSyncLockSelBrush;
119 static wxPen labelUnselectedPen;
120 static wxPen labelSelectedPen;
122 static wxPen labelSurroundPen;
123
124 static wxPen trackFocusPens[3];
125 static wxPen snapGuidePen;
126
127 static wxPen tooltipPen;
128 static wxBrush tooltipBrush;
129
130 static bool gradient_inited;
131 static const int colorSchemes = 4;
132 static const int gradientSteps = 256;
133 static unsigned char gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3];
134
135 // For experiments in mouse-over highlighting only
136 static wxPen uglyPen;
137 static wxBrush uglyBrush;
138
139 private:
140 static wxPen sparePen;
141 static wxBrush spareBrush;
142 static bool inited;
143
144};
145
146inline void GetColorGradient(float value,
148 int colorScheme,
149 unsigned char * __restrict red,
150 unsigned char * __restrict green,
151 unsigned char * __restrict blue) {
152
153 int idx = value * (AColor::gradientSteps - 1);
154
155 *red = AColor::gradient_pre[selected][colorScheme][idx][0];
156 *green = AColor::gradient_pre[selected][colorScheme][idx][1];
157 *blue = AColor::gradient_pre[selected][colorScheme][idx][2];
158}
159
160#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:146
AColor Manages color brushes and pens.
Definition: AColor.h:25
static wxBrush labelSelectedBrush
Definition: AColor.h:117
static wxPen clippingPen
Definition: AColor.h:108
static wxPen WideEnvelopePen
Definition: AColor.h:111
static wxPen sparePen
Definition: AColor.h:140
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:137
static bool inited
Definition: AColor.h:142
static wxPen labelSurroundPen
Definition: AColor.h:122
static wxPen cursorPen
Definition: AColor.h:99
static wxPen tooltipPen
Definition: AColor.h:127
static wxBrush envelopeBrush
Definition: AColor.h:112
static wxBrush labelTextNormalBrush
Definition: AColor.h:114
static wxBrush labelTextEditBrush
Definition: AColor.h:115
static wxPen uglyPen
Definition: AColor.h:136
static const int gradientSteps
Definition: AColor.h:132
static wxBrush labelSyncLockSelBrush
Definition: AColor.h:118
static wxPen envelopePen
Definition: AColor.h:110
static unsigned char gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3]
Definition: AColor.h:133
static wxPen labelSelectedPen
Definition: AColor.h:120
static wxBrush tooltipBrush
Definition: AColor.h:128
static wxBrush soloBrush
Definition: AColor.h:106
static wxBrush labelUnselectedBrush
Definition: AColor.h:116
static wxPen snapGuidePen
Definition: AColor.h:125
static wxBrush spareBrush
Definition: AColor.h:141
static wxPen labelUnselectedPen
Definition: AColor.h:119
static bool gradient_inited
Definition: AColor.h:130
static wxPen labelSyncLockSelPen
Definition: AColor.h:121