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