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