25#include <wx/dcmemory.h>
26#include <wx/graphics.h>
27#include <wx/settings.h>
82 void DrawNinePatch(wxDC& dc, wxBitmap& bitmap,
const wxRect& r,
int mid = 1)
84 assert(bitmap.GetWidth() == mid + (bitmap.GetWidth() - mid) / 2 + (bitmap.GetWidth() - mid) / 2);
85 assert(bitmap.GetHeight() == mid + (bitmap.GetHeight() - mid) / 2 + (bitmap.GetHeight() - mid) / 2);
86 assert(r.width >= bitmap.GetWidth() - mid);
87 assert(r.height >= bitmap.GetHeight() - mid);
89 memDC.SelectObject(bitmap);
93 const auto uw0 = (bitmap.GetWidth() - mid) / 2;
95 const auto uw2 = bitmap.GetWidth() - uw0 - uw1;
97 const auto vh0 = (bitmap.GetHeight() - mid) / 2;
99 const auto vh2 = bitmap.GetHeight() - vh1 - vh0;
103 const auto u2 = uw0 + uw1;
107 const auto v2 = vh0 + vh1;
111 const auto xw0 =
std::min(uw0, r.width / 2);
112 const auto xw2 =
std::min(uw2, r.width / 2);
113 const auto xw1 = std::max(r.width - xw0 - xw2, 0);
115 const auto yh0 =
std::min(vh0, r.height / 2);
116 const auto yh2 =
std::min(vh2, r.height / 2);
117 const auto yh1 = std::max(r.height - yh0 - yh2, 0);
120 const auto x1 = r.x + xw0;
121 const auto x2 = r.x + xw0 + xw1;
124 const auto y1 = r.y + yh0;
125 const auto y2 = r.y + yh0 + yh1;
128 dc.StretchBlit(x0, y0, xw0, yh0, &memDC, u0, v0, uw0, vh0, wxCOPY,
true);
129 dc.StretchBlit(x2, y0, xw2, yh0, &memDC, u2, v0, uw2, vh0, wxCOPY,
true);
130 dc.StretchBlit(x0, y2, xw0, yh2, &memDC, u0, v2, uw0, vh2, wxCOPY,
true);
131 dc.StretchBlit(x2, y2, xw2, yh2, &memDC, u2, v2, uw2, vh2, wxCOPY,
true);
133 if(xw1 > 0 && yh1 > 0)
135 dc.StretchBlit(x1, y0, xw1, yh0, &memDC, u1, v0, uw1, vh0, wxCOPY,
true);
137 dc.StretchBlit(x0, y1, xw0, yh1, &memDC, u0, v1, uw0, vh1, wxCOPY,
true);
138 dc.StretchBlit(x1, y1, xw1, yh1, &memDC, u1, v1, uw1, vh1, wxCOPY,
true);
139 dc.StretchBlit(x2, y1, xw2, yh1, &memDC, u2, v1, uw2, vh1, wxCOPY,
true);
141 dc.StretchBlit(x1, y2, xw1, yh2, &memDC, u1, v2, uw1, vh2, wxCOPY,
true);
154 if ( highlight && selected)
155 return up ? bmpHiliteUpButtonExpandSel : bmpHiliteButtonExpandSel;
157 return up ? bmpHiliteUpButtonExpand : bmpHiliteButtonExpand;
159 return up ? bmpUpButtonExpandSel : bmpDownButtonExpandSel;
160 return up ? bmpUpButtonExpand : bmpDownButtonExpand;
174 int half = width / 2;
177 pt[0].x = 0; pt[0].y = 0;
178 pt[1].x = width; pt[1].y = 0;
179 pt[2].x = half; pt[2].y = half;
182 pt[0].x = 0; pt[0].y = half;
183 pt[1].x = half; pt[1].y = 0;
184 pt[2].x = width; pt[2].y = half;
187 dc.DrawPolygon(3, pt, x, y);
194void AColor::Line(wxDC & dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
196 const wxPoint points[] { { x1, y1 }, { x2, y2 } };
197 Lines( dc, 2, points );
202 Line( dc, from.x, from.y, to.x, to.y);
208 if ( nPoints <= 1 ) {
210 dc.DrawPoint( points[0] );
214 for (
size_t ii = 0; ii < nPoints - 1; ++ii) {
215 const auto &p1 = points[ii];
216 const auto &p2 = points[ii + 1];
227#if defined(__WXMAC__) || defined(__WXGTK3__)
237#if defined(__WXMAC__) || defined(__WXGTK3__)
240 dc.DrawPoint( points[ nPoints - 1 ] );
252 wxCoord x1 = rect.GetLeft(),
254 x2 = rect.GetRight(),
255 y2 = rect.GetBottom();
261 for ( z = x1 + 1; z < x2; z += 2 )
264 wxCoord shift = z == x2 ? 0 : 1;
265 for ( z = y1 + shift; z < y2; z += 2 )
268 shift = z == y2 ? 0 : 1;
269 for ( z = x2 - shift; z > x1; z -= 2 )
272 shift = z == x1 ? 0 : 1;
273 for ( z = y2 - shift; z > y1; z -= 2 )
285 AColor::Line(dc, r.x + r.width, r.y, r.x + r.width, r.y + r.height);
286 AColor::Line(dc, r.x, r.y + r.height, r.x + r.width, r.y + r.height);
298void AColor::Bevel2(wxDC & dc,
bool up,
const wxRect & r,
bool bSel,
bool bHighlight)
302 memDC.SelectObject(Bmp);
304 int h =
std::min(r.height, Bmp.GetHeight());
306 dc.Blit( r.x,r.y,r.width/2, h, &memDC, 0, 0, wxCOPY,
true );
307 int r2 = r.width - r.width/2;
308 dc.Blit( r.x+r.width/2,r.y,r2, h, &memDC,
309 Bmp.GetWidth() - r2, 0, wxCOPY,
true );
315 srcDC.SelectObject(bitmap);
317 const auto sh = bitmap.GetHeight();
318 const auto dh = rect.height;
319 const auto w0 =
std::min((bitmap.GetWidth() - 1) / 2, rect.width / 2);
320 const auto dx0 = rect.x;
321 const auto dx1 = rect.x + w0;
322 const auto dx2 = rect.x + rect.width - w0;
324 dc.StretchBlit(dx0, rect.y, w0, dh, &srcDC, 0, 0, w0, sh, wxCOPY,
true);
325 dc.StretchBlit(dx1, rect.y, rect.width - w0 * 2, dh, &srcDC, w0, 0, 1, sh, wxCOPY,
true);
326 dc.StretchBlit(dx2, rect.y, w0, dh, &srcDC, bitmap.GetWidth() - w0, 0, w0, sh, wxCOPY,
true);
338 (c1.Red() + c2.Red())/2,
339 (c1.Green() + c2.Green())/2,
340 (c1.Blue() + c2.Blue())/2);
359 if( (iBrush == -1) && ( iPen ==-1))
361 wxColour col = wxColour(0,0,0);
364 col.Set( col.Red(), col.Green(), col.Blue(), alpha);
379 if( (iBrush == -1) && ( iPen ==-1))
381 wxColour col = wxColour(0,0,0);
384 col.Set( col.Red(), col.Green(), col.Blue(), alpha);
399 int index = (int) selected;
401 dc->SetBrush( brush );
410 int index = (int) selected;
417 UseThemeColour( dc, selected ? clrTrackInfoSelected : clrTrackInfo );
425 int index = (int) selected;
427 dc->SetBrush( brush );
434 UseThemeColour( dc, selected ? clrMediumSelected : clrTrackBackground );
442 dc->SetLogicalFunction(wxCOPY);
450 int index = (int) bIsNotRecording;
473 int index = (int) selected;
475 dc->SetPen(*wxBLACK_PEN);
479 dc->SetPen(*wxTRANSPARENT_PEN);
488 int index = (int) selected;
490 dc->SetPen(*wxBLACK_PEN);
494 dc->SetPen(*wxTRANSPARENT_PEN);
511 return wxColour( 255-c.Red(), 255-c.Green(), 255-c.Blue() );
579 tooltipPen.SetColour( wxSystemSettingsNative::GetColour(wxSYS_COLOUR_INFOTEXT) );
580 tooltipBrush.SetColour( wxSystemSettingsNative::GetColour(wxSYS_COLOUR_INFOBK) );
582 uglyPen.SetColour( wxColour{ 0, 255, 0 } );
583 uglyBrush.SetColour( wxColour{ 255, 0, 255 } );
606 lightPen[1].SetColour(lightSelected);
608 darkPen[1].SetColour(darkSelected);
636 if (channel >= 1 && channel <= 16) {
639 dc->SetPen(wxPen(wxColour(colors[0],
640 colors[1], colors[2]), 1, wxPENSTYLE_SOLID));
641 dc->SetBrush(wxBrush(wxColour(colors[0],
642 colors[1], colors[2]), wxBRUSHSTYLE_SOLID));
644 dc->SetPen(wxPen(wxColour(153, 153, 153), 1, wxPENSTYLE_SOLID));
645 dc->SetBrush(wxBrush(wxColour(153, 153, 153), wxBRUSHSTYLE_SOLID));
652 if (channel >= 1 && channel <= 16) {
655 dc->SetPen(wxPen(wxColour(127 + colors[0] / 2,
657 127 + colors[2] / 2), 1, wxPENSTYLE_SOLID));
658 dc->SetBrush(wxBrush(wxColour(127 + colors[0] / 2,
660 127 + colors[2] / 2), wxBRUSHSTYLE_SOLID));
662 dc->SetPen(wxPen(wxColour(204, 204, 204), 1, wxPENSTYLE_SOLID));
663 dc->SetBrush(wxBrush(wxColour(204, 204, 204), wxBRUSHSTYLE_SOLID));
670 if (channel >= 1 && channel <= 16) {
673 dc->SetPen(wxPen(wxColour(colors[0] / 2,
675 colors[2] / 2), 1, wxPENSTYLE_SOLID));
676 dc->SetBrush(wxBrush(wxColour(colors[0] / 2,
678 colors[2] / 2), wxBRUSHSTYLE_SOLID));
680 dc->SetPen(wxPen(wxColour(102, 102, 102), 1, wxPENSTYLE_SOLID));
681 dc->SetBrush(wxBrush(wxColour(102, 102, 102), wxBRUSHSTYLE_SOLID));
705 const int gsteps = 4;
706 float gradient[gsteps + 1][3];
710 for(
int j=0;j<(gsteps+1);j++){
712 gradient[ j] [0] = c.Red()/255.0;
713 gradient[ j] [1] = c.Green()/255.0;
714 gradient[ j] [2] = c.Blue()/255.0;
722 int left = (int)(value * gsteps);
723 int right = (left == gsteps ? gsteps : left + 1);
725 float rweight = (value * gsteps) - left;
726 float lweight = 1.0 - rweight;
728 r = (gradient[left][0] * lweight) + (gradient[right][0] * rweight);
729 g = (gradient[left][1] * lweight) + (gradient[right][1] * rweight);
730 b = (gradient[left][2] * lweight) + (gradient[right][2] * rweight);
762 gradient_pre[selected][1][i][0] = (
unsigned char) (255 * r);
763 gradient_pre[selected][1][i][1] = (
unsigned char) (255 * g);
764 gradient_pre[selected][1][i][2] = (
unsigned char) (255 * b);
785 r = r * 0.75f + 0.25f;
786 g = g * 0.75f + 0.25f;
787 b = b * 0.75f + 0.25f;
796 gradient_pre[selected][3][i][0] = (
unsigned char)(255 * r);
797 gradient_pre[selected][3][i][1] = (
unsigned char)(255 * g);
798 gradient_pre[selected][3][i][2] = (
unsigned char)(255 * b);
806 r = g = b = 0.84 - 0.84 * value;
834 gradient_pre[selected][2][i][0] = (
unsigned char) (255 * r);
835 gradient_pre[selected][2][i][1] = (
unsigned char) (255 * g);
836 gradient_pre[selected][2][i][2] = (
unsigned char) (255 * b);
wxColour InvertOfColour(const wxColour &c)
const int AColor_midicolors[16][3]
const unsigned char specColormap[256][3]
const unsigned char freqSelColormap[256][3]
const unsigned char selColormap[256][3]
static wxBrush mediumBrush[2]
static void Arrow(wxDC &dc, wxCoord x, wxCoord y, int width, bool down=true)
static wxBrush labelSelectedBrush
static wxBrush darkBrush[2]
static void Solo(wxDC *dc, bool on, bool selected)
static void Bevel2(wxDC &dc, bool up, const wxRect &r, bool bSel=false, bool bHighlight=false)
static wxPen trackFocusPens[3]
static wxPen WideEnvelopePen
static void IndicatorColor(wxDC *dc, bool bIsNotRecording)
static void Mute(wxDC *dc, bool on, bool selected, bool soloing)
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
@ ColorGradientUnselected
@ ColorGradientTimeAndFrequencySelected
@ ColorGradientTimeSelected
static wxColour Blend(const wxColour &c1, const wxColour &c2)
static void PreComputeGradient()
static wxBrush lightBrush[2]
static wxBrush playRegionBrush[1]
static void SnapGuidePen(wxDC *dc)
static void CursorColor(wxDC *dc)
static void Lines(wxDC &dc, size_t nPoints, const wxPoint points[])
static wxPen labelSurroundPen
static void Bevel(wxDC &dc, bool up, const wxRect &r)
static wxBrush muteBrush[2]
static void Light(wxDC *dc, bool selected, bool highlight=false)
static void LightMIDIChannel(wxDC *dc, int channel)
static wxPen mediumPen[2]
static void MediumTrackInfo(wxDC *dc, bool selected)
static void ApplyUpdatedImages()
static wxBrush envelopeBrush
static wxBrush labelTextNormalBrush
static wxBrush labelTextEditBrush
static void DrawFrame(wxDC &dc, const wxRect &r, wxBitmap &bitmap, int mid)
static const int gradientSteps
static void DrawHStretch(wxDC &dc, const wxRect &rect, wxBitmap &bitmap)
static void Dark(wxDC *dc, bool selected, bool highlight=false)
static void Medium(wxDC *dc, bool selected)
static void ButtonStretch(wxDC &dc, bool up, const wxRect &r, bool selected=false, bool highlight=false)
Draw a button that fills a given rect.
static wxBrush labelSyncLockSelBrush
static unsigned char gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3]
static wxBrush tooltipBrush
static void MIDIChannel(wxDC *dc, int channel)
static wxBrush indicatorBrush[2]
static void TrackFocusPen(wxDC *dc, int level)
static void BevelTrackInfo(wxDC &dc, bool up, const wxRect &r, bool highlight=false)
static void TrackPanelBackground(wxDC *dc, bool selected)
static wxBrush labelUnselectedBrush
static wxPen snapGuidePen
static wxPen indicatorPen[2]
static wxBrush spareBrush
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
static void DarkMIDIChannel(wxDC *dc, int channel)
static void DrawFocus(wxDC &dc, wxRect &r)
static bool gradient_inited
static wxPen labelSyncLockSelPen
CallbackReturn Publish(const Message &message)
Send a message to connected callbacks.
wxColour & Colour(int iIndex)
void SetBrushColour(wxBrush &Brush, int iIndex)
wxBitmap & Bitmap(int iIndex)
int ColourDistance(wxColour &From, wxColour &To)
void SetPenColour(wxPen &Pen, int iIndex)
void DrawNinePatch(wxDC &dc, wxBitmap &bitmap, const wxRect &r, int mid=1)
int GetButtonImageIndex(bool up, bool selected, bool highlight)