summaryrefslogtreecommitdiff
path: root/gtk2_ardour/ui_config.cc
blob: cafbd14e184590a955c558e1187254ec4d57a20a (plain)
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
/*
    Copyright (C) 1999-2014 Paul Davis

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

*/

#include <unistd.h>
#include <cstdlib>
#include <cstdio> /* for snprintf, grrr */

#include <glibmm/miscutils.h>

#include "pbd/failed_constructor.h"
#include "pbd/xml++.h"
#include "pbd/file_utils.h"
#include "pbd/error.h"
#include "pbd/stacktrace.h"

#include "gtkmm2ext/rgb_macros.h"

#include "ardour/filesystem_paths.h"

#include "ardour_ui.h"
#include "global_signals.h"
#include "ui_config.h"

#include "i18n.h"

using namespace std;
using namespace PBD;
using namespace ARDOUR;
using namespace ArdourCanvas;

static const char* ui_config_file_name = "ui_config";
static const char* default_ui_config_file_name = "default_ui_config";
UIConfiguration* UIConfiguration::_instance = 0;

static const double hue_width = 18.0;

UIConfiguration::UIConfiguration ()
	:
#undef  UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,val) var (name,val),
#define CANVAS_STRING_VARIABLE(var,name) var (name),
#define CANVAS_FONT_VARIABLE(var,name) var (name),
#include "ui_config_vars.h"
#include "canvas_vars.h"
#undef  UI_CONFIG_VARIABLE
#undef  CANVAS_STRING_VARIABLE
#undef  CANVAS_FONT_VARIABLE

	/* initialize all the base colors using default
	   colors for now. these will be reset when/if
	   we load the UI config file.
	*/

#undef CANVAS_BASE_COLOR
#define CANVAS_BASE_COLOR(var,name,val) var (name,quantized (val)),
#include "base_colors.h"
#undef CANVAS_BASE_COLOR

	_dirty (false)
{
	_instance = this;

	/* pack all base colors into the configurable color map so that
	   derived colors can use them.
	*/
	  
#undef CANVAS_BASE_COLOR
#define CANVAS_BASE_COLOR(var,name,color) configurable_colors.insert (make_pair (name,&var));
#include "base_colors.h"
#undef CANVAS_BASE_COLOR

#undef CANVAS_COLOR
#define CANVAS_COLOR(var,name,base,modifier) relative_colors.insert (make_pair (name, RelativeHSV (base,modifier)));
#include "colors.h"
#undef CANVAS_COLOR
	
#undef COLOR_ALIAS
#define COLOR_ALIAS(var,name,alias) color_aliases.insert (make_pair (name,alias));
#include "color_aliases.h"
#undef CANVAS_COLOR

	load_state();

	// regenerate_relative_definitions ();
	// color_compute ();

	ARDOUR_UI_UTILS::ColorsChanged.connect (boost::bind (&UIConfiguration::color_theme_changed, this));
}

UIConfiguration::~UIConfiguration ()
{
}

Color
UIConfiguration::quantized (Color c)
{
	HSV hsv (c);
	hsv.h = hue_width * (round (hsv.h/hue_width));
	return hsv.color ();
}

void
UIConfiguration::print_relative_def (string camelcase, string name, Color c)
{
	HSV variable (c);
	HSV closest;
	double shortest_distance = DBL_MAX;
	string closest_name;

	map<string,ColorVariable<Color>*>::iterator f;
	std::map<std::string,HSV> palette;

	for (f = configurable_colors.begin(); f != configurable_colors.end(); ++f) {
		palette.insert (make_pair (f->first, HSV (f->second->get())));
	}

	for (map<string,HSV>::iterator f = palette.begin(); f != palette.end(); ++f) {
		
		double d;
		HSV fixed (f->second);
		
		if (fixed.is_gray() || variable.is_gray()) {
			/* at least one is achromatic; HSV::distance() will do
			 * the right thing
			 */
			d = fixed.distance (variable);
		} else {
			/* chromatic: compare ONLY hue because our task is
			   to pick the HUE closest and then compute
			   a modifier. We want to keep the number of 
			   hues low, and by computing perceptual distance 
			   we end up finding colors that are to each
			   other without necessarily be close in hue.
			*/
			d = fabs (variable.h - fixed.h);
		}

		if (d < shortest_distance) {
			closest = fixed;
			closest_name = f->first;
			shortest_distance = d;
		}
	}
	
	/* we now know the closest color of the fixed colors to 
	   this variable color. Compute the HSV diff and
	   use it to redefine the variable color in terms of the
	   fixed one.
	*/
	
	HSV delta = variable.delta (closest);

	/* quantize hue delta so we don't end up with many subtle hues caused
	 * by original color choices
	 */

	delta.h = hue_width * (round (delta.h/hue_width));

	cerr << "CANVAS_COLOR(" << camelcase << ",\"" << name << "\", \"" << closest_name <<  "\", HSV(" 
	     << delta.h << ',' << delta.s << ',' << delta.v << ',' << variable.a << ")) /*" 
	     << shortest_distance << " */" << endl;
}

void 
UIConfiguration::regenerate_relative_definitions ()
{
	/* this takes the color definitions from around ardour 3.5.3600,
	   quantizes their hues, then prints out macros to be used
	   when defining these colors relative to the current
	   base palette. It doesn't need to be called unless
	   we change the base palette defaults.
	*/
	
	map<string,HSV> c;
        c.insert (make_pair ("active crossfade", HSV (0x20b2af2e)));
        c.insert (make_pair ("arrange base", HSV (0x595959ff)));
        c.insert (make_pair ("audio bus base", HSV (0x73829968)));
        c.insert (make_pair ("audio master bus base", HSV (0x00000000)));
        c.insert (make_pair ("audio track base", HSV (0x9daac468)));
        c.insert (make_pair ("automation line", HSV (0x44bc59ff)));
        c.insert (make_pair ("automation track fill", HSV (0xa0a0ce68)));
        c.insert (make_pair ("automation track outline", HSV (0x282828ff)));
        c.insert (make_pair ("cd marker bar", HSV (0x9496a3cc)));
        c.insert (make_pair ("crossfade editor base", HSV (0x282d49ff)));
        c.insert (make_pair ("crossfade editor line", HSV (0x000000ff)));
        c.insert (make_pair ("crossfade editor line shading", HSV (0x00a0d154)));
        c.insert (make_pair ("crossfade editor point fill", HSV (0x00ff00ff)));
        c.insert (make_pair ("crossfade editor point outline", HSV (0x0000ffff)));
        c.insert (make_pair ("crossfade editor wave", HSV (0xffffff28)));
        c.insert (make_pair ("selected crossfade editor wave fill", HSV (0x00000000)));
        c.insert (make_pair ("crossfade line", HSV (0x000000ff)));
        c.insert (make_pair ("edit point", HSV (0x0000ffff)));
        c.insert (make_pair ("entered automation line", HSV (0xdd6363ff)));
        c.insert (make_pair ("control point fill", HSV (0xffffff66)));
        c.insert (make_pair ("control point outline", HSV (0xff0000ee)));
        c.insert (make_pair ("control point selected", HSV (0x55ccccff)));
        c.insert (make_pair ("entered gain line", HSV (0xdd6363ff)));
        c.insert (make_pair ("entered marker", HSV (0xdd6363ff)));
        c.insert (make_pair ("frame handle", HSV (0x7c00ff96)));
        c.insert (make_pair ("gain line", HSV (0x00bc20ff)));
        c.insert (make_pair ("gain line inactive", HSV (0x9fbca4c5)));
        c.insert (make_pair ("ghost track base", HSV (0x603e7cc6)));
        c.insert (make_pair ("ghost track midi outline", HSV (0x00000000)));
        c.insert (make_pair ("ghost track wave", HSV (0x202020d9)));
        c.insert (make_pair ("ghost track wave fill", HSV (0x20202060)));
        c.insert (make_pair ("ghost track wave clip", HSV (0x202020d9)));
        c.insert (make_pair ("ghost track zero line", HSV (0xe500e566)));
        c.insert (make_pair ("image track", HSV (0xddddd8ff)));
        c.insert (make_pair ("inactive crossfade", HSV (0xe8ed3d77)));
        c.insert (make_pair ("inactive fade handle", HSV (0xbbbbbbaa)));
        c.insert (make_pair ("inactive group tab", HSV (0x434343ff)));
        c.insert (make_pair ("location cd marker", HSV (0x1ee8c4ff)));
        c.insert (make_pair ("location loop", HSV (0x35964fff)));
        c.insert (make_pair ("location marker", HSV (0xc4f411ff)));
        c.insert (make_pair ("location punch", HSV (0x7c3a3aff)));
        c.insert (make_pair ("location range", HSV (0x497a59ff)));
        c.insert (make_pair ("marker bar", HSV (0x99a1adcc)));
        c.insert (make_pair ("marker bar separator", HSV (0x555555ff)));
        c.insert (make_pair ("marker drag line", HSV (0x004f00f9)));
        c.insert (make_pair ("marker label", HSV (0x000000ff)));
        c.insert (make_pair ("marker track", HSV (0xddddd8ff)));
        c.insert (make_pair ("measure line bar", HSV (0xffffff9c)));
        c.insert (make_pair ("measure line beat", HSV (0xa29e9e76)));
        c.insert (make_pair ("meter bar", HSV (0x626470cc)));
        c.insert (make_pair ("meter fill: 0", HSV (0x008800ff)));
        c.insert (make_pair ("meter fill: 1", HSV (0x00aa00ff)));
        c.insert (make_pair ("meter fill: 2", HSV (0x00ff00ff)));
        c.insert (make_pair ("meter fill: 3", HSV (0x00ff00ff)));
        c.insert (make_pair ("meter fill: 4", HSV (0xfff000ff)));
        c.insert (make_pair ("meter fill: 5", HSV (0xfff000ff)));
        c.insert (make_pair ("meter fill: 6", HSV (0xff8000ff)));
        c.insert (make_pair ("meter fill: 7", HSV (0xff8000ff)));
        c.insert (make_pair ("meter fill: 8", HSV (0xff0000ff)));
        c.insert (make_pair ("meter fill: 9", HSV (0xff0000ff)));
        c.insert (make_pair ("meter background: bottom", HSV (0x333333ff)));
        c.insert (make_pair ("meter background: top", HSV (0x444444ff)));
        c.insert (make_pair ("midi meter fill: 0", HSV (0xeffaa1ff)));
        c.insert (make_pair ("midi meter fill: 1", HSV (0xf2c97dff)));
        c.insert (make_pair ("midi meter fill: 2", HSV (0xf2c97dff)));
        c.insert (make_pair ("midi meter fill: 3", HSV (0xf48f52ff)));
        c.insert (make_pair ("midi meter fill: 4", HSV (0xf48f52ff)));
        c.insert (make_pair ("midi meter fill: 5", HSV (0xf83913ff)));
        c.insert (make_pair ("midi meter fill: 6", HSV (0xf83913ff)));
        c.insert (make_pair ("midi meter fill: 7", HSV (0x8fc78eff)));
        c.insert (make_pair ("midi meter fill: 8", HSV (0x8fc78eff)));
        c.insert (make_pair ("midi meter fill: 9", HSV (0x00f45600)));
        c.insert (make_pair ("meterbridge peakindicator: fill", HSV (0x444444ff)));
        c.insert (make_pair ("meterbridge peakindicator: fill active", HSV (0xff0000ff)));
        c.insert (make_pair ("meterbridge label: fill", HSV (0x444444ff)));
        c.insert (make_pair ("meterbridge label: fill active", HSV (0x333333ff)));
        c.insert (make_pair ("meterbridge label: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("meter marker", HSV (0xf2425bff)));
        c.insert (make_pair ("midi bus base", HSV (0x00000000)));
        c.insert (make_pair ("midi frame base", HSV (0x393d3766)));
        c.insert (make_pair ("midi note inactive channel", HSV (0x00000000)));
        c.insert (make_pair ("midi note color min", HSV (0x3f542aff)));
        c.insert (make_pair ("midi note color mid", HSV (0x7ea854ff)));
        c.insert (make_pair ("midi note color max", HSV (0xbfff80ff)));
        c.insert (make_pair ("selected midi note color min", HSV (0x1e1e33ff)));
        c.insert (make_pair ("selected midi note color mid", HSV (0x51518aff)));
        c.insert (make_pair ("selected midi note color max", HSV (0x8383deff)));
        c.insert (make_pair ("midi note selected", HSV (0xb2b2ffff)));
        c.insert (make_pair ("midi note velocity text", HSV (0xf4f214bc)));
        c.insert (make_pair ("midi patch change fill", HSV (0x50555aa0)));
        c.insert (make_pair ("midi patch change outline", HSV (0xc0c5caff)));
        c.insert (make_pair ("midi patch change inactive channel fill", HSV (0x50555ac0)));
        c.insert (make_pair ("midi patch change inactive channel outline", HSV (0x20252ac0)));
        c.insert (make_pair ("midi sysex fill", HSV (0xf1e139a0)));
        c.insert (make_pair ("midi sysex outline", HSV (0xa7a7d4ff)));
        c.insert (make_pair ("midi select rect fill", HSV (0x8888ff88)));
        c.insert (make_pair ("midi select rect outline", HSV (0x5555ffff)));
        c.insert (make_pair ("midi track base", HSV (0xb3cca35f)));
        c.insert (make_pair ("name highlight fill", HSV (0x0000ffff)));
        c.insert (make_pair ("name highlight outline", HSV (0x7c00ff96)));
        c.insert (make_pair ("piano roll black outline", HSV (0xf4f4f476)));
        c.insert (make_pair ("piano roll black", HSV (0x6c6e6a6b)));
        c.insert (make_pair ("piano roll white", HSV (0x979b9565)));
        c.insert (make_pair ("play head", HSV (0xff0000ff)));
        c.insert (make_pair ("processor automation line", HSV (0x7aa3f9ff)));
        c.insert (make_pair ("punch line", HSV (0xa80000ff)));
        c.insert (make_pair ("range drag bar rect", HSV (0x969696c6)));
        c.insert (make_pair ("range drag rect", HSV (0x82c696c6)));
        c.insert (make_pair ("range marker bar", HSV (0x7d7f8ccc)));
        c.insert (make_pair ("recording rect", HSV (0xcc2828ff)));
        c.insert (make_pair ("recorded waveform fill", HSV (0xffffffd9)));
        c.insert (make_pair ("recorded waveform outline", HSV (0x0f0f1fff)));
        c.insert (make_pair ("rubber band rect", HSV (0xc6c6c659)));
        c.insert (make_pair ("ruler base", HSV (0x2c2121ff)));
        c.insert (make_pair ("ruler text", HSV (0xe5e5e5ff)));
        c.insert (make_pair ("selected crossfade editor line", HSV (0x00dbdbff)));
        c.insert (make_pair ("selected crossfade editor wave", HSV (0xf9ea14a0)));
        c.insert (make_pair ("selected region base", HSV (0x585c61ff)));
        c.insert (make_pair ("selected waveform fill", HSV (0xffa500d9)));
        c.insert (make_pair ("selected waveform outline", HSV (0x0f0f0fcc)));
        c.insert (make_pair ("selection rect", HSV (0xe8f4d377)));
        c.insert (make_pair ("selection", HSV (0x636363b2)));
        c.insert (make_pair ("shuttle", HSV (0x6bb620ff)));
        c.insert (make_pair ("silence", HSV (0x9efffd7a)));
        c.insert (make_pair ("silence text", HSV (0x0e066cff)));
        c.insert (make_pair ("mono panner outline", HSV (0x33445eff)));
        c.insert (make_pair ("mono panner fill", HSV (0x7a9bccc9)));
        c.insert (make_pair ("mono panner text", HSV (0x000000ff)));
        c.insert (make_pair ("mono panner bg", HSV (0x2e2929ff)));
        c.insert (make_pair ("mono panner position fill", HSV (0x7a89b3ff)));
        c.insert (make_pair ("mono panner position outline", HSV (0x33445eff)));
        c.insert (make_pair ("stereo panner outline", HSV (0x33445eff)));
        c.insert (make_pair ("stereo panner fill", HSV (0x7a9accc9)));
        c.insert (make_pair ("stereo panner text", HSV (0x000000ff)));
        c.insert (make_pair ("stereo panner bg", HSV (0x2e2929ff)));
        c.insert (make_pair ("stereo panner rule", HSV (0x455c7fff)));
        c.insert (make_pair ("stereo panner mono outline", HSV (0xa05600ff)));
        c.insert (make_pair ("stereo panner mono fill", HSV (0xe99668ca)));
        c.insert (make_pair ("stereo panner mono text", HSV (0x000000ff)));
        c.insert (make_pair ("stereo panner mono bg", HSV (0x2e2929ff)));
        c.insert (make_pair ("stereo panner inverted outline", HSV (0xbf0a00ff)));
        c.insert (make_pair ("stereo panner inverted fill", HSV (0xe4a19cc9)));
        c.insert (make_pair ("stereo panner inverted text", HSV (0x000000ff)));
        c.insert (make_pair ("stereo panner inverted bg", HSV (0x2e2929ff)));
        c.insert (make_pair ("tempo bar", HSV (0x70727fcc)));
        c.insert (make_pair ("tempo marker", HSV (0xf2425bff)));
        c.insert (make_pair ("time axis frame", HSV (0x000000ff)));
        c.insert (make_pair ("selected time axis frame", HSV (0xee0000ff)));
        c.insert (make_pair ("time stretch fill", HSV (0xe2b5b596)));
        c.insert (make_pair ("time stretch outline", HSV (0x63636396)));
        c.insert (make_pair ("tracknumber label: fill", HSV (0x444444ff)));
        c.insert (make_pair ("tracknumber label: fill active", HSV (0x333333ff)));
        c.insert (make_pair ("tracknumber label: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("transport drag rect", HSV (0x969696c6)));
        c.insert (make_pair ("transport loop rect", HSV (0x1e7728f9)));
        c.insert (make_pair ("transport marker bar", HSV (0x8c8e98cc)));
        c.insert (make_pair ("transport punch rect", HSV (0x6d2828e5)));
        c.insert (make_pair ("trim handle locked", HSV (0xea0f0f28)));
        c.insert (make_pair ("trim handle", HSV (0x1900ff44)));
        c.insert (make_pair ("verbose canvas cursor", HSV (0xfffd2ebc)));
        c.insert (make_pair ("vestigial frame", HSV (0x0000000f)));
        c.insert (make_pair ("video timeline bar", HSV (0x303030ff)));
        c.insert (make_pair ("region base", HSV (0x838890ff)));
        c.insert (make_pair ("region area covered by another region", HSV (0x505050b0)));
        c.insert (make_pair ("waveform outline", HSV (0x000000ff)));
        c.insert (make_pair ("clipped waveform", HSV (0xff0000e5)));
        c.insert (make_pair ("waveform fill", HSV (0xffffffd9)));
        c.insert (make_pair ("zero line", HSV (0x7f7f7fe0)));
        c.insert (make_pair ("zoom rect", HSV (0xc6d1b26d)));
        c.insert (make_pair ("monitor knob", HSV (0x555050ff)));
        c.insert (make_pair ("monitor knob: arc start", HSV (0x5d90b0ff)));
        c.insert (make_pair ("monitor knob: arc end", HSV (0x154c6eff)));
        c.insert (make_pair ("button border", HSV (0x000000f0)));
        c.insert (make_pair ("border color", HSV (0x00000000)));
        c.insert (make_pair ("processor prefader: fill", HSV (0x873c3cff)));
        c.insert (make_pair ("processor prefader: fill active", HSV (0x603535ff)));
        c.insert (make_pair ("processor prefader: led", HSV (0x26550eff)));
        c.insert (make_pair ("processor prefader: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("processor prefader: text", HSV (0xaaaaa3ff)));
        c.insert (make_pair ("processor prefader: text active", HSV (0xeeeeecff)));
        c.insert (make_pair ("processor fader: fill", HSV (0x5d90b0ff)));
        c.insert (make_pair ("processor fader: fill active", HSV (0x256d8fff)));
        c.insert (make_pair ("processor fader: led", HSV (0x26550eff)));
        c.insert (make_pair ("processor fader: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("processor fader: text", HSV (0xaaaaa3ff)));
        c.insert (make_pair ("processor fader: text active", HSV (0xeeeeecff)));
        c.insert (make_pair ("processor postfader: fill", HSV (0x455a3cff)));
        c.insert (make_pair ("processor postfader: fill active", HSV (0x254528ff)));
        c.insert (make_pair ("processor postfader: led", HSV (0x26550eff)));
        c.insert (make_pair ("processor postfader: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("processor postfader: text", HSV (0xaaaaa3ff)));
        c.insert (make_pair ("processor postfader: text active", HSV (0xeeeeecff)));
        c.insert (make_pair ("processor control button: fill", HSV (0x222222ff)));
        c.insert (make_pair ("processor control button: fill active", HSV (0x333333ff)));
        c.insert (make_pair ("processor control button: led", HSV (0x101010ff)));
        c.insert (make_pair ("processor control button: led active", HSV (0x5d90b0ff)));
        c.insert (make_pair ("processor control button: text", HSV (0xffffffff)));
        c.insert (make_pair ("processor control button: text active", HSV (0xffffffff)));
        c.insert (make_pair ("midi device: fill", HSV (0x54555dff)));
        c.insert (make_pair ("midi device: fill active", HSV (0x45464cff)));
        c.insert (make_pair ("midi device: led", HSV (0x006600ff)));
        c.insert (make_pair ("midi device: led active", HSV (0x00ff00ff)));
        c.insert (make_pair ("midi device: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("midi device: text active", HSV (0xeeeeecff)));
        c.insert (make_pair ("monitor button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("monitor button: fill active", HSV (0xc56505ff)));
        c.insert (make_pair ("monitor button: led", HSV (0x660000ff)));
        c.insert (make_pair ("monitor button: led active", HSV (0xff0000ff)));
        c.insert (make_pair ("monitor button: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("monitor button: text active", HSV (0x1a1a1aff)));
        c.insert (make_pair ("solo isolate: fill", HSV (0x616268ff)));
        c.insert (make_pair ("solo isolate: fill active", HSV (0x564d48ff)));
        c.insert (make_pair ("solo isolate: led", HSV (0x660000ff)));
        c.insert (make_pair ("solo isolate: led active", HSV (0xff0000ff)));
        c.insert (make_pair ("solo isolate: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("solo isolate: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("solo safe: fill", HSV (0x616268ff)));
        c.insert (make_pair ("solo safe: fill active", HSV (0x564d48ff)));
        c.insert (make_pair ("solo safe: led", HSV (0x660000ff)));
        c.insert (make_pair ("solo safe: led active", HSV (0xff0000ff)));
        c.insert (make_pair ("solo safe: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("solo safe: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("meterbridge peaklabel", HSV (0xff1111ff)));
        c.insert (make_pair ("meter color BBC", HSV (0xffa500ff)));
        c.insert (make_pair ("monitor section cut: fill", HSV (0x5f5a58ff)));
        c.insert (make_pair ("monitor section cut: fill active", HSV (0xffa500ff)));
        c.insert (make_pair ("monitor section cut: led", HSV (0x473812ff)));
        c.insert (make_pair ("monitor section cut: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("monitor section cut: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("monitor section cut: text active", HSV (0x000000ff)));
        c.insert (make_pair ("monitor section dim: fill", HSV (0x5f5a58ff)));
        c.insert (make_pair ("monitor section dim: fill active", HSV (0xe58505ff)));
        c.insert (make_pair ("monitor section dim: led", HSV (0x00000000)));
        c.insert (make_pair ("monitor section dim: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("monitor section dim: text", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("monitor section dim: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("monitor section solo: fill", HSV (0x5f5a58ff)));
        c.insert (make_pair ("monitor section solo: fill active", HSV (0x4dbb00ff)));
        c.insert (make_pair ("monitor section solo: led", HSV (0x473812ff)));
        c.insert (make_pair ("monitor section solo: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("monitor section solo: text", HSV (0x00000000)));
        c.insert (make_pair ("monitor section solo: text active", HSV (0x00000000)));
        c.insert (make_pair ("monitor section invert: fill", HSV (0x5f5a58ff)));
        c.insert (make_pair ("monitor section invert: fill active", HSV (0x4242d0ff)));
        c.insert (make_pair ("monitor section invert: led", HSV (0x473812ff)));
        c.insert (make_pair ("monitor section invert: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("monitor section invert: text", HSV (0x00000000)));
        c.insert (make_pair ("monitor section invert: text active", HSV (0x00000000)));
        c.insert (make_pair ("monitor section mono: fill", HSV (0x5f5a58ff)));
        c.insert (make_pair ("monitor section mono: fill active", HSV (0x3232c0ff)));
        c.insert (make_pair ("monitor section mono: led", HSV (0x473812ff)));
        c.insert (make_pair ("monitor section mono: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("monitor section mono: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("monitor section mono: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("monitor section solo model: fill", HSV (0x5d5856ff)));
        c.insert (make_pair ("monitor section solo model: fill active", HSV (0x564d48ff)));
        c.insert (make_pair ("monitor section solo model: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("monitor section solo model: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("monitor section solo model: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("monitor section solo model: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("monitor solo override: fill", HSV (0x5d5856ff)));
        c.insert (make_pair ("monitor solo override: fill active", HSV (0x564d48ff)));
        c.insert (make_pair ("monitor solo override: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("monitor solo override: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("monitor solo override: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("monitor solo override: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("monitor solo exclusive: fill", HSV (0x5d5856ff)));
        c.insert (make_pair ("monitor solo exclusive: fill active", HSV (0x564c47ff)));
        c.insert (make_pair ("monitor solo exclusive: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("monitor solo exclusive: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("monitor solo exclusive: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("monitor solo exclusive: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("rude solo: fill", HSV (0x684d4dff)));
        c.insert (make_pair ("rude solo: fill active", HSV (0xe21b1bff)));
        c.insert (make_pair ("rude solo: led", HSV (0x00000000)));
        c.insert (make_pair ("rude solo: led active", HSV (0x00000000)));
        c.insert (make_pair ("rude solo: text", HSV (0x969696ff)));
        c.insert (make_pair ("rude solo: text active", HSV (0xe5e5e5ff)));
        c.insert (make_pair ("rude isolate: fill", HSV (0x21414fff)));
        c.insert (make_pair ("rude isolate: fill active", HSV (0xb6e5fdff)));
        c.insert (make_pair ("rude isolate: led", HSV (0x00000000)));
        c.insert (make_pair ("rude isolate: led active", HSV (0x000000ff)));
        c.insert (make_pair ("rude isolate: text", HSV (0x979797ff)));
        c.insert (make_pair ("rude isolate: text active", HSV (0x000000ff)));
        c.insert (make_pair ("rude audition: fill", HSV (0x684d4dff)));
        c.insert (make_pair ("rude audition: fill active", HSV (0xe21b1bff)));
        c.insert (make_pair ("rude audition: led", HSV (0x00000000)));
        c.insert (make_pair ("rude audition: led active", HSV (0x00000000)));
        c.insert (make_pair ("rude audition: text", HSV (0x979797ff)));
        c.insert (make_pair ("rude audition: text active", HSV (0xffffffff)));
        c.insert (make_pair ("feedback alert: fill", HSV (0x684d4dff)));
        c.insert (make_pair ("feedback alert: fill active", HSV (0xe21b1bff)));
        c.insert (make_pair ("feedback alert: led", HSV (0x00000000)));
        c.insert (make_pair ("feedback alert: led active", HSV (0x00000000)));
        c.insert (make_pair ("feedback alert: text", HSV (0x969696ff)));
        c.insert (make_pair ("feedback alert: text active", HSV (0xe5e5e5ff)));
        c.insert (make_pair ("mute button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("mute button: fill active", HSV (0xbbbb00ff)));
        c.insert (make_pair ("mute button: led", HSV (0x00000000)));
        c.insert (make_pair ("mute button: led active", HSV (0x00000000)));
        c.insert (make_pair ("mute button: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("mute button: text active", HSV (0x191919ff)));
        c.insert (make_pair ("solo button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("solo button: fill active", HSV (0x4dbb00ff)));
        c.insert (make_pair ("solo button: led", HSV (0x00000000)));
        c.insert (make_pair ("solo button: led active", HSV (0x00000000)));
        c.insert (make_pair ("solo button: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("solo button: text active", HSV (0x191919ff)));
        c.insert (make_pair ("invert button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("invert button: fill active", HSV (0x4242d0ff)));
        c.insert (make_pair ("invert button: led", HSV (0x473812ff)));
        c.insert (make_pair ("invert button: led active", HSV (0x78cb4eff)));
        c.insert (make_pair ("invert button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("invert button: text active", HSV (0xbfbfbfff)));
        c.insert (make_pair ("record enable button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("record enable button: fill active", HSV (0xb50e0eff)));
        c.insert (make_pair ("record enable button: led", HSV (0x7b3541ff)));
        c.insert (make_pair ("record enable button: led active", HSV (0xffa3b3ff)));
        c.insert (make_pair ("record enable button: text", HSV (0xa5a5a5ff)));
        c.insert (make_pair ("record enable button: text active", HSV (0x000000ff)));
        c.insert (make_pair ("generic button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("generic button: fill active", HSV (0xfd0000ff)));
        c.insert (make_pair ("generic button: led", HSV (0x22224fff)));
        c.insert (make_pair ("generic button: led active", HSV (0x2222ffff)));
        c.insert (make_pair ("generic button: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("generic button: text active", HSV (0x191919ff)));
        c.insert (make_pair ("send alert button: fill", HSV (0x4e5647ff)));
        c.insert (make_pair ("send alert button: fill active", HSV (0x85e524ff)));
        c.insert (make_pair ("send alert button: led", HSV (0x00000000)));
        c.insert (make_pair ("send alert button: led active", HSV (0x00000000)));
        c.insert (make_pair ("send alert button: text", HSV (0xccccccff)));
        c.insert (make_pair ("send alert button: text active", HSV (0x000000ff)));
        c.insert (make_pair ("transport button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("transport button: fill active", HSV (0x00a300ff)));
        c.insert (make_pair ("transport button: led", HSV (0x00000000)));
        c.insert (make_pair ("transport button: led active", HSV (0x00000000)));
        c.insert (make_pair ("transport button: text", HSV (0x00000000)));
        c.insert (make_pair ("transport button: text active", HSV (0x00000000)));
        c.insert (make_pair ("transport recenable button: fill", HSV (0x5f3f3fff)));
        c.insert (make_pair ("transport recenable button: fill active", HSV (0xb50e0eff)));
        c.insert (make_pair ("transport recenable button: led", HSV (0x00000000)));
        c.insert (make_pair ("transport recenable button: led active", HSV (0x00000000)));
        c.insert (make_pair ("transport recenable button: text", HSV (0x00000000)));
        c.insert (make_pair ("transport recenable button: text active", HSV (0x00000000)));
        c.insert (make_pair ("transport option button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("transport option button: fill active", HSV (0x4a4b51ff)));
        c.insert (make_pair ("transport option button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("transport option button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("transport option button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("transport option button: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("transport active option button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("transport active option button: fill active", HSV (0x00a300ff)));
        c.insert (make_pair ("transport active option button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("transport active option button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("transport active option button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("transport active option button: text active", HSV (0x000000ff)));
        c.insert (make_pair ("plugin bypass button: fill", HSV (0x5d5856ff)));
        c.insert (make_pair ("plugin bypass button: fill active", HSV (0x564d48ff)));
        c.insert (make_pair ("plugin bypass button: led", HSV (0x660000ff)));
        c.insert (make_pair ("plugin bypass button: led active", HSV (0xff0000ff)));
        c.insert (make_pair ("plugin bypass button: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("plugin bypass button: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("punch button: fill", HSV (0x603f3fff)));
        c.insert (make_pair ("punch button: fill active", HSV (0xf03020ff)));
        c.insert (make_pair ("punch button: led", HSV (0x00000000)));
        c.insert (make_pair ("punch button: led active", HSV (0x00000000)));
        c.insert (make_pair ("punch button: text", HSV (0xa5a5a5ff)));
        c.insert (make_pair ("punch button: text active", HSV (0xd8d8d8ff)));
        c.insert (make_pair ("mouse mode button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("mouse mode button: fill active", HSV (0x00b200ff)));
        c.insert (make_pair ("mouse mode button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("mouse mode button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("mouse mode button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("mouse mode button: text active", HSV (0x000000ff)));
        c.insert (make_pair ("nudge button: fill", HSV (0x684744ff)));
        c.insert (make_pair ("nudge button: fill active", HSV (0x404045ff)));
        c.insert (make_pair ("nudge button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("nudge button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("nudge button: text", HSV (0xc7c7d8ff)));
        c.insert (make_pair ("nudge button: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("zoom menu: fill", HSV (0x99997950)));
        c.insert (make_pair ("zoom menu: fill active", HSV (0x404045ff)));
        c.insert (make_pair ("zoom menu: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("zoom menu: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("zoom menu: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("zoom menu: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("zoom button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("zoom button: fill active", HSV (0x00a300ff)));
        c.insert (make_pair ("zoom button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("zoom button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("zoom button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("zoom button: text active", HSV (0x000000ff)));
        c.insert (make_pair ("route button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("route button: fill active", HSV (0x121212ff)));
        c.insert (make_pair ("route button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("route button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("route button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("route button: text active", HSV (0x191919ff)));
        c.insert (make_pair ("mixer strip button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("mixer strip button: fill active", HSV (0xffa500ff)));
        c.insert (make_pair ("mixer strip button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("mixer strip button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("mixer strip button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("mixer strip button: text active", HSV (0x000000ff)));
        c.insert (make_pair ("mixer strip name button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("mixer strip name button: fill active", HSV (0x121212ff)));
        c.insert (make_pair ("mixer strip name button: led", HSV (0x4f3300ff)));
        c.insert (make_pair ("mixer strip name button: led active", HSV (0xffa500ff)));
        c.insert (make_pair ("mixer strip name button: text", HSV (0xd7d7e8ff)));
        c.insert (make_pair ("mixer strip name button: text active", HSV (0xc8c8d9ff)));
        c.insert (make_pair ("midi input button: fill", HSV (0x656867ff)));
        c.insert (make_pair ("midi input button: fill active", HSV (0x00a300ff)));
        c.insert (make_pair ("midi input button: led", HSV (0x00000000)));
        c.insert (make_pair ("midi input button: led active", HSV (0x00000000)));
        c.insert (make_pair ("midi input button: text", HSV (0x00000000)));
        c.insert (make_pair ("midi input button: text active", HSV (0x00000000)));
        c.insert (make_pair ("transport clock: background", HSV (0x262626ff)));
        c.insert (make_pair ("transport clock: text", HSV (0x8df823ff)));
        c.insert (make_pair ("transport clock: edited text", HSV (0xffa500ff)));
        c.insert (make_pair ("transport clock: cursor", HSV (0xffa500ff)));
        c.insert (make_pair ("secondary clock: background", HSV (0x262626ff)));
        c.insert (make_pair ("secondary clock: text", HSV (0x8df823ff)));
        c.insert (make_pair ("secondary clock: edited text", HSV (0xffa500ff)));
        c.insert (make_pair ("secondary clock: cursor", HSV (0xffa500ff)));
        c.insert (make_pair ("transport delta clock: background", HSV (0x000000ff)));
        c.insert (make_pair ("transport delta clock: edited text", HSV (0xff0000ff)));
        c.insert (make_pair ("transport delta clock: cursor", HSV (0xf11000ff)));
        c.insert (make_pair ("transport delta clock: text", HSV (0x8ce1f8ff)));
        c.insert (make_pair ("secondary delta clock: edited text", HSV (0xff0000ff)));
        c.insert (make_pair ("secondary delta clock: cursor", HSV (0xf11000ff)));
        c.insert (make_pair ("secondary delta clock: background", HSV (0x000000ff)));
        c.insert (make_pair ("secondary delta clock: text", HSV (0x8ce1f8ff)));
        c.insert (make_pair ("big clock: background", HSV (0x020202ff)));
        c.insert (make_pair ("big clock: text", HSV (0xf0f0f0ff)));
        c.insert (make_pair ("big clock: edited text", HSV (0xffa500ff)));
        c.insert (make_pair ("big clock: cursor", HSV (0xffa500ff)));
        c.insert (make_pair ("big clock active: background", HSV (0x020202ff)));
        c.insert (make_pair ("big clock active: text", HSV (0xf11000ff)));
        c.insert (make_pair ("big clock active: edited text", HSV (0xffa500ff)));
        c.insert (make_pair ("big clock active: cursor", HSV (0xffa500ff)));
        c.insert (make_pair ("punch clock: background", HSV (0x000000ff)));
        c.insert (make_pair ("punch clock: text", HSV (0x6bb620ff)));
        c.insert (make_pair ("punch clock: edited text", HSV (0xff0000ff)));
        c.insert (make_pair ("punch clock: cursor", HSV (0xf11000ff)));
        c.insert (make_pair ("selection clock: background", HSV (0x000000ff)));
        c.insert (make_pair ("selection clock: text", HSV (0x6bb620ff)));
        c.insert (make_pair ("selection clock: edited text", HSV (0xff0000ff)));
        c.insert (make_pair ("selection clock: cursor", HSV (0xf11000ff)));
        c.insert (make_pair ("nudge clock: background", HSV (0x262626ff)));
        c.insert (make_pair ("nudge clock: text", HSV (0x6bb620ff)));
        c.insert (make_pair ("nudge clock: edited text", HSV (0xffa500ff)));
        c.insert (make_pair ("nudge clock: cursor", HSV (0xffa500ff)));
        c.insert (make_pair ("clock: background", HSV (0x000000ff)));
        c.insert (make_pair ("clock: text", HSV (0x6bb620ff)));
        c.insert (make_pair ("clock: edited text", HSV (0xffa500ff)));
        c.insert (make_pair ("clock: cursor", HSV (0xffa500ff)));
        c.insert (make_pair ("lock button: fill", HSV (0x616268ff)));
        c.insert (make_pair ("lock button: fill active", HSV (0x404045ff)));
        c.insert (make_pair ("lock button: led", HSV (0x00000000)));
        c.insert (make_pair ("lock button: led active", HSV (0x00000000)));
        c.insert (make_pair ("lock button: text", HSV (0x000024ff)));
        c.insert (make_pair ("lock button: text active", HSV (0xc8c8d9ff)));

	for (map<string,HSV>::iterator fp = c.begin(); fp != c.end(); ++fp) {
		fp->second.h = hue_width * (round (fp->second.h/hue_width));
	}

#undef CANVAS_COLOR
#define CANVAS_COLOR(var,name,base,modifier) print_relative_def (#var,name,c[name]);
#include "colors.h"
#undef CANVAS_COLOR	
}

void
UIConfiguration::color_theme_changed ()
{
	return;
	
	map<std::string,RelativeHSV>::iterator current_color;

	/* we need to reset the quantized hues before we start, because
	 * otherwise when we call RelativeHSV::get() in color_compute()
	 * we don't get an answer based on the new base colors, but instead
	 * based on any existing hue quantization.
	 */

	for (current_color = relative_colors.begin(); current_color != relative_colors.end(); ++current_color) {
		current_color->second.quantized_hue = -1;
	}

	color_compute ();
}

void
UIConfiguration::map_parameters (boost::function<void (std::string)>& functor)
{
#undef  UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,Name,value) functor (Name);
#include "ui_config_vars.h"
#undef  UI_CONFIG_VARIABLE
}

int
UIConfiguration::load_defaults ()
{
	int found = 0;
        std::string rcfile;

	if (find_file (ardour_config_search_path(), default_ui_config_file_name, rcfile) ) {
		XMLTree tree;
		found = 1;

		info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl;

		if (!tree.read (rcfile.c_str())) {
			error << string_compose(_("cannot read default ui configuration file \"%1\""), rcfile) << endmsg;
			return -1;
		}

		if (set_state (*tree.root(), Stateful::loading_state_version)) {
			error << string_compose(_("default ui configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
			return -1;
		}

		_dirty = false;
	}

	return found;
}

int
UIConfiguration::load_state ()
{
	bool found = false;

	std::string rcfile;

	if ( find_file (ardour_config_search_path(), default_ui_config_file_name, rcfile)) {
		XMLTree tree;
		found = true;

		info << string_compose (_("Loading default ui configuration file %1"), rcfile) << endl;

		if (!tree.read (rcfile.c_str())) {
			error << string_compose(_("cannot read default ui configuration file \"%1\""), rcfile) << endmsg;
			return -1;
		}

		if (set_state (*tree.root(), Stateful::loading_state_version)) {
			error << string_compose(_("default ui configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
			return -1;
		}
	}

	if (find_file (ardour_config_search_path(), ui_config_file_name, rcfile)) {
		XMLTree tree;
		found = true;

		info << string_compose (_("Loading user ui configuration file %1"), rcfile) << endmsg;

		if (!tree.read (rcfile)) {
			error << string_compose(_("cannot read ui configuration file \"%1\""), rcfile) << endmsg;
			return -1;
		}

		if (set_state (*tree.root(), Stateful::loading_state_version)) {
			error << string_compose(_("user ui configuration file \"%1\" not loaded successfully."), rcfile) << endmsg;
			return -1;
		}

		_dirty = false;
	}

	if (!found) {
		error << _("could not find any ui configuration file, canvas will look broken.") << endmsg;
	}

	return 0;
}

int
UIConfiguration::save_state()
{
	XMLTree tree;

	std::string rcfile(user_config_directory());
	rcfile = Glib::build_filename (rcfile, ui_config_file_name);

	// this test seems bogus?
	if (rcfile.length()) {
		tree.set_root (&get_state());
		if (!tree.write (rcfile.c_str())){
			error << string_compose (_("Config file %1 not saved"), rcfile) << endmsg;
			return -1;
		}
	}

	_dirty = false;

	return 0;
}

XMLNode&
UIConfiguration::get_state ()
{
	XMLNode* root;
	LocaleGuard lg (X_("POSIX"));

	root = new XMLNode("Ardour");

	root->add_child_nocopy (get_variables ("UI"));
	root->add_child_nocopy (get_variables ("Canvas"));

	if (_extra_xml) {
		root->add_child_copy (*_extra_xml);
	}

	return *root;
}

XMLNode&
UIConfiguration::get_variables (std::string which_node)
{
	XMLNode* node;
	LocaleGuard lg (X_("POSIX"));

	node = new XMLNode (which_node);

#undef  UI_CONFIG_VARIABLE
#undef  CANVAS_STRING_VARIABLE
#undef  CANVAS_FONT_VARIABLE
#undef  CANVAS_BASE_COLOR
#define UI_CONFIG_VARIABLE(Type,var,Name,value) if (node->name() == "UI") { var.add_to_node (*node); }
#define CANVAS_STRING_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); }
#define CANVAS_FONT_VARIABLE(var,Name) if (node->name() == "Canvas") { var.add_to_node (*node); }
#define CANVAS_BASE_COLOR(var,Name,val) if (node->name() == "Canvas") { var.add_to_node (*node); }
#include "ui_config_vars.h"
#include "canvas_vars.h"
#include "base_colors.h"
#undef  UI_CONFIG_VARIABLE
#undef  CANVAS_STRING_VARIABLE
#undef  CANVAS_FONT_VARIABLE
#undef  CANVAS_BASE_COLOR

	return *node;
}

int
UIConfiguration::set_state (const XMLNode& root, int /*version*/)
{
	if (root.name() != "Ardour") {
		return -1;
	}

	Stateful::save_extra_xml (root);

	XMLNodeList nlist = root.children();
	XMLNodeConstIterator niter;
	XMLNode *node;

	for (niter = nlist.begin(); niter != nlist.end(); ++niter) {

		node = *niter;

		if (node->name() == "Canvas" ||  node->name() == "UI") {
			set_variables (*node);

		}
	}

	return 0;
}


void
UIConfiguration::set_variables (const XMLNode& node)
{
#undef  UI_CONFIG_VARIABLE
#define UI_CONFIG_VARIABLE(Type,var,name,val) \
         if (var.set_from_node (node)) { \
		 ParameterChanged (name); \
		 }
#define CANVAS_STRING_VARIABLE(var,name)	\
         if (var.set_from_node (node)) { \
		 ParameterChanged (name); \
		 }
#define CANVAS_FONT_VARIABLE(var,name)	\
         if (var.set_from_node (node)) { \
		 ParameterChanged (name); \
		 }
#include "ui_config_vars.h"
#include "canvas_vars.h"
#undef  UI_CONFIG_VARIABLE
#undef  CANVAS_STRING_VARIABLE
#undef  CANVAS_FONT_VARIABLE

	/* Reset base colors */

#undef  CANVAS_BASE_COLOR
#define CANVAS_BASE_COLOR(var,name,val) \
	var.set_from_node (node);
#include "base_colors.h"
#undef CANVAS_BASE_COLOR	

}

void
UIConfiguration::set_dirty ()
{
	_dirty = true;
}

bool
UIConfiguration::dirty () const
{
	return _dirty;
}

ArdourCanvas::Color
UIConfiguration::base_color_by_name (const std::string& name) const
{
	map<std::string,ColorVariable<Color>* >::const_iterator i = configurable_colors.find (name);

	if (i != configurable_colors.end()) {
		return i->second->get();
	}

#if 0 // yet unsed experimental style postfix
	/* Idea: use identical colors but different font/sizes
	 * for variants of the same 'widget'.
	 *
	 * example:
	 *  set_name("mute button");  // in route_ui.cc
	 *  set_name("mute button small"); // in mixer_strip.cc
	 *
	 * ardour3_widget_list.rc:
	 *  widget "*mute button" style:highest "small_button"
	 *  widget "*mute button small" style:highest "very_small_text"
	 *
	 * both use color-schema of defined in
	 *   BUTTON_VARS(MuteButton, "mute button")
	 *
	 * (in this particular example the widgets should be packed
	 * vertically shinking the mixer strip ones are currently not)
	 */
	const size_t name_len = name.size();
	const size_t name_sep = name.find(':');
	for (i = configurable_colors.begin(); i != configurable_colors.end(), name_sep != string::npos; ++i) {
		const size_t cmp_len = i->first.size();
		const size_t cmp_sep = i->first.find(':');
		if (cmp_len >= name_len || cmp_sep == string::npos) continue;
		if (name.substr(name_sep) != i->first.substr(cmp_sep)) continue;
		if (name.substr(0, cmp_sep) != i->first.substr(0, cmp_sep)) continue;
		return i->second->get();
	}
#endif

	cerr << string_compose (_("Base Color %1 not found"), name) << endl;
	return RGBA_TO_UINT (g_random_int()%256,g_random_int()%256,g_random_int()%256,0xff);
}

ArdourCanvas::Color
UIConfiguration::color (const std::string& name) const
{
	map<string,string>::const_iterator e = color_aliases.find (name);

	if (e != color_aliases.end ()) {
		map<string,RelativeHSV>::const_iterator rc = relative_colors.find (e->second);
		if (rc != relative_colors.end()) {
			return rc->second.get();
		}
	}

	cerr << string_compose (_("Color %1 not found"), name) << endl;
	
	return rgba_to_color ((g_random_int()%256)/255.0,
			      (g_random_int()%256)/255.0,
			      (g_random_int()%256)/255.0,
			      0xff);
}

ArdourCanvas::HSV
UIConfiguration::RelativeHSV::get() const
{
	HSV base (UIConfiguration::instance()->base_color_by_name (base_color));
	
	/* this operation is a little wierd. because of the way we originally
	 * computed the alpha specification for the modifiers used here
	 * we need to reset base's alpha to zero before adding the modifier.
	 */

	base.a = 0.0;

	HSV self (base + modifier);
	
	if (quantized_hue >= 0.0) {
		self.h = quantized_hue;
	}
	
	return self;
}

void
UIConfiguration::color_compute ()
{
	using namespace ArdourCanvas;

	map<std::string,ColorVariable<Color>* >::iterator f;
	map<std::string,HSV*>::iterator v;

	/* now compute distances */

	cerr << "Attempt to reduce " << relative_colors.size() << endl;

	map<std::string,RelativeHSV>::iterator current_color;
	
	color_aliases.clear ();
	actual_colors.clear ();

	for (current_color = relative_colors.begin(); current_color != relative_colors.end(); ++current_color) {

		map<std::string,HSV>::iterator possible_match;
		std::string equivalent_name;
		bool matched;

		matched = false;

		for (possible_match = actual_colors.begin(); possible_match != actual_colors.end(); ++possible_match) {

			HSV a (current_color->second.get());
			HSV b (possible_match->second);
		
			/* This uses perceptual distance to find visually
			 * similar colors.
			 */

			if (a.distance (b) < 6.0) {
				matched = true;
				break;
			}
		}

		if (!matched) {

			/* color does not match any other, generate a generic
			 * name and store two aliases.
			 */

			string alias = string_compose ("color %1", actual_colors.size() + 1);
			cerr << "CANVAS_COLOR(\"" << alias << "\", \"" << current_color->second.base_color 
			     << "\"," << current_color->second.modifier
			     << ")\n";
			actual_colors.insert (make_pair (alias, current_color->second.get()));
			color_aliases.insert (make_pair (current_color->first, alias));
			cerr << "COLOR_ALIAS(\"" << current_color->first << "\",\"" << alias << "\")\n";

		} else {

			/* this color was within the JND CIE76 distance of
			 * another, so throw it away.
			 */
			
			color_aliases.insert (make_pair (current_color->first, possible_match->first));
			cerr << "COLOR_ALIAS(\"" << current_color->first << "\",\"" << possible_match->first << "\")\n";
		}
	}

	cerr << "Ended with " << actual_colors.size() << " colors" << endl;
}