Audacity  3.0.3
AColor.cpp
Go to the documentation of this file.
1 
2 /**********************************************************************
3 
4  Audacity: A Digital Audio Editor
5 
6  AColor.cpp
7 
8  Dominic Mazzoni
9 
10 
11 ********************************************************************//********************************************************************/
19 
20 
21 #include "AColor.h"
22 #include "AColorResources.h"
23 
24 
25 #include <wx/window.h>
26 #include <wx/colour.h>
27 #include <wx/dc.h>
28 #include <wx/dcmemory.h>
29 #include <wx/graphics.h>
30 #include <wx/settings.h>
31 #include <wx/utils.h>
32 
33 #include "AllThemeResources.h"
34 #include "Theme.h"
35 
36 bool AColor::inited = false;
37 wxBrush AColor::lightBrush[2];
38 wxBrush AColor::mediumBrush[2];
39 wxBrush AColor::darkBrush[2];
40 wxPen AColor::lightPen[2];
41 wxPen AColor::mediumPen[2];
42 wxPen AColor::darkPen[2];
43 
44 wxPen AColor::cursorPen;
45 wxBrush AColor::indicatorBrush[2];
46 wxPen AColor::indicatorPen[2];
47 wxPen AColor::playRegionPen[2];
48 wxBrush AColor::playRegionBrush[2];
49 
50 wxBrush AColor::muteBrush[2];
51 wxBrush AColor::soloBrush;
52 
54 
55 wxBrush AColor::envelopeBrush;
58 
68 wxPen AColor::trackFocusPens[3];
70 
71 wxPen AColor::tooltipPen;
72 wxBrush AColor::tooltipBrush;
73 
74 // The spare pen and brush possibly help us cut down on the
75 // number of pens and brushes we need.
76 wxPen AColor::sparePen;
77 wxBrush AColor::spareBrush;
78 
79 wxPen AColor::uglyPen;
80 wxBrush AColor::uglyBrush;
81 
82 //
83 // Draw an upward or downward pointing arrow.
84 //
85 void AColor::Arrow(wxDC & dc, wxCoord x, wxCoord y, int width, bool down)
86 {
87  if (width & 0x01) {
88  width--;
89  }
90 
91  wxPoint pt[3];
92  int half = width / 2;
93 
94  if (down) {
95  pt[0].x = 0; pt[0].y = 0;
96  pt[1].x = width; pt[1].y = 0;
97  pt[2].x = half; pt[2].y = half;
98  }
99  else {
100  pt[0].x = 0; pt[0].y = half;
101  pt[1].x = half; pt[1].y = 0;
102  pt[2].x = width; pt[2].y = half;
103  }
104 
105  dc.DrawPolygon(3, pt, x, y);
106 }
107 
108 //
109 // Draw a line, inclusive of endpoints,
110 // compensating for differences in wxWidgets versions across platforms
111 //
112 void AColor::Line(wxDC & dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
113 {
114  const wxPoint points[] { { x1, y1 }, { x2, y2 } };
115  Lines( dc, 2, points );
116 }
117 
118 // Draw lines, INCLUSIVE of all endpoints
119 void AColor::Lines(wxDC &dc, size_t nPoints, const wxPoint points[])
120 {
121  if ( nPoints <= 1 ) {
122  if (nPoints == 1)
123  dc.DrawPoint( points[0] );
124  return;
125  }
126 
127  for (size_t ii = 0; ii < nPoints - 1; ++ii) {
128  const auto &p1 = points[ii];
129  const auto &p2 = points[ii + 1];
130 
131  // As of 2.8.9 (possibly earlier), wxDC::DrawLine() on the Mac draws the
132  // last point since it is now based on the NEW wxGraphicsContext system.
133  // Make the other platforms do the same thing since the other platforms
134  // "may" follow they get wxGraphicsContext going.
135 
136  // PRL: as of 3.1.1, I still observe that on Mac, the last point is
137  // included, contrary to what documentation says. Also that on Windows,
138  // sometimes it is the first point that is excluded.
139 
140 #if defined(__WXMAC__) || defined(__WXGTK3__)
141  dc.DrawLine(p1, p2);
142 #else
143  dc.DrawPoint(p1);
144  if ( p1 != p2 ) {
145  dc.DrawLine(p1, p2);
146  }
147 #endif
148  }
149 
150 #if defined(__WXMAC__) || defined(__WXGTK3__)
151  ;
152 #else
153  dc.DrawPoint( points[ nPoints - 1 ] );
154 #endif
155 }
156 
157 //
158 // Draws a focus rectangle (Taken directly from wxWidgets source)
159 //
160 void AColor::DrawFocus(wxDC & dc, wxRect & rect)
161 {
162  // draw the pixels manually: note that to behave in the same manner as
163  // DrawRect(), we must exclude the bottom and right borders from the
164  // rectangle
165  wxCoord x1 = rect.GetLeft(),
166  y1 = rect.GetTop(),
167  x2 = rect.GetRight(),
168  y2 = rect.GetBottom();
169 
170  // -1 for brush, so it just sets the pen colour, and does not change the brush.
171  UseThemeColour( &dc, -1, clrTrackPanelText );
172 
173  wxCoord z;
174  for ( z = x1 + 1; z < x2; z += 2 )
175  dc.DrawPoint(z, y1);
176 
177  wxCoord shift = z == x2 ? 0 : 1;
178  for ( z = y1 + shift; z < y2; z += 2 )
179  dc.DrawPoint(x2, z);
180 
181  shift = z == y2 ? 0 : 1;
182  for ( z = x2 - shift; z > x1; z -= 2 )
183  dc.DrawPoint(z, y2);
184 
185  shift = z == x1 ? 0 : 1;
186  for ( z = y2 - shift; z > y1; z -= 2 )
187  dc.DrawPoint(x1, z);
188 
189 }
190 
191 void AColor::Bevel(wxDC & dc, bool up, const wxRect & r)
192 {
193  if (up)
194  AColor::Light(&dc, false);
195  else
196  AColor::Dark(&dc, false);
197 
198  AColor::Line(dc, r.x, r.y, r.x + r.width, r.y);
199  AColor::Line(dc, r.x, r.y, r.x, r.y + r.height);
200 
201  if (!up)
202  AColor::Light(&dc, false);
203  else
204  AColor::Dark(&dc, false);
205 
206  AColor::Line(dc, r.x + r.width, r.y, r.x + r.width, r.y + r.height);
207  AColor::Line(dc, r.x, r.y + r.height, r.x + r.width, r.y + r.height);
208 }
209 
211 (wxDC & dc, bool up, const wxRect & r, bool bSel, bool bHighlight)
212 {
213  int index = 0;
214  // There are eight button states in the TCP.
215  // A theme might not differentiate between them all. That's up to
216  // the theme designer.
217  // Button highlighted (i.e. hovered over) or not.
218  // Track selected or not
219  // Button up or down.
220  // Highlight in most themes is lighter than not highlighted.
221  if ( bHighlight && bSel)
222  index = up ? bmpHiliteUpButtonExpandSel : bmpHiliteButtonExpandSel;
223  else if ( bHighlight )
224  index = up ? bmpHiliteUpButtonExpand : bmpHiliteButtonExpand;
225  else if( bSel )
226  index = up ? bmpUpButtonExpandSel : bmpDownButtonExpandSel;
227  else
228  index = up ? bmpUpButtonExpand : bmpDownButtonExpand;
229 
230  wxBitmap & Bmp = theTheme.Bitmap( index );
231  wxMemoryDC memDC;
232  memDC.SelectObject(Bmp);
233  int h = wxMin( r.height, Bmp.GetHeight() );
234 
235 
236  dc.Blit( r.x,r.y,r.width/2, h, &memDC, 0, 0, wxCOPY, true );
237  int r2 = r.width - r.width/2;
238  dc.Blit( r.x+r.width/2,r.y,r2, h, &memDC,
239  Bmp.GetWidth() - r2, 0, wxCOPY, true );
240 }
241 
242 wxColour AColor::Blend( const wxColour & c1, const wxColour & c2 )
243 {
244  wxColour c3(
245  (c1.Red() + c2.Red())/2,
246  (c1.Green() + c2.Green())/2,
247  (c1.Blue() + c2.Blue())/2);
248  return c3;
249 }
250 
251 void AColor::BevelTrackInfo(wxDC & dc, bool up, const wxRect & r, bool highlight)
252 {
253 #ifndef EXPERIMENTAL_THEMING
254  Bevel( dc, up, r );
255 #else
256  // Note that the actually drawn rectangle extends one pixel right of and
257  // below the given
258 
259  wxColour col;
260  col = Blend( theTheme.Colour( clrTrackInfo ), up ? wxColour( 255,255,255):wxColour(0,0,0));
261 
262  wxPen pen( highlight ? uglyPen : col );
263  dc.SetPen( pen );
264 
265  dc.DrawLine(r.x, r.y, r.x + r.width, r.y);
266  dc.DrawLine(r.x, r.y, r.x, r.y + r.height);
267 
268  col = Blend( theTheme.Colour( clrTrackInfo ), up ? wxColour(0,0,0): wxColour(255,255,255));
269 
270  pen.SetColour( col );
271  dc.SetPen( highlight ? uglyPen : pen );
272 
273  dc.DrawLine(r.x + r.width, r.y, r.x + r.width, r.y + r.height);
274  dc.DrawLine(r.x, r.y + r.height, r.x + r.width, r.y + r.height);
275 #endif
276 }
277 
278 // Set colour of and select brush and pen.
279 // Use -1 to omit brush or pen.
280 // If pen omitted, then the same colour as the brush will be used.
281 // alpha for the brush is normally 255, but if set will make a difference
282 // on mac (only) currently.
283 void AColor::UseThemeColour( wxDC * dc, int iBrush, int iPen, int alpha )
284 {
285  if (!inited)
286  Init();
287  // do nothing if no colours set.
288  if( (iBrush == -1) && ( iPen ==-1))
289  return;
290  wxColour col = wxColour(0,0,0);
291  if( iBrush !=-1 ){
292  col = theTheme.Colour( iBrush );
293  col.Set( col.Red(), col.Green(), col.Blue(), alpha);
294  spareBrush.SetColour( col );
295  dc->SetBrush( spareBrush );
296  }
297  if( iPen != -1)
298  col = theTheme.Colour( iPen );
299  sparePen.SetColour( col );
300  dc->SetPen( sparePen );
301 }
302 
303 void AColor::UseThemeColour( wxGraphicsContext * gc, int iBrush, int iPen, int alpha )
304 {
305  if (!inited)
306  Init();
307  // do nothing if no colours set.
308  if( (iBrush == -1) && ( iPen ==-1))
309  return;
310  wxColour col = wxColour(0,0,0);
311  if( iBrush !=-1 ){
312  col = theTheme.Colour( iBrush );
313  col.Set( col.Red(), col.Green(), col.Blue(), alpha);
314  spareBrush.SetColour( col );
315  gc->SetBrush( spareBrush );
316  }
317  if( iPen != -1)
318  col = theTheme.Colour( iPen );
319  sparePen.SetColour( col );
320  gc->SetPen( sparePen );
321 }
322 
323 
324 void AColor::Light(wxDC * dc, bool selected, bool highlight)
325 {
326  if (!inited)
327  Init();
328  int index = (int) selected;
329  auto &brush = highlight ? AColor::uglyBrush : lightBrush[index];
330  dc->SetBrush( brush );
331  auto &pen = highlight ? AColor::uglyPen : lightPen[index];
332  dc->SetPen( pen );
333 }
334 
335 void AColor::Medium(wxDC * dc, bool selected)
336 {
337  if (!inited)
338  Init();
339  int index = (int) selected;
340  dc->SetBrush(mediumBrush[index]);
341  dc->SetPen(mediumPen[index]);
342 }
343 
344 void AColor::MediumTrackInfo(wxDC * dc, bool selected)
345 {
346 #ifdef EXPERIMENTAL_THEMING
347  UseThemeColour( dc, selected ? clrTrackInfoSelected : clrTrackInfo );
348 #else
349  Medium( dc, selected );
350 #endif
351 }
352 
353 
354 void AColor::Dark(wxDC * dc, bool selected, bool highlight)
355 {
356  if (!inited)
357  Init();
358  int index = (int) selected;
359  auto &brush = highlight ? AColor::uglyBrush : darkBrush[index];
360  dc->SetBrush( brush );
361  auto &pen = highlight ? AColor::uglyPen : darkPen[index];
362  dc->SetPen( pen );
363 }
364 
365 void AColor::TrackPanelBackground(wxDC * dc, bool selected)
366 {
367 #ifdef EXPERIMENTAL_THEMING
368  UseThemeColour( dc, selected ? clrMediumSelected : clrTrackBackground );
369 #else
370  Dark( dc, selected );
371 #endif
372 }
373 
374 void AColor::CursorColor(wxDC * dc)
375 {
376  if (!inited)
377  Init();
378 
379  dc->SetLogicalFunction(wxCOPY);
380  dc->SetPen(cursorPen);
381 }
382 
383 void AColor::IndicatorColor(wxDC * dc, bool bIsNotRecording)
384 {
385  if (!inited)
386  Init();
387  int index = (int) bIsNotRecording;
388  dc->SetPen(indicatorPen[index]);
389  dc->SetBrush(indicatorBrush[index]);
390 }
391 
392 void AColor::PlayRegionColor(wxDC * dc, bool locked)
393 {
394  if (!inited)
395  Init();
396  dc->SetPen(playRegionPen[(int)locked]);
397  dc->SetBrush(playRegionBrush[(int)locked]);
398 }
399 
400 void AColor::TrackFocusPen(wxDC * dc, int level)
401 {
402  if (!inited)
403  Init();
404  dc->SetPen(trackFocusPens[level]);
405 }
406 
407 void AColor::SnapGuidePen(wxDC * dc)
408 {
409  if (!inited)
410  Init();
411  dc->SetPen(snapGuidePen);
412 }
413 
414 void AColor::Mute(wxDC * dc, bool on, bool selected, bool soloing)
415 {
416  if (!inited)
417  Init();
418  int index = (int) selected;
419  if (on) {
420  dc->SetPen(*wxBLACK_PEN);
421  dc->SetBrush(muteBrush[(int) soloing]);
422  }
423  else {
424  dc->SetPen(*wxTRANSPARENT_PEN);
425  dc->SetBrush(mediumBrush[index]);
426  }
427 }
428 
429 void AColor::Solo(wxDC * dc, bool on, bool selected)
430 {
431  if (!inited)
432  Init();
433  int index = (int) selected;
434  if (on) {
435  dc->SetPen(*wxBLACK_PEN);
436  dc->SetBrush(soloBrush);
437  }
438  else {
439  dc->SetPen(*wxTRANSPARENT_PEN);
440  dc->SetBrush(mediumBrush[index]);
441  }
442 }
443 
444 bool AColor::gradient_inited = 0;
445 
447 {
448  inited=false;
449  Init();
450  gradient_inited=0;
452 }
453 
454 wxColour InvertOfColour( const wxColour & c )
455 {
456  return wxColour( 255-c.Red(), 255-c.Green(), 255-c.Blue() );
457 }
458 
459 // Fix up the cursor colour, if it is 'unacceptable'.
460 // Unacceptable if it is too close to the background colour.
461 wxColour CursorColour( )
462 {
463  wxColour cCursor = theTheme.Colour( clrCursorPen );
464  wxColour cBack = theTheme.Colour( clrMedium );
465 
466  int d = theTheme.ColourDistance( cCursor, cBack );
467 
468  // Pen colour is fine, if there is plenty of contrast.
469  if( d > 200 )
470  return clrCursorPen;
471 
472  // otherwise return same colour as a selection.
473  return theTheme.Colour( clrSelected );
474 }
475 
477 {
478  if (inited)
479  return;
480 
481  wxColour light = theTheme.Colour( clrLight );
482  // wxSystemSettings::GetColour(wxSYS_COLOUR_3DHIGHLIGHT);
483  wxColour med = theTheme.Colour( clrMedium );
484  // wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
485  wxColour dark = theTheme.Colour( clrDark );
486  // wxSystemSettings::GetColour(wxSYS_COLOUR_3DSHADOW);
487 
488  wxColour lightSelected = theTheme.Colour( clrLightSelected );
489  wxColour medSelected = theTheme.Colour( clrMediumSelected );
490  wxColour darkSelected = theTheme.Colour( clrDarkSelected );
491 
492 
493  clippingPen.SetColour(0xCC, 0x11, 0x00);
494 
495  theTheme.SetPenColour( envelopePen, clrEnvelope );
496  theTheme.SetPenColour( WideEnvelopePen, clrEnvelope );
497  theTheme.SetBrushColour( envelopeBrush, clrEnvelope );
498 
499  WideEnvelopePen.SetWidth( 3 );
500 
501  theTheme.SetBrushColour( labelTextNormalBrush, clrLabelTextNormalBrush );
502  theTheme.SetBrushColour( labelTextEditBrush, clrLabelTextEditBrush );
503  theTheme.SetBrushColour( labelUnselectedBrush, clrLabelUnselectedBrush );
504  theTheme.SetBrushColour( labelSelectedBrush, clrLabelSelectedBrush );
505  theTheme.SetBrushColour( labelSyncLockSelBrush, clrSyncLockSel );
506  theTheme.SetPenColour( labelUnselectedPen, clrLabelUnselectedPen );
507  theTheme.SetPenColour( labelSelectedPen, clrLabelSelectedPen );
508  theTheme.SetPenColour( labelSyncLockSelPen, clrSyncLockSel );
509  theTheme.SetPenColour( labelSurroundPen, clrLabelSurroundPen );
510 
511  // These colors were modified to avoid using reserved colors red and green
512  // for the buttons.
513  theTheme.SetBrushColour( muteBrush[0], clrMuteButtonActive);
514  theTheme.SetBrushColour( muteBrush[1], clrMuteButtonVetoed);
515  theTheme.SetBrushColour( soloBrush, clrMuteButtonActive);
516 
517  cursorPen.SetColour( CursorColour() );
518  theTheme.SetPenColour( indicatorPen[0], clrRecordingPen);
519  theTheme.SetPenColour( indicatorPen[1], clrPlaybackPen);
520  theTheme.SetBrushColour( indicatorBrush[0], clrRecordingBrush);
521  theTheme.SetBrushColour( indicatorBrush[1], clrPlaybackBrush);
522 
523  theTheme.SetBrushColour( playRegionBrush[0],clrRulerRecordingBrush);
524  theTheme.SetPenColour( playRegionPen[0], clrRulerRecordingPen);
525  theTheme.SetBrushColour( playRegionBrush[1],clrRulerPlaybackBrush);
526  theTheme.SetPenColour( playRegionPen[1], clrRulerPlaybackPen);
527 
528  //Determine tooltip color
529  tooltipPen.SetColour( wxSystemSettingsNative::GetColour(wxSYS_COLOUR_INFOTEXT) );
530  tooltipBrush.SetColour( wxSystemSettingsNative::GetColour(wxSYS_COLOUR_INFOBK) );
531 
532  uglyPen.SetColour( wxColour{ 0, 255, 0 } ); // saturated green
533  uglyBrush.SetColour( wxColour{ 255, 0, 255 } ); // saturated magenta
534 
535  // A tiny gradient of yellow surrounding the current focused track
536  theTheme.SetPenColour( trackFocusPens[0], clrTrackFocus0);
537  theTheme.SetPenColour( trackFocusPens[1], clrTrackFocus1);
538  theTheme.SetPenColour( trackFocusPens[2], clrTrackFocus2);
539 
540  // A vertical line indicating that the selection or sliding has
541  // been snapped to the nearest boundary.
542  theTheme.SetPenColour( snapGuidePen, clrSnapGuide);
543 
544  // unselected
545  lightBrush[0].SetColour(light);
546  mediumBrush[0].SetColour(med);
547  darkBrush[0].SetColour(dark);
548  lightPen[0].SetColour(light);
549  mediumPen[0].SetColour(med);
550  darkPen[0].SetColour(dark);
551 
552  // selected
553  lightBrush[1].SetColour(lightSelected);
554  mediumBrush[1].SetColour(medSelected);
555  darkBrush[1].SetColour(darkSelected);
556  lightPen[1].SetColour(lightSelected);
557  mediumPen[1].SetColour(medSelected);
558  darkPen[1].SetColour(darkSelected);
559 
560  inited = true;
561 }
562 
563 // These colours are chosen so that black text shows up OK on them.
564 const int AColor_midicolors[16][3] = {
565  {255, 102, 102}, // 1=salmon
566  {204, 0, 0}, // 2=red
567  {255, 117, 23}, // 3=orange
568  {255, 255, 0}, // 4=yellow
569  {0, 204, 0}, // 5=green
570  {0, 204, 204}, // 6=turquoise
571  {125, 125, 255}, // 7=blue
572  {153, 0, 255}, // 8=blue-violet
573 
574  {140, 97, 54}, // 9=brown
575  {120, 120, 120}, // 10=gray (drums)
576  {255, 175, 40}, // 11=lt orange
577  {102, 255, 102}, // 12=lt green
578  {153, 255, 255}, // 13=lt turquoise
579  {190, 190, 255}, // 14=lt blue
580  {204, 102, 255}, // 15=lt blue-violet
581  {255, 51, 204} // 16=lt red-violet
582 };
583 
584 void AColor::MIDIChannel(wxDC * dc, int channel /* 1 - 16 */ )
585 {
586  if (channel >= 1 && channel <= 16) {
587  const int *colors = AColor_midicolors[channel - 1];
588 
589  dc->SetPen(wxPen(wxColour(colors[0],
590  colors[1], colors[2]), 1, wxPENSTYLE_SOLID));
591  dc->SetBrush(wxBrush(wxColour(colors[0],
592  colors[1], colors[2]), wxBRUSHSTYLE_SOLID));
593  } else {
594  dc->SetPen(wxPen(wxColour(153, 153, 153), 1, wxPENSTYLE_SOLID));
595  dc->SetBrush(wxBrush(wxColour(153, 153, 153), wxBRUSHSTYLE_SOLID));
596  }
597 
598 }
599 
600 void AColor::LightMIDIChannel(wxDC * dc, int channel /* 1 - 16 */ )
601 {
602  if (channel >= 1 && channel <= 16) {
603  const int *colors = AColor_midicolors[channel - 1];
604 
605  dc->SetPen(wxPen(wxColour(127 + colors[0] / 2,
606  127 + colors[1] / 2,
607  127 + colors[2] / 2), 1, wxPENSTYLE_SOLID));
608  dc->SetBrush(wxBrush(wxColour(127 + colors[0] / 2,
609  127 + colors[1] / 2,
610  127 + colors[2] / 2), wxBRUSHSTYLE_SOLID));
611  } else {
612  dc->SetPen(wxPen(wxColour(204, 204, 204), 1, wxPENSTYLE_SOLID));
613  dc->SetBrush(wxBrush(wxColour(204, 204, 204), wxBRUSHSTYLE_SOLID));
614  }
615 
616 }
617 
618 void AColor::DarkMIDIChannel(wxDC * dc, int channel /* 1 - 16 */ )
619 {
620  if (channel >= 1 && channel <= 16) {
621  const int *colors = AColor_midicolors[channel - 1];
622 
623  dc->SetPen(wxPen(wxColour(colors[0] / 2,
624  colors[1] / 2,
625  colors[2] / 2), 1, wxPENSTYLE_SOLID));
626  dc->SetBrush(wxBrush(wxColour(colors[0] / 2,
627  colors[1] / 2,
628  colors[2] / 2), wxBRUSHSTYLE_SOLID));
629  } else {
630  dc->SetPen(wxPen(wxColour(102, 102, 102), 1, wxPENSTYLE_SOLID));
631  dc->SetBrush(wxBrush(wxColour(102, 102, 102), wxBRUSHSTYLE_SOLID));
632  }
633 
634 }
635 
636 
637 
638 unsigned char AColor::gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3];
639 
641  if (gradient_inited) return;
642  gradient_inited = 1;
643 
644  // Keep in correspondence with enum SpectrogramSettings::ColorScheme
645 
646  // colorScheme 0: Color (New)
647  std::copy_n(&specColormap[0][0], gradientSteps * 3, &gradient_pre[ColorGradientUnselected][0][0][0]);
648  std::copy_n(&selColormap[0][0], gradientSteps * 3, &gradient_pre[ColorGradientTimeSelected][0][0][0]);
650  std::fill_n(&gradient_pre[ColorGradientEdge][0][0][0], gradientSteps * 3, 0);
651 
652 
653  for (int selected = 0; selected < ColorGradientTotal; selected++) {
654  // Get color scheme from Theme
655  const int gsteps = 4;
656  float gradient[gsteps + 1][3];
657  theTheme.Colour( clrSpectro1 ) = theTheme.Colour( clrUnselected );
658  theTheme.Colour( clrSpectro1Sel ) = theTheme.Colour( clrSelected );
659  int clrFirst = (selected == ColorGradientUnselected ) ? clrSpectro1 : clrSpectro1Sel;
660  for(int j=0;j<(gsteps+1);j++){
661  wxColour c = theTheme.Colour( clrFirst+j );
662  gradient[ j] [0] = c.Red()/255.0;
663  gradient[ j] [1] = c.Green()/255.0;
664  gradient[ j] [2] = c.Blue()/255.0;
665  }
666 
667  // colorScheme 1: Color (from theme)
668  for (int i = 0; i<gradientSteps; i++) {
669  float r, g, b;
670  float value = float(i)/gradientSteps;
671 
672  int left = (int)(value * gsteps);
673  int right = (left == gsteps ? gsteps : left + 1);
674 
675  float rweight = (value * gsteps) - left;
676  float lweight = 1.0 - rweight;
677 
678  r = (gradient[left][0] * lweight) + (gradient[right][0] * rweight);
679  g = (gradient[left][1] * lweight) + (gradient[right][1] * rweight);
680  b = (gradient[left][2] * lweight) + (gradient[right][2] * rweight);
681 
682  switch (selected) {
684  // not dimmed
685  break;
686 
688  float temp;
689  temp = r;
690  r = g;
691  g = b;
692  b = temp;
693  break;
694 
696  // partly dimmed
697  r *= 0.75f;
698  g *= 0.75f;
699  b *= 0.75f;
700  break;
701 
702 
703  // For now edge colour is just black (or white if grey-scale)
704  // Later we might invert or something else funky.
705  case ColorGradientEdge:
706  // fully dimmed
707  r = 0;
708  g = 0;
709  b = 0;
710  break;
711  }
712  gradient_pre[selected][1][i][0] = (unsigned char) (255 * r);
713  gradient_pre[selected][1][i][1] = (unsigned char) (255 * g);
714  gradient_pre[selected][1][i][2] = (unsigned char) (255 * b);
715  }
716 
717  // colorScheme 3: Inverse Grayscale
718  for (int i = 0; i < gradientSteps; i++) {
719  float r, g, b;
720  float value = float(i) / gradientSteps;
721 
722  r = g = b = value;
723 
724  switch (selected) {
726  // not dimmed
727  break;
728 
730  // else fall through to SAME grayscale colour as normal selection.
731  // The white lines show it up clearly enough.
732 
734  // partly dimmed
735  r = r * 0.75f + 0.25f;
736  g = g * 0.75f + 0.25f;
737  b = b * 0.75f + 0.25f;
738  break;
739 
740  case ColorGradientEdge:
741  r = 1.0f;
742  g = 1.0f;
743  b = 1.0f;
744  break;
745  }
746  gradient_pre[selected][3][i][0] = (unsigned char)(255 * r);
747  gradient_pre[selected][3][i][1] = (unsigned char)(255 * g);
748  gradient_pre[selected][3][i][2] = (unsigned char)(255 * b);
749  }
750 
751  // colorScheme 2: Grayscale (=Old grayscale)
752  for (int i = 0; i<gradientSteps; i++) {
753  float r, g, b;
754  float value = float(i)/gradientSteps;
755 
756  r = g = b = 0.84 - 0.84 * value;
757 
758  switch (selected) {
760  // not dimmed
761  break;
762 
764  // else fall through to SAME grayscale colour as normal selection.
765  // The white lines show it up clearly enough.
766 
768  // partly dimmed
769  r *= 0.75f;
770  g *= 0.75f;
771  b *= 0.75f;
772  break;
773 
774 
775  // For now edge colour is just black (or white if grey-scale)
776  // Later we might invert or something else funky.
777  case ColorGradientEdge:
778  // fully dimmed
779  r = 1.0f;
780  g = 1.0f;
781  b = 1.0f;
782  break;
783  }
784  gradient_pre[selected][2][i][0] = (unsigned char) (255 * r);
785  gradient_pre[selected][2][i][1] = (unsigned char) (255 * g);
786  gradient_pre[selected][2][i][2] = (unsigned char) (255 * b);
787  }
788  }
789 }
freqSelColormap
const unsigned char freqSelColormap[256][3]
Definition: AColorResources.h:532
AColor::labelUnselectedPen
static wxPen labelUnselectedPen
Definition: AColor.h:114
AColorResources.h
AColor::UseThemeColour
static void UseThemeColour(wxDC *dc, int iBrush, int iPen=-1, int alpha=255)
Definition: AColor.cpp:283
AColor::TrackPanelBackground
static void TrackPanelBackground(wxDC *dc, bool selected)
Definition: AColor.cpp:365
AColor::CursorColor
static void CursorColor(wxDC *dc)
Definition: AColor.cpp:374
AColor::labelUnselectedBrush
static wxBrush labelUnselectedBrush
Definition: AColor.h:111
AColor::ReInit
static void ReInit()
Definition: AColor.cpp:446
selColormap
const unsigned char selColormap[256][3]
Definition: AColorResources.h:273
AColor::trackFocusPens
static wxPen trackFocusPens[3]
Definition: AColor.h:119
AColor::ColorGradientTotal
@ ColorGradientTotal
Definition: AColor.h:34
ThemeBase::ColourDistance
int ColourDistance(wxColour &From, wxColour &To)
Definition: Theme.cpp:339
AllThemeResources.h
CursorColour
wxColour CursorColour()
Definition: AColor.cpp:461
AColor::ColorGradientTimeSelected
@ ColorGradientTimeSelected
Definition: AColor.h:30
AColor::mediumPen
static wxPen mediumPen[2]
Definition: AColor.h:91
AColor::IndicatorColor
static void IndicatorColor(wxDC *dc, bool bIsNotRecording)
Definition: AColor.cpp:383
AColor::Bevel2
static void Bevel2(wxDC &dc, bool up, const wxRect &r, bool bSel=false, bool bHighlight=false)
Definition: AColor.cpp:211
AColor::labelSelectedPen
static wxPen labelSelectedPen
Definition: AColor.h:115
AColor::mediumBrush
static wxBrush mediumBrush[2]
Definition: AColor.h:88
AColor::Line
static void Line(wxDC &dc, wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
Definition: AColor.cpp:112
AColor::Mute
static void Mute(wxDC *dc, bool on, bool selected, bool soloing)
Definition: AColor.cpp:414
AColor::playRegionPen
static wxPen playRegionPen[2]
Definition: AColor.h:97
AColor::Lines
static void Lines(wxDC &dc, size_t nPoints, const wxPoint points[])
Definition: AColor.cpp:119
AColor::TrackFocusPen
static void TrackFocusPen(wxDC *dc, int level)
Definition: AColor.cpp:400
AColor::uglyBrush
static wxBrush uglyBrush
Definition: AColor.h:132
AColor::labelSyncLockSelBrush
static wxBrush labelSyncLockSelBrush
Definition: AColor.h:113
AColor::lightPen
static wxPen lightPen[2]
Definition: AColor.h:90
AColor::BevelTrackInfo
static void BevelTrackInfo(wxDC &dc, bool up, const wxRect &r, bool highlight=false)
Definition: AColor.cpp:251
AColor::MIDIChannel
static void MIDIChannel(wxDC *dc, int channel)
Definition: AColor.cpp:584
AColor::darkBrush
static wxBrush darkBrush[2]
Definition: AColor.h:89
AColor::indicatorBrush
static wxBrush indicatorBrush[2]
Definition: AColor.h:96
AColor::envelopePen
static wxPen envelopePen
Definition: AColor.h:105
AColor::snapGuidePen
static wxPen snapGuidePen
Definition: AColor.h:120
AColor::PreComputeGradient
static void PreComputeGradient()
Definition: AColor.cpp:640
ThemeBase::Bitmap
wxBitmap & Bitmap(int iIndex)
Definition: Theme.cpp:1216
AColor::sparePen
static wxPen sparePen
Definition: AColor.h:135
AColor::labelTextEditBrush
static wxBrush labelTextEditBrush
Definition: AColor.h:110
AColor::Solo
static void Solo(wxDC *dc, bool on, bool selected)
Definition: AColor.cpp:429
AColor::tooltipBrush
static wxBrush tooltipBrush
Definition: AColor.h:123
AColor::DarkMIDIChannel
static void DarkMIDIChannel(wxDC *dc, int channel)
Definition: AColor.cpp:618
AColor::lightBrush
static wxBrush lightBrush[2]
Definition: AColor.h:87
AColor::PlayRegionColor
static void PlayRegionColor(wxDC *dc, bool locked)
Definition: AColor.cpp:392
AColor::LightMIDIChannel
static void LightMIDIChannel(wxDC *dc, int channel)
Definition: AColor.cpp:600
InvertOfColour
wxColour InvertOfColour(const wxColour &c)
Definition: AColor.cpp:454
AColor::inited
static bool inited
Definition: AColor.h:137
AColor::tooltipPen
static wxPen tooltipPen
Definition: AColor.h:122
AColor::Light
static void Light(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:324
AColor::WideEnvelopePen
static wxPen WideEnvelopePen
Definition: AColor.h:106
Theme.h
AColor::labelSelectedBrush
static wxBrush labelSelectedBrush
Definition: AColor.h:112
AColor::SnapGuidePen
static void SnapGuidePen(wxDC *dc)
Definition: AColor.cpp:407
ThemeBase::SetBrushColour
void SetBrushColour(wxBrush &Brush, int iIndex)
Definition: Theme.cpp:1204
AColor::indicatorPen
static wxPen indicatorPen[2]
Definition: AColor.h:95
AColor::gradientSteps
static const int gradientSteps
Definition: AColor.h:127
AColor::Arrow
static void Arrow(wxDC &dc, wxCoord x, wxCoord y, int width, bool down=true)
Definition: AColor.cpp:85
AColor::uglyPen
static wxPen uglyPen
Definition: AColor.h:131
AColor::Medium
static void Medium(wxDC *dc, bool selected)
Definition: AColor.cpp:335
AColor::DrawFocus
static void DrawFocus(wxDC &dc, wxRect &r)
Definition: AColor.cpp:160
AColor::clippingPen
static wxPen clippingPen
Definition: AColor.h:103
AColor::MediumTrackInfo
static void MediumTrackInfo(wxDC *dc, bool selected)
Definition: AColor.cpp:344
AColor::ColorGradientUnselected
@ ColorGradientUnselected
Definition: AColor.h:29
AColor::cursorPen
static wxPen cursorPen
Definition: AColor.h:94
AColor::Bevel
static void Bevel(wxDC &dc, bool up, const wxRect &r)
Definition: AColor.cpp:191
AColor::spareBrush
static wxBrush spareBrush
Definition: AColor.h:136
AColor::Init
static void Init()
Definition: AColor.cpp:476
AColor::muteBrush
static wxBrush muteBrush[2]
Definition: AColor.h:100
AColor::Dark
static void Dark(wxDC *dc, bool selected, bool highlight=false)
Definition: AColor.cpp:354
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::darkPen
static wxPen darkPen[2]
Definition: AColor.h:92
AColor_midicolors
const int AColor_midicolors[16][3]
Definition: AColor.cpp:564
ThemeBase::Colour
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1197
AColor::gradient_pre
static unsigned char gradient_pre[ColorGradientTotal][colorSchemes][gradientSteps][3]
Definition: AColor.h:128
AColor::ColorGradientTimeAndFrequencySelected
@ ColorGradientTimeAndFrequencySelected
Definition: AColor.h:31
theTheme
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:203
AColor::gradient_inited
static bool gradient_inited
Definition: AColor.h:125
AColor::playRegionBrush
static wxBrush playRegionBrush[2]
Definition: AColor.h:98
AColor.h
AColor::envelopeBrush
static wxBrush envelopeBrush
Definition: AColor.h:107
ThemeBase::SetPenColour
void SetPenColour(wxPen &Pen, int iIndex)
Definition: Theme.cpp:1210
AColor::Blend
static wxColour Blend(const wxColour &c1, const wxColour &c2)
Definition: AColor.cpp:242
AColor::labelSurroundPen
static wxPen labelSurroundPen
Definition: AColor.h:117
specColormap
const unsigned char specColormap[256][3]
Definition: AColorResources.h:14
AColor::ColorGradientEdge
@ ColorGradientEdge
Definition: AColor.h:32