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