-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
/
editor_theme_manager.cpp
2512 lines (2083 loc) · 149 KB
/
editor_theme_manager.cpp
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
/**************************************************************************/
/* editor_theme_manager.cpp */
/**************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/**************************************************************************/
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/**************************************************************************/
#include "editor_theme_manager.h"
#include "core/error/error_macros.h"
#include "core/io/resource_loader.h"
#include "editor/editor_settings.h"
#include "editor/editor_string_names.h"
#include "editor/themes/editor_color_map.h"
#include "editor/themes/editor_fonts.h"
#include "editor/themes/editor_icons.h"
#include "editor/themes/editor_scale.h"
#include "editor/themes/editor_theme.h"
#include "scene/gui/graph_edit.h"
#include "scene/resources/image_texture.h"
#include "scene/resources/style_box_flat.h"
#include "scene/resources/style_box_line.h"
#include "scene/resources/style_box_texture.h"
#include "scene/resources/texture.h"
// Theme configuration.
uint32_t EditorThemeManager::ThemeConfiguration::hash() {
uint32_t hash = hash_murmur3_one_float(EDSCALE);
// Basic properties.
hash = hash_murmur3_one_32(preset.hash(), hash);
hash = hash_murmur3_one_32(spacing_preset.hash(), hash);
hash = hash_murmur3_one_32(base_color.to_rgba32(), hash);
hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);
hash = hash_murmur3_one_float(contrast, hash);
hash = hash_murmur3_one_float(icon_saturation, hash);
// Extra properties.
hash = hash_murmur3_one_32(base_spacing, hash);
hash = hash_murmur3_one_32(extra_spacing, hash);
hash = hash_murmur3_one_32(border_width, hash);
hash = hash_murmur3_one_32(corner_radius, hash);
hash = hash_murmur3_one_32((int)draw_extra_borders, hash);
hash = hash_murmur3_one_float(relationship_line_opacity, hash);
hash = hash_murmur3_one_32(thumb_size, hash);
hash = hash_murmur3_one_32(class_icon_size, hash);
hash = hash_murmur3_one_32((int)increase_scrollbar_touch_area, hash);
hash = hash_murmur3_one_float(gizmo_handle_scale, hash);
hash = hash_murmur3_one_32(color_picker_button_height, hash);
hash = hash_murmur3_one_float(subresource_hue_tint, hash);
hash = hash_murmur3_one_float(default_contrast, hash);
// Generated properties.
hash = hash_murmur3_one_32((int)dark_theme, hash);
return hash;
}
uint32_t EditorThemeManager::ThemeConfiguration::hash_fonts() {
uint32_t hash = hash_murmur3_one_float(EDSCALE);
// TODO: Implement the hash based on what editor_register_fonts() uses.
return hash;
}
uint32_t EditorThemeManager::ThemeConfiguration::hash_icons() {
uint32_t hash = hash_murmur3_one_float(EDSCALE);
hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);
hash = hash_murmur3_one_float(icon_saturation, hash);
hash = hash_murmur3_one_32(thumb_size, hash);
hash = hash_murmur3_one_float(gizmo_handle_scale, hash);
hash = hash_murmur3_one_32((int)dark_theme, hash);
return hash;
}
// Benchmarks.
int EditorThemeManager::benchmark_run = 0;
String EditorThemeManager::get_benchmark_key() {
if (benchmark_run == 0) {
return "EditorTheme (Startup)";
}
return vformat("EditorTheme (Run %d)", benchmark_run);
}
// Generation helper methods.
Ref<StyleBoxTexture> make_stylebox(Ref<Texture2D> p_texture, float p_left, float p_top, float p_right, float p_bottom, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, bool p_draw_center = true) {
Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
style->set_texture(p_texture);
style->set_texture_margin_individual(p_left * EDSCALE, p_top * EDSCALE, p_right * EDSCALE, p_bottom * EDSCALE);
style->set_content_margin_individual((p_left + p_margin_left) * EDSCALE, (p_top + p_margin_top) * EDSCALE, (p_right + p_margin_right) * EDSCALE, (p_bottom + p_margin_bottom) * EDSCALE);
style->set_draw_center(p_draw_center);
return style;
}
Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {
Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);
return style;
}
Ref<StyleBoxFlat> make_flat_stylebox(Color p_color, float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1, int p_corner_width = 0) {
Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
style->set_bg_color(p_color);
// Adjust level of detail based on the corners' effective sizes.
style->set_corner_detail(Math::ceil(0.8 * p_corner_width * EDSCALE));
style->set_corner_radius_all(p_corner_width * EDSCALE);
style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);
// Work around issue about antialiased edges being blurrier (GH-35279).
style->set_anti_aliased(false);
return style;
}
Ref<StyleBoxLine> make_line_stylebox(Color p_color, int p_thickness = 1, float p_grow_begin = 1, float p_grow_end = 1, bool p_vertical = false) {
Ref<StyleBoxLine> style(memnew(StyleBoxLine));
style->set_color(p_color);
style->set_grow_begin(p_grow_begin);
style->set_grow_end(p_grow_end);
style->set_thickness(p_thickness);
style->set_vertical(p_vertical);
return style;
}
// Theme generation and population routines.
Ref<EditorTheme> EditorThemeManager::_create_base_theme(const Ref<EditorTheme> &p_old_theme) {
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Create Base Theme");
Ref<EditorTheme> theme = memnew(EditorTheme);
ThemeConfiguration config = _create_theme_config(theme);
theme->set_generated_hash(config.hash());
theme->set_generated_fonts_hash(config.hash_fonts());
theme->set_generated_icons_hash(config.hash_icons());
print_verbose(vformat("EditorTheme: Generating new theme for the config '%d'.", theme->get_generated_hash()));
_create_shared_styles(theme, config);
// Register icons.
{
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Icons");
// External functions, see editor_icons.cpp.
editor_configure_icons(config.dark_theme);
// If settings are comparable to the old theme, then just copy existing icons over.
// Otherwise, regenerate them.
bool keep_old_icons = (p_old_theme != nullptr && theme->get_generated_icons_hash() == p_old_theme->get_generated_icons_hash());
if (keep_old_icons) {
print_verbose("EditorTheme: Can keep old icons, copying.");
editor_copy_icons(theme, p_old_theme);
} else {
print_verbose("EditorTheme: Generating new icons.");
editor_register_icons(theme, config.dark_theme, config.icon_saturation, config.thumb_size, config.gizmo_handle_scale);
}
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Icons");
}
// Register fonts.
{
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Fonts");
// TODO: Check if existing font definitions from the old theme are usable and copy them.
// External function, see editor_fonts.cpp.
print_verbose("EditorTheme: Generating new fonts.");
editor_register_fonts(theme);
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Fonts");
}
// TODO: Check if existing style definitions from the old theme are usable and copy them.
print_verbose("EditorTheme: Generating new styles.");
_populate_standard_styles(theme, config);
_populate_editor_styles(theme, config);
_populate_text_editor_styles(theme, config);
_populate_visual_shader_styles(theme, config);
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Create Base Theme");
return theme;
}
EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(const Ref<EditorTheme> &p_theme) {
ThemeConfiguration config;
// Basic properties.
config.preset = EDITOR_GET("interface/theme/preset");
config.spacing_preset = EDITOR_GET("interface/theme/spacing_preset");
config.base_color = EDITOR_GET("interface/theme/base_color");
config.accent_color = EDITOR_GET("interface/theme/accent_color");
config.contrast = EDITOR_GET("interface/theme/contrast");
config.icon_saturation = EDITOR_GET("interface/theme/icon_saturation");
// Extra properties.
config.base_spacing = EDITOR_GET("interface/theme/base_spacing");
config.extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
// Ensure borders are visible when using an editor scale below 100%.
config.border_width = CLAMP((int)EDITOR_GET("interface/theme/border_size"), 0, 2) * MAX(1, EDSCALE);
config.corner_radius = CLAMP((int)EDITOR_GET("interface/theme/corner_radius"), 0, 6);
config.draw_extra_borders = EDITOR_GET("interface/theme/draw_extra_borders");
config.relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
config.thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
config.class_icon_size = 16 * EDSCALE;
config.increase_scrollbar_touch_area = EDITOR_GET("interface/touchscreen/increase_scrollbar_touch_area");
config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
config.color_picker_button_height = 28 * EDSCALE;
config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");
config.default_contrast = 0.3; // Make sure to keep this in sync with the editor settings definition.
// Handle main theme preset.
{
const bool follow_system_theme = EDITOR_GET("interface/theme/follow_system_theme");
const bool use_system_accent_color = EDITOR_GET("interface/theme/use_system_accent_color");
DisplayServer *display_server = DisplayServer::get_singleton();
Color system_base_color = display_server->get_base_color();
Color system_accent_color = display_server->get_accent_color();
if (follow_system_theme) {
String dark_theme = "Default";
String light_theme = "Light";
config.preset = light_theme; // Assume light theme if we can't detect system theme attributes.
if (system_base_color == Color(0, 0, 0, 0)) {
if (display_server->is_dark_mode_supported() && display_server->is_dark_mode()) {
config.preset = dark_theme;
}
} else {
if (system_base_color.get_luminance() < 0.5) {
config.preset = dark_theme;
}
}
}
if (config.preset != "Custom") {
Color preset_accent_color;
Color preset_base_color;
float preset_contrast = 0;
bool preset_draw_extra_borders = false;
// Please use alphabetical order if you're adding a new theme here.
if (config.preset == "Breeze Dark") {
preset_accent_color = Color(0.26, 0.76, 1.00);
preset_base_color = Color(0.24, 0.26, 0.28);
preset_contrast = config.default_contrast;
} else if (config.preset == "Godot 2") {
preset_accent_color = Color(0.53, 0.67, 0.89);
preset_base_color = Color(0.24, 0.23, 0.27);
preset_contrast = config.default_contrast;
} else if (config.preset == "Gray") {
preset_accent_color = Color(0.44, 0.73, 0.98);
preset_base_color = Color(0.24, 0.24, 0.24);
preset_contrast = config.default_contrast;
} else if (config.preset == "Light") {
preset_accent_color = Color(0.18, 0.50, 1.00);
preset_base_color = Color(0.9, 0.9, 0.9);
// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
preset_contrast = -0.06;
} else if (config.preset == "Solarized (Dark)") {
preset_accent_color = Color(0.15, 0.55, 0.82);
preset_base_color = Color(0.04, 0.23, 0.27);
preset_contrast = config.default_contrast;
} else if (config.preset == "Solarized (Light)") {
preset_accent_color = Color(0.15, 0.55, 0.82);
preset_base_color = Color(0.89, 0.86, 0.79);
// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
preset_contrast = -0.06;
} else if (config.preset == "Black (OLED)") {
preset_accent_color = Color(0.45, 0.75, 1.0);
preset_base_color = Color(0, 0, 0);
// The contrast rate value is irrelevant on a fully black theme.
preset_contrast = 0.0;
preset_draw_extra_borders = true;
} else { // Default
preset_accent_color = Color(0.44, 0.73, 0.98);
preset_base_color = Color(0.21, 0.24, 0.29);
preset_contrast = config.default_contrast;
}
config.accent_color = preset_accent_color;
config.base_color = preset_base_color;
config.contrast = preset_contrast;
config.draw_extra_borders = preset_draw_extra_borders;
EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", config.accent_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", config.base_color);
EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", config.contrast);
EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", config.draw_extra_borders);
}
if (follow_system_theme && system_base_color != Color(0, 0, 0, 0)) {
config.base_color = system_base_color;
config.preset = "Custom";
}
if (use_system_accent_color && system_accent_color != Color(0, 0, 0, 0)) {
config.accent_color = system_accent_color;
config.preset = "Custom";
}
// Enforce values in case they were adjusted or overridden.
EditorSettings::get_singleton()->set_manually("interface/theme/preset", config.preset);
EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", config.accent_color);
EditorSettings::get_singleton()->set_manually("interface/theme/base_color", config.base_color);
EditorSettings::get_singleton()->set_manually("interface/theme/contrast", config.contrast);
EditorSettings::get_singleton()->set_manually("interface/theme/draw_extra_borders", config.draw_extra_borders);
}
// Handle theme spacing preset.
{
if (config.spacing_preset != "Custom") {
int preset_base_spacing = 0;
int preset_extra_spacing = 0;
if (config.spacing_preset == "Compact") {
preset_base_spacing = 0;
preset_extra_spacing = 4;
} else if (config.spacing_preset == "Spacious") {
preset_base_spacing = 6;
preset_extra_spacing = 2;
} else { // Default
preset_base_spacing = 4;
preset_extra_spacing = 0;
}
config.base_spacing = preset_base_spacing;
config.extra_spacing = preset_extra_spacing;
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_spacing", config.base_spacing);
EditorSettings::get_singleton()->set_initial_value("interface/theme/additional_spacing", config.extra_spacing);
}
// Enforce values in case they were adjusted or overridden.
EditorSettings::get_singleton()->set_manually("interface/theme/spacing_preset", config.spacing_preset);
EditorSettings::get_singleton()->set_manually("interface/theme/base_spacing", config.base_spacing);
EditorSettings::get_singleton()->set_manually("interface/theme/additional_spacing", config.extra_spacing);
}
// Generated properties.
config.dark_theme = is_dark_theme();
config.base_margin = config.base_spacing;
config.increased_margin = config.base_spacing + config.extra_spacing;
config.separation_margin = (config.base_spacing + config.extra_spacing / 2) * EDSCALE;
config.popup_margin = config.base_margin * 3 * EDSCALE;
// Make sure content doesn't stick to window decorations; this can be fixed in future with layout changes.
config.window_border_margin = MAX(1, config.base_margin * 2);
config.top_bar_separation = config.base_margin * 2 * EDSCALE;
// Force the v_separation to be even so that the spacing on top and bottom is even.
// If the vsep is odd and cannot be split into 2 even groups (of pixels), then it will be lopsided.
// We add 2 to the vsep to give it some extra spacing which looks a bit more modern (see Windows, for example).
const int separation_base = config.increased_margin + 6;
config.forced_even_separation = separation_base + (separation_base % 2);
return config;
}
void EditorThemeManager::_create_shared_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
// Colors.
{
// Base colors.
p_theme->set_color("base_color", EditorStringName(Editor), p_config.base_color);
p_theme->set_color("accent_color", EditorStringName(Editor), p_config.accent_color);
// White (dark theme) or black (light theme), will be used to generate the rest of the colors
p_config.mono_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
// Ensure base colors are in the 0..1 luminance range to avoid 8-bit integer overflow or text rendering issues.
// Some places in the editor use 8-bit integer colors.
p_config.dark_color_1 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast).clamp();
p_config.dark_color_2 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 1.5).clamp();
p_config.dark_color_3 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 2).clamp();
p_config.contrast_color_1 = p_config.base_color.lerp(p_config.mono_color, MAX(p_config.contrast, p_config.default_contrast));
p_config.contrast_color_2 = p_config.base_color.lerp(p_config.mono_color, MAX(p_config.contrast * 1.5, p_config.default_contrast * 1.5));
p_config.highlight_color = Color(p_config.accent_color.r, p_config.accent_color.g, p_config.accent_color.b, 0.275);
p_config.highlight_disabled_color = p_config.highlight_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.5);
p_config.success_color = Color(0.45, 0.95, 0.5);
p_config.warning_color = Color(1, 0.87, 0.4);
p_config.error_color = Color(1, 0.47, 0.42);
if (!p_config.dark_theme) {
// Darken some colors to be readable on a light background.
p_config.success_color = p_config.success_color.lerp(p_config.mono_color, 0.35);
p_config.warning_color = p_config.warning_color.lerp(p_config.mono_color, 0.35);
p_config.error_color = p_config.error_color.lerp(p_config.mono_color, 0.25);
}
p_theme->set_color("mono_color", EditorStringName(Editor), p_config.mono_color);
p_theme->set_color("dark_color_1", EditorStringName(Editor), p_config.dark_color_1);
p_theme->set_color("dark_color_2", EditorStringName(Editor), p_config.dark_color_2);
p_theme->set_color("dark_color_3", EditorStringName(Editor), p_config.dark_color_3);
p_theme->set_color("contrast_color_1", EditorStringName(Editor), p_config.contrast_color_1);
p_theme->set_color("contrast_color_2", EditorStringName(Editor), p_config.contrast_color_2);
p_theme->set_color("highlight_color", EditorStringName(Editor), p_config.highlight_color);
p_theme->set_color("highlight_disabled_color", EditorStringName(Editor), p_config.highlight_disabled_color);
p_theme->set_color("success_color", EditorStringName(Editor), p_config.success_color);
p_theme->set_color("warning_color", EditorStringName(Editor), p_config.warning_color);
p_theme->set_color("error_color", EditorStringName(Editor), p_config.error_color);
// Only used when the Draw Extra Borders editor setting is enabled.
p_config.extra_border_color_1 = Color(0.5, 0.5, 0.5);
p_config.extra_border_color_2 = p_config.dark_theme ? Color(0.3, 0.3, 0.3) : Color(0.7, 0.7, 0.7);
p_theme->set_color("extra_border_color_1", EditorStringName(Editor), p_config.extra_border_color_1);
p_theme->set_color("extra_border_color_2", EditorStringName(Editor), p_config.extra_border_color_2);
// Font colors.
p_config.font_color = p_config.mono_color.lerp(p_config.base_color, 0.25);
p_config.font_focus_color = p_config.mono_color.lerp(p_config.base_color, 0.125);
p_config.font_hover_color = p_config.mono_color.lerp(p_config.base_color, 0.125);
p_config.font_pressed_color = p_config.accent_color;
p_config.font_hover_pressed_color = p_config.font_hover_color.lerp(p_config.accent_color, 0.74);
p_config.font_disabled_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.35);
p_config.font_readonly_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.65);
p_config.font_placeholder_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.6);
p_config.font_outline_color = Color(0, 0, 0, 0);
p_theme->set_color("font_color", EditorStringName(Editor), p_config.font_color);
p_theme->set_color("font_focus_color", EditorStringName(Editor), p_config.font_focus_color);
p_theme->set_color("font_hover_color", EditorStringName(Editor), p_config.font_hover_color);
p_theme->set_color("font_pressed_color", EditorStringName(Editor), p_config.font_pressed_color);
p_theme->set_color("font_hover_pressed_color", EditorStringName(Editor), p_config.font_hover_pressed_color);
p_theme->set_color("font_disabled_color", EditorStringName(Editor), p_config.font_disabled_color);
p_theme->set_color("font_readonly_color", EditorStringName(Editor), p_config.font_readonly_color);
p_theme->set_color("font_placeholder_color", EditorStringName(Editor), p_config.font_placeholder_color);
p_theme->set_color("font_outline_color", EditorStringName(Editor), p_config.font_outline_color);
// Icon colors.
p_config.icon_normal_color = Color(1, 1, 1);
p_config.icon_focus_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.45);
p_config.icon_focus_color.a = 1.0;
p_config.icon_hover_color = p_config.icon_focus_color;
// Make the pressed icon color overbright because icons are not completely white on a dark theme.
// On a light theme, icons are dark, so we need to modulate them with an even brighter color.
p_config.icon_pressed_color = p_config.accent_color * (p_config.dark_theme ? 1.15 : 3.5);
p_config.icon_pressed_color.a = 1.0;
p_config.icon_disabled_color = Color(p_config.icon_normal_color, 0.4);
p_theme->set_color("icon_normal_color", EditorStringName(Editor), p_config.icon_normal_color);
p_theme->set_color("icon_focus_color", EditorStringName(Editor), p_config.icon_focus_color);
p_theme->set_color("icon_hover_color", EditorStringName(Editor), p_config.icon_hover_color);
p_theme->set_color("icon_pressed_color", EditorStringName(Editor), p_config.icon_pressed_color);
p_theme->set_color("icon_disabled_color", EditorStringName(Editor), p_config.icon_disabled_color);
// Additional GUI colors.
p_config.shadow_color = Color(0, 0, 0, p_config.dark_theme ? 0.3 : 0.1);
p_config.selection_color = p_config.accent_color * Color(1, 1, 1, 0.4);
p_config.disabled_border_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.7);
p_config.disabled_bg_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.9);
p_config.separator_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.1);
p_theme->set_color("selection_color", EditorStringName(Editor), p_config.selection_color);
p_theme->set_color("disabled_border_color", EditorStringName(Editor), p_config.disabled_border_color);
p_theme->set_color("disabled_bg_color", EditorStringName(Editor), p_config.disabled_bg_color);
p_theme->set_color("separator_color", EditorStringName(Editor), p_config.separator_color);
// Additional editor colors.
p_theme->set_color("box_selection_fill_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.3));
p_theme->set_color("box_selection_stroke_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.8));
p_theme->set_color("axis_x_color", EditorStringName(Editor), Color(0.96, 0.20, 0.32));
p_theme->set_color("axis_y_color", EditorStringName(Editor), Color(0.53, 0.84, 0.01));
p_theme->set_color("axis_z_color", EditorStringName(Editor), Color(0.16, 0.55, 0.96));
p_theme->set_color("axis_w_color", EditorStringName(Editor), Color(0.55, 0.55, 0.55));
const float prop_color_saturation = p_config.accent_color.get_s() * 0.75;
const float prop_color_value = p_config.accent_color.get_v();
p_theme->set_color("property_color_x", EditorStringName(Editor), Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
p_theme->set_color("property_color_y", EditorStringName(Editor), Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
p_theme->set_color("property_color_z", EditorStringName(Editor), Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
p_theme->set_color("property_color_w", EditorStringName(Editor), Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
// Special colors for rendering methods.
p_theme->set_color("forward_plus_color", EditorStringName(Editor), Color::hex(0x5d8c3fff));
p_theme->set_color("mobile_color", EditorStringName(Editor), Color::hex(0xa5557dff));
p_theme->set_color("gl_compatibility_color", EditorStringName(Editor), Color::hex(0x5586a4ff));
if (p_config.dark_theme) {
p_theme->set_color("highend_color", EditorStringName(Editor), Color(1.0, 0.0, 0.0));
} else {
p_theme->set_color("highend_color", EditorStringName(Editor), Color::hex(0xad1128ff));
}
}
// Constants.
{
// Can't save single float in theme, so using Color.
p_theme->set_color("icon_saturation", EditorStringName(Editor), Color(p_config.icon_saturation, p_config.icon_saturation, p_config.icon_saturation));
// Controls may rely on the scale for their internal drawing logic.
p_theme->set_default_base_scale(EDSCALE);
p_theme->set_constant("scale", EditorStringName(Editor), EDSCALE);
p_theme->set_constant("thumb_size", EditorStringName(Editor), p_config.thumb_size);
p_theme->set_constant("class_icon_size", EditorStringName(Editor), p_config.class_icon_size);
p_theme->set_constant("color_picker_button_height", EditorStringName(Editor), p_config.color_picker_button_height);
p_theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), p_config.gizmo_handle_scale);
p_theme->set_constant("base_margin", EditorStringName(Editor), p_config.base_margin);
p_theme->set_constant("increased_margin", EditorStringName(Editor), p_config.increased_margin);
p_theme->set_constant("window_border_margin", EditorStringName(Editor), p_config.window_border_margin);
p_theme->set_constant("top_bar_separation", EditorStringName(Editor), p_config.top_bar_separation);
p_theme->set_constant("dark_theme", EditorStringName(Editor), p_config.dark_theme);
}
// Styleboxes.
{
// This is the basic stylebox, used as a base for most other styleboxes (through `duplicate()`).
p_config.base_style = make_flat_stylebox(p_config.base_color, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.corner_radius);
p_config.base_style->set_border_width_all(p_config.border_width);
p_config.base_style->set_border_color(p_config.base_color);
p_config.base_empty_style = make_empty_stylebox(p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
// Button styles.
{
p_config.widget_margin = Vector2(p_config.increased_margin + 2, p_config.increased_margin + 1) * EDSCALE;
p_config.button_style = p_config.base_style->duplicate();
p_config.button_style->set_content_margin_individual(p_config.widget_margin.x, p_config.widget_margin.y, p_config.widget_margin.x, p_config.widget_margin.y);
p_config.button_style->set_bg_color(p_config.dark_color_1);
if (p_config.draw_extra_borders) {
p_config.button_style->set_border_width_all(Math::round(EDSCALE));
p_config.button_style->set_border_color(p_config.extra_border_color_1);
} else {
p_config.button_style->set_border_color(p_config.dark_color_2);
}
p_config.button_style_disabled = p_config.button_style->duplicate();
p_config.button_style_disabled->set_bg_color(p_config.disabled_bg_color);
if (p_config.draw_extra_borders) {
p_config.button_style_disabled->set_border_color(p_config.extra_border_color_2);
} else {
p_config.button_style_disabled->set_border_color(p_config.disabled_border_color);
}
p_config.button_style_focus = p_config.button_style->duplicate();
p_config.button_style_focus->set_draw_center(false);
p_config.button_style_focus->set_border_width_all(Math::round(2 * MAX(1, EDSCALE)));
p_config.button_style_focus->set_border_color(p_config.accent_color);
p_config.button_style_pressed = p_config.button_style->duplicate();
p_config.button_style_pressed->set_bg_color(p_config.dark_color_1.darkened(0.125));
p_config.button_style_hover = p_config.button_style->duplicate();
p_config.button_style_hover->set_bg_color(p_config.mono_color * Color(1, 1, 1, 0.11));
if (p_config.draw_extra_borders) {
p_config.button_style_hover->set_border_color(p_config.extra_border_color_1);
} else {
p_config.button_style_hover->set_border_color(p_config.mono_color * Color(1, 1, 1, 0.05));
}
}
// Windows and popups.
{
p_config.popup_style = p_config.base_style->duplicate();
p_config.popup_style->set_content_margin_all(p_config.popup_margin);
p_config.popup_style->set_border_color(p_config.contrast_color_1);
p_config.popup_style->set_shadow_color(p_config.shadow_color);
p_config.popup_style->set_shadow_size(4 * EDSCALE);
// Popups are separate windows by default in the editor. Windows currently don't support per-pixel transparency
// in 4.0, and even if it was, it may not always work in practice (e.g. running with compositing disabled).
p_config.popup_style->set_corner_radius_all(0);
p_config.window_style = p_config.popup_style->duplicate();
p_config.window_style->set_border_color(p_config.base_color);
p_config.window_style->set_border_width(SIDE_TOP, 24 * EDSCALE);
p_config.window_style->set_expand_margin(SIDE_TOP, 24 * EDSCALE);
// Prevent corner artifacts between window title and body.
p_config.dialog_style = p_config.base_style->duplicate();
p_config.dialog_style->set_corner_radius(CORNER_TOP_LEFT, 0);
p_config.dialog_style->set_corner_radius(CORNER_TOP_RIGHT, 0);
// Prevent visible line between window title and body.
p_config.dialog_style->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);
}
// Panels.
{
p_config.panel_container_style = p_config.button_style->duplicate();
p_config.panel_container_style->set_draw_center(false);
p_config.panel_container_style->set_border_width_all(0);
// Content panel for tabs and similar containers.
// Compensate for the border.
const int content_panel_margin = p_config.base_margin * EDSCALE + p_config.border_width;
p_config.content_panel_style = p_config.base_style->duplicate();
p_config.content_panel_style->set_border_color(p_config.dark_color_3);
p_config.content_panel_style->set_border_width_all(p_config.border_width);
p_config.content_panel_style->set_border_width(Side::SIDE_TOP, 0);
p_config.content_panel_style->set_corner_radius(CORNER_TOP_LEFT, 0);
p_config.content_panel_style->set_corner_radius(CORNER_TOP_RIGHT, 0);
p_config.content_panel_style->set_content_margin_individual(content_panel_margin, 2 * EDSCALE + content_panel_margin, content_panel_margin, content_panel_margin);
// Trees and similarly inset panels.
p_config.tree_panel_style = p_config.base_style->duplicate();
// Make Trees easier to distinguish from other controls by using a darker background color.
p_config.tree_panel_style->set_bg_color(p_config.dark_color_1.lerp(p_config.dark_color_2, 0.5));
if (p_config.draw_extra_borders) {
p_config.tree_panel_style->set_border_width_all(Math::round(EDSCALE));
p_config.tree_panel_style->set_border_color(p_config.extra_border_color_2);
} else {
p_config.tree_panel_style->set_border_color(p_config.dark_color_3);
}
}
}
}
void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
// Panels.
{
// Panel.
p_theme->set_stylebox("panel", "Panel", make_flat_stylebox(p_config.dark_color_1, 6, 4, 6, 4, p_config.corner_radius));
// PanelContainer.
p_theme->set_stylebox("panel", "PanelContainer", p_config.panel_container_style);
// TooltipPanel & TooltipLabel.
{
// TooltipPanel is also used for custom tooltips, while TooltipLabel
// is only relevant for default tooltips.
p_theme->set_color("font_color", "TooltipLabel", p_config.font_hover_color);
p_theme->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0));
Ref<StyleBoxFlat> style_tooltip = p_config.popup_style->duplicate();
style_tooltip->set_shadow_size(0);
style_tooltip->set_content_margin_all(p_config.base_margin * EDSCALE * 0.5);
style_tooltip->set_bg_color(p_config.dark_color_3 * Color(0.8, 0.8, 0.8, 0.9));
style_tooltip->set_border_width_all(0);
p_theme->set_stylebox("panel", "TooltipPanel", style_tooltip);
}
// PopupPanel
p_theme->set_stylebox("panel", "PopupPanel", p_config.popup_style);
}
// Buttons.
{
// Button.
p_theme->set_stylebox("normal", "Button", p_config.button_style);
p_theme->set_stylebox("hover", "Button", p_config.button_style_hover);
p_theme->set_stylebox("pressed", "Button", p_config.button_style_pressed);
p_theme->set_stylebox("focus", "Button", p_config.button_style_focus);
p_theme->set_stylebox("disabled", "Button", p_config.button_style_disabled);
p_theme->set_color("font_color", "Button", p_config.font_color);
p_theme->set_color("font_hover_color", "Button", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "Button", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "Button", p_config.font_focus_color);
p_theme->set_color("font_pressed_color", "Button", p_config.font_pressed_color);
p_theme->set_color("font_disabled_color", "Button", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "Button", p_config.font_outline_color);
p_theme->set_color("icon_normal_color", "Button", p_config.icon_normal_color);
p_theme->set_color("icon_hover_color", "Button", p_config.icon_hover_color);
p_theme->set_color("icon_focus_color", "Button", p_config.icon_focus_color);
p_theme->set_color("icon_hover_pressed_color", "Button", p_config.icon_pressed_color);
p_theme->set_color("icon_pressed_color", "Button", p_config.icon_pressed_color);
p_theme->set_color("icon_disabled_color", "Button", p_config.icon_disabled_color);
p_theme->set_constant("h_separation", "Button", 4 * EDSCALE);
p_theme->set_constant("outline_size", "Button", 0);
// MenuButton.
p_theme->set_stylebox("normal", "MenuButton", p_config.panel_container_style);
p_theme->set_stylebox("hover", "MenuButton", p_config.button_style_hover);
p_theme->set_stylebox("pressed", "MenuButton", p_config.panel_container_style);
p_theme->set_stylebox("focus", "MenuButton", p_config.panel_container_style);
p_theme->set_stylebox("disabled", "MenuButton", p_config.panel_container_style);
p_theme->set_color("font_color", "MenuButton", p_config.font_color);
p_theme->set_color("font_hover_color", "MenuButton", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "MenuButton", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "MenuButton", p_config.font_focus_color);
p_theme->set_color("font_outline_color", "MenuButton", p_config.font_outline_color);
p_theme->set_constant("outline_size", "MenuButton", 0);
// MenuBar.
p_theme->set_stylebox("normal", "MenuBar", p_config.button_style);
p_theme->set_stylebox("hover", "MenuBar", p_config.button_style_hover);
p_theme->set_stylebox("pressed", "MenuBar", p_config.button_style_pressed);
p_theme->set_stylebox("disabled", "MenuBar", p_config.button_style_disabled);
p_theme->set_color("font_color", "MenuBar", p_config.font_color);
p_theme->set_color("font_hover_color", "MenuBar", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "MenuBar", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "MenuBar", p_config.font_focus_color);
p_theme->set_color("font_pressed_color", "MenuBar", p_config.font_pressed_color);
p_theme->set_color("font_disabled_color", "MenuBar", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "MenuBar", p_config.font_outline_color);
p_theme->set_color("icon_normal_color", "MenuBar", p_config.icon_normal_color);
p_theme->set_color("icon_hover_color", "MenuBar", p_config.icon_hover_color);
p_theme->set_color("icon_focus_color", "MenuBar", p_config.icon_focus_color);
p_theme->set_color("icon_pressed_color", "MenuBar", p_config.icon_pressed_color);
p_theme->set_color("icon_disabled_color", "MenuBar", p_config.icon_disabled_color);
p_theme->set_constant("h_separation", "MenuBar", 4 * EDSCALE);
p_theme->set_constant("outline_size", "MenuBar", 0);
// OptionButton.
{
Ref<StyleBoxFlat> option_button_focus_style = p_config.button_style_focus->duplicate();
Ref<StyleBoxFlat> option_button_normal_style = p_config.button_style->duplicate();
Ref<StyleBoxFlat> option_button_hover_style = p_config.button_style_hover->duplicate();
Ref<StyleBoxFlat> option_button_pressed_style = p_config.button_style_pressed->duplicate();
Ref<StyleBoxFlat> option_button_disabled_style = p_config.button_style_disabled->duplicate();
option_button_focus_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
option_button_normal_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
option_button_hover_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
option_button_pressed_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
option_button_disabled_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
p_theme->set_stylebox("focus", "OptionButton", option_button_focus_style);
p_theme->set_stylebox("normal", "OptionButton", p_config.button_style);
p_theme->set_stylebox("hover", "OptionButton", p_config.button_style_hover);
p_theme->set_stylebox("pressed", "OptionButton", p_config.button_style_pressed);
p_theme->set_stylebox("disabled", "OptionButton", p_config.button_style_disabled);
p_theme->set_stylebox("normal_mirrored", "OptionButton", option_button_normal_style);
p_theme->set_stylebox("hover_mirrored", "OptionButton", option_button_hover_style);
p_theme->set_stylebox("pressed_mirrored", "OptionButton", option_button_pressed_style);
p_theme->set_stylebox("disabled_mirrored", "OptionButton", option_button_disabled_style);
p_theme->set_color("font_color", "OptionButton", p_config.font_color);
p_theme->set_color("font_hover_color", "OptionButton", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "OptionButton", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "OptionButton", p_config.font_focus_color);
p_theme->set_color("font_pressed_color", "OptionButton", p_config.font_pressed_color);
p_theme->set_color("font_disabled_color", "OptionButton", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "OptionButton", p_config.font_outline_color);
p_theme->set_color("icon_normal_color", "OptionButton", p_config.icon_normal_color);
p_theme->set_color("icon_hover_color", "OptionButton", p_config.icon_hover_color);
p_theme->set_color("icon_focus_color", "OptionButton", p_config.icon_focus_color);
p_theme->set_color("icon_pressed_color", "OptionButton", p_config.icon_pressed_color);
p_theme->set_color("icon_disabled_color", "OptionButton", p_config.icon_disabled_color);
p_theme->set_icon("arrow", "OptionButton", p_theme->get_icon(SNAME("GuiOptionArrow"), EditorStringName(EditorIcons)));
p_theme->set_constant("arrow_margin", "OptionButton", p_config.widget_margin.x - 2 * EDSCALE);
p_theme->set_constant("modulate_arrow", "OptionButton", true);
p_theme->set_constant("h_separation", "OptionButton", 4 * EDSCALE);
p_theme->set_constant("outline_size", "OptionButton", 0);
}
// CheckButton.
p_theme->set_stylebox("normal", "CheckButton", p_config.panel_container_style);
p_theme->set_stylebox("pressed", "CheckButton", p_config.panel_container_style);
p_theme->set_stylebox("disabled", "CheckButton", p_config.panel_container_style);
p_theme->set_stylebox("hover", "CheckButton", p_config.panel_container_style);
p_theme->set_stylebox("hover_pressed", "CheckButton", p_config.panel_container_style);
p_theme->set_icon("checked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOn"), EditorStringName(EditorIcons)));
p_theme->set_icon("checked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOff"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("checked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnMirrored"), EditorStringName(EditorIcons)));
p_theme->set_icon("checked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffMirrored"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), EditorStringName(EditorIcons)));
p_theme->set_color("font_color", "CheckButton", p_config.font_color);
p_theme->set_color("font_hover_color", "CheckButton", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "CheckButton", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "CheckButton", p_config.font_focus_color);
p_theme->set_color("font_pressed_color", "CheckButton", p_config.font_pressed_color);
p_theme->set_color("font_disabled_color", "CheckButton", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "CheckButton", p_config.font_outline_color);
p_theme->set_color("icon_normal_color", "CheckButton", p_config.icon_normal_color);
p_theme->set_color("icon_hover_color", "CheckButton", p_config.icon_hover_color);
p_theme->set_color("icon_focus_color", "CheckButton", p_config.icon_focus_color);
p_theme->set_color("icon_pressed_color", "CheckButton", p_config.icon_pressed_color);
p_theme->set_color("icon_disabled_color", "CheckButton", p_config.icon_disabled_color);
p_theme->set_constant("h_separation", "CheckButton", 8 * EDSCALE);
p_theme->set_constant("check_v_offset", "CheckButton", 0);
p_theme->set_constant("outline_size", "CheckButton", 0);
// CheckBox.
{
Ref<StyleBoxFlat> checkbox_style = p_config.panel_container_style->duplicate();
checkbox_style->set_content_margin_all(p_config.base_margin * EDSCALE);
p_theme->set_stylebox("normal", "CheckBox", checkbox_style);
p_theme->set_stylebox("pressed", "CheckBox", checkbox_style);
p_theme->set_stylebox("disabled", "CheckBox", checkbox_style);
p_theme->set_stylebox("hover", "CheckBox", checkbox_style);
p_theme->set_stylebox("hover_pressed", "CheckBox", checkbox_style);
p_theme->set_icon("checked", "CheckBox", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
p_theme->set_icon("radio_checked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));
p_theme->set_icon("radio_unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));
p_theme->set_icon("checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("radio_checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("radio_unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));
p_theme->set_color("font_color", "CheckBox", p_config.font_color);
p_theme->set_color("font_hover_color", "CheckBox", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "CheckBox", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "CheckBox", p_config.font_focus_color);
p_theme->set_color("font_pressed_color", "CheckBox", p_config.font_pressed_color);
p_theme->set_color("font_disabled_color", "CheckBox", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "CheckBox", p_config.font_outline_color);
p_theme->set_color("icon_normal_color", "CheckBox", p_config.icon_normal_color);
p_theme->set_color("icon_hover_color", "CheckBox", p_config.icon_hover_color);
p_theme->set_color("icon_focus_color", "CheckBox", p_config.icon_focus_color);
p_theme->set_color("icon_pressed_color", "CheckBox", p_config.icon_pressed_color);
p_theme->set_color("icon_disabled_color", "CheckBox", p_config.icon_disabled_color);
p_theme->set_constant("h_separation", "CheckBox", 8 * EDSCALE);
p_theme->set_constant("check_v_offset", "CheckBox", 0);
p_theme->set_constant("outline_size", "CheckBox", 0);
}
// LinkButton.
p_theme->set_stylebox("focus", "LinkButton", p_config.base_empty_style);
p_theme->set_color("font_color", "LinkButton", p_config.font_color);
p_theme->set_color("font_hover_color", "LinkButton", p_config.font_hover_color);
p_theme->set_color("font_hover_pressed_color", "LinkButton", p_config.font_hover_pressed_color);
p_theme->set_color("font_focus_color", "LinkButton", p_config.font_focus_color);
p_theme->set_color("font_pressed_color", "LinkButton", p_config.font_pressed_color);
p_theme->set_color("font_disabled_color", "LinkButton", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "LinkButton", p_config.font_outline_color);
p_theme->set_constant("outline_size", "LinkButton", 0);
}
// Tree & ItemList.
{
Ref<StyleBoxFlat> style_tree_focus = p_config.base_style->duplicate();
style_tree_focus->set_bg_color(p_config.highlight_color);
style_tree_focus->set_border_width_all(0);
Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
const Color guide_color = p_config.mono_color * Color(1, 1, 1, 0.05);
// Tree.
{
p_theme->set_icon("checked", "Tree", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
p_theme->set_icon("checked_disabled", "Tree", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("indeterminate", "Tree", p_theme->get_icon(SNAME("GuiIndeterminate"), EditorStringName(EditorIcons)));
p_theme->set_icon("indeterminate_disabled", "Tree", p_theme->get_icon(SNAME("GuiIndeterminateDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked", "Tree", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
p_theme->set_icon("unchecked_disabled", "Tree", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
p_theme->set_icon("arrow", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));
p_theme->set_icon("arrow_collapsed", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));
p_theme->set_icon("arrow_collapsed_mirrored", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));
p_theme->set_icon("updown", "Tree", p_theme->get_icon(SNAME("GuiTreeUpdown"), EditorStringName(EditorIcons)));
p_theme->set_icon("select_arrow", "Tree", p_theme->get_icon(SNAME("GuiDropdown"), EditorStringName(EditorIcons)));
p_theme->set_stylebox("panel", "Tree", p_config.tree_panel_style);
p_theme->set_stylebox("focus", "Tree", p_config.button_style_focus);
p_theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
p_theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
p_theme->set_stylebox("custom_button_hover", "Tree", p_config.button_style);
p_theme->set_color("custom_button_font_highlight", "Tree", p_config.font_hover_color);
p_theme->set_color("font_color", "Tree", p_config.font_color);
p_theme->set_color("font_selected_color", "Tree", p_config.mono_color);
p_theme->set_color("font_disabled_color", "Tree", p_config.font_disabled_color);
p_theme->set_color("font_outline_color", "Tree", p_config.font_outline_color);
p_theme->set_color("title_button_color", "Tree", p_config.font_color);
p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);
p_theme->set_constant("v_separation", "Tree", p_config.separation_margin);
p_theme->set_constant("h_separation", "Tree", (p_config.increased_margin + 2) * EDSCALE);
p_theme->set_constant("guide_width", "Tree", p_config.border_width);
p_theme->set_constant("item_margin", "Tree", 3 * p_config.increased_margin * EDSCALE);
p_theme->set_constant("inner_item_margin_top", "Tree", p_config.separation_margin);
p_theme->set_constant("inner_item_margin_bottom", "Tree", p_config.separation_margin);
p_theme->set_constant("inner_item_margin_left", "Tree", p_config.increased_margin * EDSCALE);
p_theme->set_constant("inner_item_margin_right", "Tree", p_config.increased_margin * EDSCALE);
p_theme->set_constant("button_margin", "Tree", p_config.base_margin * EDSCALE);
p_theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
p_theme->set_constant("scroll_speed", "Tree", 12);
p_theme->set_constant("outline_size", "Tree", 0);
p_theme->set_constant("scrollbar_margin_left", "Tree", 0);
p_theme->set_constant("scrollbar_margin_top", "Tree", 0);
p_theme->set_constant("scrollbar_margin_right", "Tree", 0);
p_theme->set_constant("scrollbar_margin_bottom", "Tree", 0);
p_theme->set_constant("scrollbar_h_separation", "Tree", 1 * EDSCALE);
p_theme->set_constant("scrollbar_v_separation", "Tree", 1 * EDSCALE);
Color relationship_line_color = p_config.mono_color * Color(1, 1, 1, p_config.relationship_line_opacity);
p_theme->set_constant("draw_guides", "Tree", p_config.relationship_line_opacity < 0.01);
p_theme->set_color("guide_color", "Tree", guide_color);
int relationship_line_width = 1;
Color parent_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.45, 0.0, 1.0));
Color children_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.25, 0.0, 1.0));
p_theme->set_constant("draw_relationship_lines", "Tree", p_config.relationship_line_opacity >= 0.01);
p_theme->set_constant("relationship_line_width", "Tree", relationship_line_width);
p_theme->set_constant("parent_hl_line_width", "Tree", relationship_line_width * 2);
p_theme->set_constant("children_hl_line_width", "Tree", relationship_line_width);
p_theme->set_constant("parent_hl_line_margin", "Tree", relationship_line_width * 3);
p_theme->set_color("relationship_line_color", "Tree", relationship_line_color);
p_theme->set_color("parent_hl_line_color", "Tree", parent_line_color);
p_theme->set_color("children_hl_line_color", "Tree", children_line_color);
p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);
Ref<StyleBoxFlat> style_tree_btn = p_config.base_style->duplicate();
style_tree_btn->set_bg_color(p_config.highlight_color);
style_tree_btn->set_border_width_all(0);
p_theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
Ref<StyleBoxFlat> style_tree_hover = p_config.base_style->duplicate();
style_tree_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.4));
style_tree_hover->set_border_width_all(0);
p_theme->set_stylebox("hover", "Tree", style_tree_hover);
p_theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
p_theme->set_stylebox("selected", "Tree", style_tree_selected);
Ref<StyleBoxFlat> style_tree_cursor = p_config.base_style->duplicate();
style_tree_cursor->set_draw_center(false);
style_tree_cursor->set_border_width_all(MAX(1, p_config.border_width));
style_tree_cursor->set_border_color(p_config.contrast_color_1);
Ref<StyleBoxFlat> style_tree_title = p_config.base_style->duplicate();
style_tree_title->set_bg_color(p_config.dark_color_3);
style_tree_title->set_border_width_all(0);
p_theme->set_stylebox("cursor", "Tree", style_tree_cursor);
p_theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
p_theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
p_theme->set_stylebox("title_button_hover", "Tree", style_tree_title);