Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
godotengine
GitHub Repository: godotengine/godot
Path: blob/master/editor/themes/editor_theme_manager.cpp
9898 views
1
/**************************************************************************/
2
/* editor_theme_manager.cpp */
3
/**************************************************************************/
4
/* This file is part of: */
5
/* GODOT ENGINE */
6
/* https://godotengine.org */
7
/**************************************************************************/
8
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10
/* */
11
/* Permission is hereby granted, free of charge, to any person obtaining */
12
/* a copy of this software and associated documentation files (the */
13
/* "Software"), to deal in the Software without restriction, including */
14
/* without limitation the rights to use, copy, modify, merge, publish, */
15
/* distribute, sublicense, and/or sell copies of the Software, and to */
16
/* permit persons to whom the Software is furnished to do so, subject to */
17
/* the following conditions: */
18
/* */
19
/* The above copyright notice and this permission notice shall be */
20
/* included in all copies or substantial portions of the Software. */
21
/* */
22
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29
/**************************************************************************/
30
31
#include "editor_theme_manager.h"
32
33
#include "core/error/error_macros.h"
34
#include "core/io/resource_loader.h"
35
#include "editor/editor_string_names.h"
36
#include "editor/file_system/editor_paths.h"
37
#include "editor/settings/editor_settings.h"
38
#include "editor/themes/editor_color_map.h"
39
#include "editor/themes/editor_fonts.h"
40
#include "editor/themes/editor_icons.h"
41
#include "editor/themes/editor_scale.h"
42
#include "editor/themes/editor_theme.h"
43
#include "scene/gui/graph_edit.h"
44
#include "scene/resources/dpi_texture.h"
45
#include "scene/resources/image_texture.h"
46
#include "scene/resources/style_box_flat.h"
47
#include "scene/resources/style_box_line.h"
48
#include "scene/resources/style_box_texture.h"
49
#include "scene/resources/texture.h"
50
51
// Theme configuration.
52
53
uint32_t EditorThemeManager::ThemeConfiguration::hash() {
54
uint32_t hash = hash_murmur3_one_float(EDSCALE);
55
56
// Basic properties.
57
58
hash = hash_murmur3_one_32(preset.hash(), hash);
59
hash = hash_murmur3_one_32(spacing_preset.hash(), hash);
60
61
hash = hash_murmur3_one_32(base_color.to_rgba32(), hash);
62
hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);
63
hash = hash_murmur3_one_float(contrast, hash);
64
hash = hash_murmur3_one_float(icon_saturation, hash);
65
66
// Extra properties.
67
68
hash = hash_murmur3_one_32(base_spacing, hash);
69
hash = hash_murmur3_one_32(extra_spacing, hash);
70
hash = hash_murmur3_one_32(border_width, hash);
71
hash = hash_murmur3_one_32(corner_radius, hash);
72
73
hash = hash_murmur3_one_32((int)draw_extra_borders, hash);
74
hash = hash_murmur3_one_float(relationship_line_opacity, hash);
75
hash = hash_murmur3_one_32(thumb_size, hash);
76
hash = hash_murmur3_one_32(class_icon_size, hash);
77
hash = hash_murmur3_one_32((int)enable_touch_optimizations, hash);
78
hash = hash_murmur3_one_float(gizmo_handle_scale, hash);
79
hash = hash_murmur3_one_32(color_picker_button_height, hash);
80
hash = hash_murmur3_one_float(subresource_hue_tint, hash);
81
82
hash = hash_murmur3_one_float(default_contrast, hash);
83
84
// Generated properties.
85
86
hash = hash_murmur3_one_32((int)dark_theme, hash);
87
88
return hash;
89
}
90
91
uint32_t EditorThemeManager::ThemeConfiguration::hash_fonts() {
92
uint32_t hash = hash_murmur3_one_float(EDSCALE);
93
94
// TODO: Implement the hash based on what editor_register_fonts() uses.
95
96
return hash;
97
}
98
99
uint32_t EditorThemeManager::ThemeConfiguration::hash_icons() {
100
uint32_t hash = hash_murmur3_one_float(EDSCALE);
101
102
hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);
103
hash = hash_murmur3_one_float(icon_saturation, hash);
104
105
hash = hash_murmur3_one_32(thumb_size, hash);
106
hash = hash_murmur3_one_float(gizmo_handle_scale, hash);
107
108
hash = hash_murmur3_one_32((int)dark_theme, hash);
109
110
return hash;
111
}
112
113
// Benchmarks.
114
115
int EditorThemeManager::benchmark_run = 0;
116
117
String EditorThemeManager::get_benchmark_key() {
118
if (benchmark_run == 0) {
119
return "EditorTheme (Startup)";
120
}
121
122
return vformat("EditorTheme (Run %d)", benchmark_run);
123
}
124
125
// Generation helper methods.
126
127
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) {
128
Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));
129
style->set_texture(p_texture);
130
style->set_texture_margin_individual(p_left * EDSCALE, p_top * EDSCALE, p_right * EDSCALE, p_bottom * EDSCALE);
131
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);
132
style->set_draw_center(p_draw_center);
133
return style;
134
}
135
136
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) {
137
Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));
138
style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);
139
return style;
140
}
141
142
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) {
143
Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));
144
style->set_bg_color(p_color);
145
// Adjust level of detail based on the corners' effective sizes.
146
style->set_corner_detail(Math::ceil(0.8 * p_corner_width * EDSCALE));
147
style->set_corner_radius_all(p_corner_width * EDSCALE);
148
style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);
149
// Work around issue about antialiased edges being blurrier (GH-35279).
150
style->set_anti_aliased(false);
151
return style;
152
}
153
154
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) {
155
Ref<StyleBoxLine> style(memnew(StyleBoxLine));
156
style->set_color(p_color);
157
style->set_grow_begin(p_grow_begin);
158
style->set_grow_end(p_grow_end);
159
style->set_thickness(p_thickness);
160
style->set_vertical(p_vertical);
161
return style;
162
}
163
164
// Theme generation and population routines.
165
166
Ref<EditorTheme> EditorThemeManager::_create_base_theme(const Ref<EditorTheme> &p_old_theme) {
167
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Create Base Theme");
168
169
Ref<EditorTheme> theme = memnew(EditorTheme);
170
ThemeConfiguration config = _create_theme_config(theme);
171
theme->set_generated_hash(config.hash());
172
theme->set_generated_fonts_hash(config.hash_fonts());
173
theme->set_generated_icons_hash(config.hash_icons());
174
175
print_verbose(vformat("EditorTheme: Generating new theme for the config '%d'.", theme->get_generated_hash()));
176
177
_create_shared_styles(theme, config);
178
179
// Register icons.
180
{
181
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Icons");
182
183
// External functions, see editor_icons.cpp.
184
editor_configure_icons(config.dark_theme);
185
186
// If settings are comparable to the old theme, then just copy existing icons over.
187
// Otherwise, regenerate them.
188
bool keep_old_icons = (p_old_theme.is_valid() && theme->get_generated_icons_hash() == p_old_theme->get_generated_icons_hash());
189
if (keep_old_icons) {
190
print_verbose("EditorTheme: Can keep old icons, copying.");
191
editor_copy_icons(theme, p_old_theme);
192
} else {
193
print_verbose("EditorTheme: Generating new icons.");
194
editor_register_icons(theme, config.dark_theme, config.icon_saturation, config.thumb_size, config.gizmo_handle_scale);
195
}
196
197
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Icons");
198
}
199
200
// Register fonts.
201
{
202
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Fonts");
203
204
// TODO: Check if existing font definitions from the old theme are usable and copy them.
205
206
// External function, see editor_fonts.cpp.
207
print_verbose("EditorTheme: Generating new fonts.");
208
editor_register_fonts(theme);
209
210
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Fonts");
211
}
212
213
// TODO: Check if existing style definitions from the old theme are usable and copy them.
214
215
print_verbose("EditorTheme: Generating new styles.");
216
_populate_standard_styles(theme, config);
217
_populate_editor_styles(theme, config);
218
_populate_text_editor_styles(theme, config);
219
_populate_visual_shader_styles(theme, config);
220
221
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Create Base Theme");
222
return theme;
223
}
224
225
EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(const Ref<EditorTheme> &p_theme) {
226
ThemeConfiguration config;
227
228
// Basic properties.
229
230
config.preset = EDITOR_GET("interface/theme/preset");
231
config.spacing_preset = EDITOR_GET("interface/theme/spacing_preset");
232
233
config.base_color = EDITOR_GET("interface/theme/base_color");
234
config.accent_color = EDITOR_GET("interface/theme/accent_color");
235
config.contrast = EDITOR_GET("interface/theme/contrast");
236
config.icon_saturation = EDITOR_GET("interface/theme/icon_saturation");
237
238
// Extra properties.
239
240
config.base_spacing = EDITOR_GET("interface/theme/base_spacing");
241
config.extra_spacing = EDITOR_GET("interface/theme/additional_spacing");
242
// Ensure borders are visible when using an editor scale below 100%.
243
config.border_width = CLAMP((int)EDITOR_GET("interface/theme/border_size"), 0, 2) * MAX(1, EDSCALE);
244
config.corner_radius = CLAMP((int)EDITOR_GET("interface/theme/corner_radius"), 0, 6);
245
246
config.draw_extra_borders = EDITOR_GET("interface/theme/draw_extra_borders");
247
config.relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");
248
config.thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");
249
config.class_icon_size = 16 * EDSCALE;
250
config.enable_touch_optimizations = EDITOR_GET("interface/touchscreen/enable_touch_optimizations");
251
config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");
252
config.color_picker_button_height = 28 * EDSCALE;
253
config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");
254
255
config.default_contrast = 0.3; // Make sure to keep this in sync with the editor settings definition.
256
257
// Handle main theme preset.
258
{
259
const bool follow_system_theme = EDITOR_GET("interface/theme/follow_system_theme");
260
const bool use_system_accent_color = EDITOR_GET("interface/theme/use_system_accent_color");
261
DisplayServer *display_server = DisplayServer::get_singleton();
262
Color system_base_color = display_server->get_base_color();
263
Color system_accent_color = display_server->get_accent_color();
264
265
if (follow_system_theme) {
266
String dark_theme = "Default";
267
String light_theme = "Light";
268
269
config.preset = light_theme; // Assume light theme if we can't detect system theme attributes.
270
271
if (system_base_color == Color(0, 0, 0, 0)) {
272
if (display_server->is_dark_mode_supported() && display_server->is_dark_mode()) {
273
config.preset = dark_theme;
274
}
275
} else {
276
if (system_base_color.get_luminance() < 0.5) {
277
config.preset = dark_theme;
278
}
279
}
280
}
281
282
if (config.preset != "Custom") {
283
Color preset_accent_color;
284
Color preset_base_color;
285
float preset_contrast = 0;
286
bool preset_draw_extra_borders = false;
287
288
// Please use alphabetical order if you're adding a new theme here.
289
if (config.preset == "Breeze Dark") {
290
preset_accent_color = Color(0.26, 0.76, 1.00);
291
preset_base_color = Color(0.24, 0.26, 0.28);
292
preset_contrast = config.default_contrast;
293
} else if (config.preset == "Godot 2") {
294
preset_accent_color = Color(0.53, 0.67, 0.89);
295
preset_base_color = Color(0.24, 0.23, 0.27);
296
preset_contrast = config.default_contrast;
297
} else if (config.preset == "Gray") {
298
preset_accent_color = Color(0.44, 0.73, 0.98);
299
preset_base_color = Color(0.24, 0.24, 0.24);
300
preset_contrast = config.default_contrast;
301
} else if (config.preset == "Light") {
302
preset_accent_color = Color(0.18, 0.50, 1.00);
303
preset_base_color = Color(0.9, 0.9, 0.9);
304
// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
305
preset_contrast = -0.06;
306
} else if (config.preset == "Solarized (Dark)") {
307
preset_accent_color = Color(0.15, 0.55, 0.82);
308
preset_base_color = Color(0.03, 0.21, 0.26);
309
preset_contrast = 0.23;
310
} else if (config.preset == "Solarized (Light)") {
311
preset_accent_color = Color(0.15, 0.55, 0.82);
312
preset_base_color = Color(0.89, 0.86, 0.79);
313
// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".
314
preset_contrast = -0.06;
315
} else if (config.preset == "Black (OLED)") {
316
preset_accent_color = Color(0.45, 0.75, 1.0);
317
preset_base_color = Color(0, 0, 0);
318
// The contrast rate value is irrelevant on a fully black theme.
319
preset_contrast = 0.0;
320
preset_draw_extra_borders = true;
321
} else { // Default
322
preset_accent_color = Color(0.44, 0.73, 0.98);
323
preset_base_color = Color(0.21, 0.24, 0.29);
324
preset_contrast = config.default_contrast;
325
}
326
327
config.accent_color = preset_accent_color;
328
config.base_color = preset_base_color;
329
config.contrast = preset_contrast;
330
config.draw_extra_borders = preset_draw_extra_borders;
331
332
EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", config.accent_color);
333
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", config.base_color);
334
EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", config.contrast);
335
EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", config.draw_extra_borders);
336
}
337
338
if (follow_system_theme && system_base_color != Color(0, 0, 0, 0)) {
339
config.base_color = system_base_color;
340
config.preset = "Custom";
341
}
342
343
if (use_system_accent_color && system_accent_color != Color(0, 0, 0, 0)) {
344
config.accent_color = system_accent_color;
345
config.preset = "Custom";
346
}
347
348
// Enforce values in case they were adjusted or overridden.
349
EditorSettings::get_singleton()->set_manually("interface/theme/preset", config.preset);
350
EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", config.accent_color);
351
EditorSettings::get_singleton()->set_manually("interface/theme/base_color", config.base_color);
352
EditorSettings::get_singleton()->set_manually("interface/theme/contrast", config.contrast);
353
EditorSettings::get_singleton()->set_manually("interface/theme/draw_extra_borders", config.draw_extra_borders);
354
}
355
356
// Handle theme spacing preset.
357
{
358
if (config.spacing_preset != "Custom") {
359
int preset_base_spacing = 0;
360
int preset_extra_spacing = 0;
361
Size2 preset_dialogs_buttons_min_size;
362
363
if (config.spacing_preset == "Compact") {
364
preset_base_spacing = 0;
365
preset_extra_spacing = 4;
366
preset_dialogs_buttons_min_size = Size2(90, 26);
367
} else if (config.spacing_preset == "Spacious") {
368
preset_base_spacing = 6;
369
preset_extra_spacing = 2;
370
preset_dialogs_buttons_min_size = Size2(112, 36);
371
} else { // Default
372
preset_base_spacing = 4;
373
preset_extra_spacing = 0;
374
preset_dialogs_buttons_min_size = Size2(105, 34);
375
}
376
377
config.base_spacing = preset_base_spacing;
378
config.extra_spacing = preset_extra_spacing;
379
config.dialogs_buttons_min_size = preset_dialogs_buttons_min_size;
380
381
EditorSettings::get_singleton()->set_initial_value("interface/theme/base_spacing", config.base_spacing);
382
EditorSettings::get_singleton()->set_initial_value("interface/theme/additional_spacing", config.extra_spacing);
383
}
384
385
// Enforce values in case they were adjusted or overridden.
386
EditorSettings::get_singleton()->set_manually("interface/theme/spacing_preset", config.spacing_preset);
387
EditorSettings::get_singleton()->set_manually("interface/theme/base_spacing", config.base_spacing);
388
EditorSettings::get_singleton()->set_manually("interface/theme/additional_spacing", config.extra_spacing);
389
}
390
391
// Generated properties.
392
393
config.dark_theme = is_dark_theme();
394
395
config.base_margin = config.base_spacing;
396
config.increased_margin = config.base_spacing + config.extra_spacing;
397
config.separation_margin = (config.base_spacing + config.extra_spacing / 2) * EDSCALE;
398
config.popup_margin = config.base_margin * 2.4 * EDSCALE;
399
// Make sure content doesn't stick to window decorations; this can be fixed in future with layout changes.
400
config.window_border_margin = MAX(1, config.base_margin * 2);
401
config.top_bar_separation = config.base_margin * 2 * EDSCALE;
402
403
// Force the v_separation to be even so that the spacing on top and bottom is even.
404
// If the vsep is odd and cannot be split into 2 even groups (of pixels), then it will be lopsided.
405
// We add 2 to the vsep to give it some extra spacing which looks a bit more modern (see Windows, for example).
406
const int separation_base = config.increased_margin + 6;
407
config.forced_even_separation = separation_base + (separation_base % 2);
408
409
return config;
410
}
411
412
void EditorThemeManager::_create_shared_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
413
// Colors.
414
{
415
// Base colors.
416
417
p_theme->set_color("base_color", EditorStringName(Editor), p_config.base_color);
418
p_theme->set_color("accent_color", EditorStringName(Editor), p_config.accent_color);
419
420
// White (dark theme) or black (light theme), will be used to generate the rest of the colors
421
p_config.mono_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
422
423
// Ensure base colors are in the 0..1 luminance range to avoid 8-bit integer overflow or text rendering issues.
424
// Some places in the editor use 8-bit integer colors.
425
p_config.dark_color_1 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast).clamp();
426
p_config.dark_color_2 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 1.5).clamp();
427
p_config.dark_color_3 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 2).clamp();
428
429
p_config.contrast_color_1 = p_config.base_color.lerp(p_config.mono_color, MAX(p_config.contrast, p_config.default_contrast));
430
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));
431
432
p_config.highlight_color = Color(p_config.accent_color.r, p_config.accent_color.g, p_config.accent_color.b, 0.275);
433
p_config.highlight_disabled_color = p_config.highlight_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.5);
434
435
p_config.success_color = Color(0.45, 0.95, 0.5);
436
p_config.warning_color = Color(1, 0.87, 0.4);
437
p_config.error_color = Color(1, 0.47, 0.42);
438
if (!p_config.dark_theme) {
439
// Darken some colors to be readable on a light background.
440
p_config.success_color = p_config.success_color.lerp(p_config.mono_color, 0.35);
441
p_config.warning_color = Color(0.82, 0.56, 0.1);
442
p_config.error_color = Color(0.8, 0.22, 0.22);
443
}
444
445
p_theme->set_color("mono_color", EditorStringName(Editor), p_config.mono_color);
446
p_theme->set_color("dark_color_1", EditorStringName(Editor), p_config.dark_color_1);
447
p_theme->set_color("dark_color_2", EditorStringName(Editor), p_config.dark_color_2);
448
p_theme->set_color("dark_color_3", EditorStringName(Editor), p_config.dark_color_3);
449
p_theme->set_color("contrast_color_1", EditorStringName(Editor), p_config.contrast_color_1);
450
p_theme->set_color("contrast_color_2", EditorStringName(Editor), p_config.contrast_color_2);
451
p_theme->set_color("highlight_color", EditorStringName(Editor), p_config.highlight_color);
452
p_theme->set_color("highlight_disabled_color", EditorStringName(Editor), p_config.highlight_disabled_color);
453
p_theme->set_color("success_color", EditorStringName(Editor), p_config.success_color);
454
p_theme->set_color("warning_color", EditorStringName(Editor), p_config.warning_color);
455
p_theme->set_color("error_color", EditorStringName(Editor), p_config.error_color);
456
#ifndef DISABLE_DEPRECATED // Used before 4.3.
457
p_theme->set_color("disabled_highlight_color", EditorStringName(Editor), p_config.highlight_disabled_color);
458
#endif
459
460
// Only used when the Draw Extra Borders editor setting is enabled.
461
p_config.extra_border_color_1 = Color(0.5, 0.5, 0.5);
462
p_config.extra_border_color_2 = p_config.dark_theme ? Color(0.3, 0.3, 0.3) : Color(0.7, 0.7, 0.7);
463
464
p_theme->set_color("extra_border_color_1", EditorStringName(Editor), p_config.extra_border_color_1);
465
p_theme->set_color("extra_border_color_2", EditorStringName(Editor), p_config.extra_border_color_2);
466
467
// Font colors.
468
469
p_config.font_color = p_config.mono_color.lerp(p_config.base_color, 0.25);
470
p_config.font_focus_color = p_config.mono_color.lerp(p_config.base_color, 0.125);
471
p_config.font_hover_color = p_config.mono_color.lerp(p_config.base_color, 0.125);
472
p_config.font_pressed_color = p_config.accent_color;
473
p_config.font_hover_pressed_color = p_config.font_hover_color.lerp(p_config.accent_color, 0.74);
474
p_config.font_disabled_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.35);
475
p_config.font_readonly_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.65);
476
p_config.font_placeholder_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.5);
477
p_config.font_outline_color = Color(0, 0, 0, 0);
478
479
p_theme->set_color(SceneStringName(font_color), EditorStringName(Editor), p_config.font_color);
480
p_theme->set_color("font_focus_color", EditorStringName(Editor), p_config.font_focus_color);
481
p_theme->set_color("font_hover_color", EditorStringName(Editor), p_config.font_hover_color);
482
p_theme->set_color("font_pressed_color", EditorStringName(Editor), p_config.font_pressed_color);
483
p_theme->set_color("font_hover_pressed_color", EditorStringName(Editor), p_config.font_hover_pressed_color);
484
p_theme->set_color("font_disabled_color", EditorStringName(Editor), p_config.font_disabled_color);
485
p_theme->set_color("font_readonly_color", EditorStringName(Editor), p_config.font_readonly_color);
486
p_theme->set_color("font_placeholder_color", EditorStringName(Editor), p_config.font_placeholder_color);
487
p_theme->set_color("font_outline_color", EditorStringName(Editor), p_config.font_outline_color);
488
#ifndef DISABLE_DEPRECATED // Used before 4.3.
489
p_theme->set_color("readonly_font_color", EditorStringName(Editor), p_config.font_readonly_color);
490
p_theme->set_color("disabled_font_color", EditorStringName(Editor), p_config.font_disabled_color);
491
p_theme->set_color("readonly_color", EditorStringName(Editor), p_config.font_readonly_color);
492
p_theme->set_color("highlighted_font_color", EditorStringName(Editor), p_config.font_hover_color); // Closest equivalent.
493
#endif
494
495
// Icon colors.
496
497
p_config.icon_normal_color = Color(1, 1, 1);
498
p_config.icon_focus_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.45);
499
p_config.icon_focus_color.a = 1.0;
500
p_config.icon_hover_color = p_config.icon_focus_color;
501
// Make the pressed icon color overbright because icons are not completely white on a dark theme.
502
// On a light theme, icons are dark, so we need to modulate them with an even brighter color.
503
p_config.icon_pressed_color = p_config.accent_color * (p_config.dark_theme ? 1.15 : 3.5);
504
p_config.icon_pressed_color.a = 1.0;
505
p_config.icon_disabled_color = Color(p_config.icon_normal_color, 0.4);
506
507
p_theme->set_color("icon_normal_color", EditorStringName(Editor), p_config.icon_normal_color);
508
p_theme->set_color("icon_focus_color", EditorStringName(Editor), p_config.icon_focus_color);
509
p_theme->set_color("icon_hover_color", EditorStringName(Editor), p_config.icon_hover_color);
510
p_theme->set_color("icon_pressed_color", EditorStringName(Editor), p_config.icon_pressed_color);
511
p_theme->set_color("icon_disabled_color", EditorStringName(Editor), p_config.icon_disabled_color);
512
513
// Additional GUI colors.
514
515
p_config.shadow_color = Color(0, 0, 0, p_config.dark_theme ? 0.3 : 0.1);
516
p_config.selection_color = p_config.accent_color * Color(1, 1, 1, 0.4);
517
p_config.disabled_border_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.7);
518
p_config.disabled_bg_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.9);
519
p_config.separator_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.1);
520
521
p_theme->set_color("selection_color", EditorStringName(Editor), p_config.selection_color);
522
p_theme->set_color("disabled_border_color", EditorStringName(Editor), p_config.disabled_border_color);
523
p_theme->set_color("disabled_bg_color", EditorStringName(Editor), p_config.disabled_bg_color);
524
p_theme->set_color("separator_color", EditorStringName(Editor), p_config.separator_color);
525
526
// Additional editor colors.
527
528
p_theme->set_color("box_selection_fill_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.3));
529
p_theme->set_color("box_selection_stroke_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.8));
530
531
p_theme->set_color("axis_x_color", EditorStringName(Editor), Color(0.96, 0.20, 0.32));
532
p_theme->set_color("axis_y_color", EditorStringName(Editor), Color(0.53, 0.84, 0.01));
533
p_theme->set_color("axis_z_color", EditorStringName(Editor), Color(0.16, 0.55, 0.96));
534
p_theme->set_color("axis_w_color", EditorStringName(Editor), Color(0.55, 0.55, 0.55));
535
536
const float prop_color_saturation = p_config.accent_color.get_s() * 0.75;
537
const float prop_color_value = p_config.accent_color.get_v();
538
539
p_theme->set_color("property_color_x", EditorStringName(Editor), Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
540
p_theme->set_color("property_color_y", EditorStringName(Editor), Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
541
p_theme->set_color("property_color_z", EditorStringName(Editor), Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
542
p_theme->set_color("property_color_w", EditorStringName(Editor), Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value));
543
544
// Special colors for rendering methods.
545
546
p_theme->set_color("forward_plus_color", EditorStringName(Editor), Color::hex(0x5d8c3fff));
547
p_theme->set_color("mobile_color", EditorStringName(Editor), Color::hex(0xa5557dff));
548
p_theme->set_color("gl_compatibility_color", EditorStringName(Editor), Color::hex(0x5586a4ff));
549
550
if (p_config.dark_theme) {
551
p_theme->set_color("highend_color", EditorStringName(Editor), Color(1.0, 0.0, 0.0));
552
} else {
553
p_theme->set_color("highend_color", EditorStringName(Editor), Color::hex(0xad1128ff));
554
}
555
}
556
557
// Constants.
558
{
559
// Can't save single float in theme, so using Color.
560
p_theme->set_color("icon_saturation", EditorStringName(Editor), Color(p_config.icon_saturation, p_config.icon_saturation, p_config.icon_saturation));
561
562
// Controls may rely on the scale for their internal drawing logic.
563
p_theme->set_default_base_scale(EDSCALE);
564
p_theme->set_constant("scale", EditorStringName(Editor), EDSCALE);
565
566
p_theme->set_constant("thumb_size", EditorStringName(Editor), p_config.thumb_size);
567
p_theme->set_constant("class_icon_size", EditorStringName(Editor), p_config.class_icon_size);
568
p_theme->set_constant("color_picker_button_height", EditorStringName(Editor), p_config.color_picker_button_height);
569
p_theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), p_config.gizmo_handle_scale);
570
571
p_theme->set_constant("base_margin", EditorStringName(Editor), p_config.base_margin);
572
p_theme->set_constant("increased_margin", EditorStringName(Editor), p_config.increased_margin);
573
p_theme->set_constant("window_border_margin", EditorStringName(Editor), p_config.window_border_margin);
574
p_theme->set_constant("top_bar_separation", EditorStringName(Editor), p_config.top_bar_separation);
575
576
p_theme->set_constant("dark_theme", EditorStringName(Editor), p_config.dark_theme);
577
}
578
579
// Styleboxes.
580
{
581
// This is the basic stylebox, used as a base for most other styleboxes (through `duplicate()`).
582
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);
583
p_config.base_style->set_border_width_all(p_config.border_width);
584
p_config.base_style->set_border_color(p_config.base_color);
585
586
p_config.base_empty_style = make_empty_stylebox(p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
587
588
// Button styles.
589
{
590
p_config.widget_margin = Vector2(p_config.increased_margin + 2, p_config.increased_margin + 1) * EDSCALE;
591
592
p_config.button_style = p_config.base_style->duplicate();
593
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);
594
p_config.button_style->set_bg_color(p_config.dark_color_1);
595
if (p_config.draw_extra_borders) {
596
p_config.button_style->set_border_width_all(Math::round(EDSCALE));
597
p_config.button_style->set_border_color(p_config.extra_border_color_1);
598
} else {
599
p_config.button_style->set_border_color(p_config.dark_color_2);
600
}
601
602
p_config.button_style_disabled = p_config.button_style->duplicate();
603
p_config.button_style_disabled->set_bg_color(p_config.disabled_bg_color);
604
if (p_config.draw_extra_borders) {
605
p_config.button_style_disabled->set_border_color(p_config.extra_border_color_2);
606
} else {
607
p_config.button_style_disabled->set_border_color(p_config.disabled_border_color);
608
}
609
610
p_config.button_style_focus = p_config.button_style->duplicate();
611
p_config.button_style_focus->set_draw_center(false);
612
p_config.button_style_focus->set_border_width_all(Math::round(2 * MAX(1, EDSCALE)));
613
p_config.button_style_focus->set_border_color(p_config.accent_color);
614
615
p_config.button_style_pressed = p_config.button_style->duplicate();
616
p_config.button_style_pressed->set_bg_color(p_config.dark_color_1.darkened(0.125));
617
618
p_config.button_style_hover = p_config.button_style->duplicate();
619
p_config.button_style_hover->set_bg_color(p_config.mono_color * Color(1, 1, 1, 0.11));
620
if (p_config.draw_extra_borders) {
621
p_config.button_style_hover->set_border_color(p_config.extra_border_color_1);
622
} else {
623
p_config.button_style_hover->set_border_color(p_config.mono_color * Color(1, 1, 1, 0.05));
624
}
625
}
626
627
// Windows and popups.
628
{
629
p_config.popup_style = p_config.base_style->duplicate();
630
p_config.popup_style->set_content_margin_all(p_config.popup_margin);
631
p_config.popup_style->set_border_color(p_config.contrast_color_1);
632
p_config.popup_style->set_shadow_color(p_config.shadow_color);
633
p_config.popup_style->set_shadow_size(4 * EDSCALE);
634
// Popups are separate windows by default in the editor. Windows currently don't support per-pixel transparency
635
// in 4.0, and even if it was, it may not always work in practice (e.g. running with compositing disabled).
636
p_config.popup_style->set_corner_radius_all(0);
637
638
p_config.popup_border_style = p_config.popup_style->duplicate();
639
p_config.popup_border_style->set_content_margin_all(MAX(Math::round(EDSCALE), p_config.border_width) + 2 + (p_config.base_margin * 1.5) * EDSCALE);
640
// Always display a border for popups like PopupMenus so they can be distinguished from their background.
641
p_config.popup_border_style->set_border_width_all(MAX(Math::round(EDSCALE), p_config.border_width));
642
if (p_config.draw_extra_borders) {
643
p_config.popup_border_style->set_border_color(p_config.extra_border_color_2);
644
} else {
645
p_config.popup_border_style->set_border_color(p_config.dark_color_2);
646
}
647
648
p_config.window_style = p_config.popup_style->duplicate();
649
p_config.window_style->set_border_color(p_config.base_color);
650
p_config.window_style->set_border_width(SIDE_TOP, 24 * EDSCALE);
651
p_config.window_style->set_expand_margin(SIDE_TOP, 24 * EDSCALE);
652
653
// Prevent corner artifacts between window title and body.
654
p_config.dialog_style = p_config.base_style->duplicate();
655
p_config.dialog_style->set_corner_radius(CORNER_TOP_LEFT, 0);
656
p_config.dialog_style->set_corner_radius(CORNER_TOP_RIGHT, 0);
657
p_config.dialog_style->set_content_margin_all(p_config.popup_margin);
658
// Prevent visible line between window title and body.
659
p_config.dialog_style->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);
660
}
661
662
// Panels.
663
{
664
p_config.panel_container_style = p_config.button_style->duplicate();
665
p_config.panel_container_style->set_draw_center(false);
666
p_config.panel_container_style->set_border_width_all(0);
667
668
// Content panel for tabs and similar containers.
669
670
// Compensate for the border.
671
const int content_panel_margin = p_config.base_margin * EDSCALE + p_config.border_width;
672
673
p_config.content_panel_style = p_config.base_style->duplicate();
674
p_config.content_panel_style->set_border_color(p_config.dark_color_3);
675
p_config.content_panel_style->set_border_width_all(p_config.border_width);
676
p_config.content_panel_style->set_border_width(Side::SIDE_TOP, 0);
677
p_config.content_panel_style->set_corner_radius(CORNER_TOP_LEFT, 0);
678
p_config.content_panel_style->set_corner_radius(CORNER_TOP_RIGHT, 0);
679
p_config.content_panel_style->set_content_margin_individual(content_panel_margin, 2 * EDSCALE + content_panel_margin, content_panel_margin, content_panel_margin);
680
681
// Trees and similarly inset panels.
682
683
p_config.tree_panel_style = p_config.base_style->duplicate();
684
// Make Trees easier to distinguish from other controls by using a darker background color.
685
p_config.tree_panel_style->set_bg_color(p_config.dark_color_1.lerp(p_config.dark_color_2, 0.5));
686
if (p_config.draw_extra_borders) {
687
p_config.tree_panel_style->set_border_width_all(Math::round(EDSCALE));
688
p_config.tree_panel_style->set_border_color(p_config.extra_border_color_2);
689
} else {
690
p_config.tree_panel_style->set_border_color(p_config.dark_color_3);
691
}
692
}
693
}
694
}
695
696
void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
697
// Panels.
698
{
699
// Panel.
700
p_theme->set_stylebox(SceneStringName(panel), "Panel", make_flat_stylebox(p_config.dark_color_1, 6, 4, 6, 4, p_config.corner_radius));
701
702
// PanelContainer.
703
p_theme->set_stylebox(SceneStringName(panel), "PanelContainer", p_config.panel_container_style);
704
705
// TooltipPanel & TooltipLabel.
706
{
707
// TooltipPanel is also used for custom tooltips, while TooltipLabel
708
// is only relevant for default tooltips.
709
710
p_theme->set_color(SceneStringName(font_color), "TooltipLabel", p_config.font_hover_color);
711
p_theme->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0));
712
713
Ref<StyleBoxFlat> style_tooltip = p_config.popup_style->duplicate();
714
style_tooltip->set_shadow_size(0);
715
style_tooltip->set_content_margin_all(p_config.base_margin * EDSCALE * 0.5);
716
style_tooltip->set_bg_color(p_config.dark_color_3 * Color(0.8, 0.8, 0.8, 0.9));
717
style_tooltip->set_border_width_all(0);
718
p_theme->set_stylebox(SceneStringName(panel), "TooltipPanel", style_tooltip);
719
}
720
721
// PopupPanel
722
p_theme->set_stylebox(SceneStringName(panel), "PopupPanel", p_config.popup_border_style);
723
}
724
725
// Buttons.
726
{
727
// Button.
728
729
p_theme->set_stylebox(CoreStringName(normal), "Button", p_config.button_style);
730
p_theme->set_stylebox(SceneStringName(hover), "Button", p_config.button_style_hover);
731
p_theme->set_stylebox(SceneStringName(pressed), "Button", p_config.button_style_pressed);
732
p_theme->set_stylebox("focus", "Button", p_config.button_style_focus);
733
p_theme->set_stylebox("disabled", "Button", p_config.button_style_disabled);
734
735
p_theme->set_color(SceneStringName(font_color), "Button", p_config.font_color);
736
p_theme->set_color("font_hover_color", "Button", p_config.font_hover_color);
737
p_theme->set_color("font_hover_pressed_color", "Button", p_config.font_hover_pressed_color);
738
p_theme->set_color("font_focus_color", "Button", p_config.font_focus_color);
739
p_theme->set_color("font_pressed_color", "Button", p_config.font_pressed_color);
740
p_theme->set_color("font_disabled_color", "Button", p_config.font_disabled_color);
741
p_theme->set_color("font_outline_color", "Button", p_config.font_outline_color);
742
743
p_theme->set_color("icon_normal_color", "Button", p_config.icon_normal_color);
744
p_theme->set_color("icon_hover_color", "Button", p_config.icon_hover_color);
745
p_theme->set_color("icon_focus_color", "Button", p_config.icon_focus_color);
746
p_theme->set_color("icon_hover_pressed_color", "Button", p_config.icon_pressed_color);
747
p_theme->set_color("icon_pressed_color", "Button", p_config.icon_pressed_color);
748
p_theme->set_color("icon_disabled_color", "Button", p_config.icon_disabled_color);
749
750
p_theme->set_constant("h_separation", "Button", 4 * EDSCALE);
751
p_theme->set_constant("outline_size", "Button", 0);
752
753
p_theme->set_constant("align_to_largest_stylebox", "Button", 1); // Enabled.
754
755
// MenuButton.
756
757
p_theme->set_stylebox(CoreStringName(normal), "MenuButton", p_config.panel_container_style);
758
p_theme->set_stylebox(SceneStringName(hover), "MenuButton", p_config.button_style_hover);
759
p_theme->set_stylebox(SceneStringName(pressed), "MenuButton", p_config.panel_container_style);
760
p_theme->set_stylebox("focus", "MenuButton", p_config.panel_container_style);
761
p_theme->set_stylebox("disabled", "MenuButton", p_config.panel_container_style);
762
763
p_theme->set_color(SceneStringName(font_color), "MenuButton", p_config.font_color);
764
p_theme->set_color("font_hover_color", "MenuButton", p_config.font_hover_color);
765
p_theme->set_color("font_hover_pressed_color", "MenuButton", p_config.font_hover_pressed_color);
766
p_theme->set_color("font_focus_color", "MenuButton", p_config.font_focus_color);
767
p_theme->set_color("font_outline_color", "MenuButton", p_config.font_outline_color);
768
769
p_theme->set_constant("outline_size", "MenuButton", 0);
770
771
// MenuBar.
772
773
p_theme->set_stylebox(CoreStringName(normal), "MenuBar", p_config.button_style);
774
p_theme->set_stylebox(SceneStringName(hover), "MenuBar", p_config.button_style_hover);
775
p_theme->set_stylebox(SceneStringName(pressed), "MenuBar", p_config.button_style_pressed);
776
p_theme->set_stylebox("disabled", "MenuBar", p_config.button_style_disabled);
777
778
p_theme->set_color(SceneStringName(font_color), "MenuBar", p_config.font_color);
779
p_theme->set_color("font_hover_color", "MenuBar", p_config.font_hover_color);
780
p_theme->set_color("font_hover_pressed_color", "MenuBar", p_config.font_hover_pressed_color);
781
p_theme->set_color("font_focus_color", "MenuBar", p_config.font_focus_color);
782
p_theme->set_color("font_pressed_color", "MenuBar", p_config.font_pressed_color);
783
p_theme->set_color("font_disabled_color", "MenuBar", p_config.font_disabled_color);
784
p_theme->set_color("font_outline_color", "MenuBar", p_config.font_outline_color);
785
786
p_theme->set_color("icon_normal_color", "MenuBar", p_config.icon_normal_color);
787
p_theme->set_color("icon_hover_color", "MenuBar", p_config.icon_hover_color);
788
p_theme->set_color("icon_focus_color", "MenuBar", p_config.icon_focus_color);
789
p_theme->set_color("icon_pressed_color", "MenuBar", p_config.icon_pressed_color);
790
p_theme->set_color("icon_disabled_color", "MenuBar", p_config.icon_disabled_color);
791
792
p_theme->set_constant("h_separation", "MenuBar", 4 * EDSCALE);
793
p_theme->set_constant("outline_size", "MenuBar", 0);
794
795
// OptionButton.
796
{
797
Ref<StyleBoxFlat> option_button_focus_style = p_config.button_style_focus->duplicate();
798
Ref<StyleBoxFlat> option_button_normal_style = p_config.button_style->duplicate();
799
Ref<StyleBoxFlat> option_button_hover_style = p_config.button_style_hover->duplicate();
800
Ref<StyleBoxFlat> option_button_pressed_style = p_config.button_style_pressed->duplicate();
801
Ref<StyleBoxFlat> option_button_disabled_style = p_config.button_style_disabled->duplicate();
802
803
option_button_focus_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
804
option_button_normal_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
805
option_button_hover_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
806
option_button_pressed_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
807
option_button_disabled_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);
808
809
p_theme->set_stylebox("focus", "OptionButton", option_button_focus_style);
810
p_theme->set_stylebox(CoreStringName(normal), "OptionButton", p_config.button_style);
811
p_theme->set_stylebox(SceneStringName(hover), "OptionButton", p_config.button_style_hover);
812
p_theme->set_stylebox(SceneStringName(pressed), "OptionButton", p_config.button_style_pressed);
813
p_theme->set_stylebox("disabled", "OptionButton", p_config.button_style_disabled);
814
815
p_theme->set_stylebox("normal_mirrored", "OptionButton", option_button_normal_style);
816
p_theme->set_stylebox("hover_mirrored", "OptionButton", option_button_hover_style);
817
p_theme->set_stylebox("pressed_mirrored", "OptionButton", option_button_pressed_style);
818
p_theme->set_stylebox("disabled_mirrored", "OptionButton", option_button_disabled_style);
819
820
p_theme->set_color(SceneStringName(font_color), "OptionButton", p_config.font_color);
821
p_theme->set_color("font_hover_color", "OptionButton", p_config.font_hover_color);
822
p_theme->set_color("font_hover_pressed_color", "OptionButton", p_config.font_hover_pressed_color);
823
p_theme->set_color("font_focus_color", "OptionButton", p_config.font_focus_color);
824
p_theme->set_color("font_pressed_color", "OptionButton", p_config.font_pressed_color);
825
p_theme->set_color("font_disabled_color", "OptionButton", p_config.font_disabled_color);
826
p_theme->set_color("font_outline_color", "OptionButton", p_config.font_outline_color);
827
828
p_theme->set_color("icon_normal_color", "OptionButton", p_config.icon_normal_color);
829
p_theme->set_color("icon_hover_color", "OptionButton", p_config.icon_hover_color);
830
p_theme->set_color("icon_focus_color", "OptionButton", p_config.icon_focus_color);
831
p_theme->set_color("icon_pressed_color", "OptionButton", p_config.icon_pressed_color);
832
p_theme->set_color("icon_disabled_color", "OptionButton", p_config.icon_disabled_color);
833
834
p_theme->set_icon("arrow", "OptionButton", p_theme->get_icon(SNAME("GuiOptionArrow"), EditorStringName(EditorIcons)));
835
p_theme->set_constant("arrow_margin", "OptionButton", p_config.widget_margin.x - 2 * EDSCALE);
836
p_theme->set_constant("modulate_arrow", "OptionButton", true);
837
p_theme->set_constant("h_separation", "OptionButton", 4 * EDSCALE);
838
p_theme->set_constant("outline_size", "OptionButton", 0);
839
}
840
841
// CheckButton.
842
843
p_theme->set_stylebox(CoreStringName(normal), "CheckButton", p_config.panel_container_style);
844
p_theme->set_stylebox(SceneStringName(pressed), "CheckButton", p_config.panel_container_style);
845
p_theme->set_stylebox("disabled", "CheckButton", p_config.panel_container_style);
846
p_theme->set_stylebox(SceneStringName(hover), "CheckButton", p_config.panel_container_style);
847
p_theme->set_stylebox("hover_pressed", "CheckButton", p_config.panel_container_style);
848
849
p_theme->set_icon("checked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOn"), EditorStringName(EditorIcons)));
850
p_theme->set_icon("checked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabled"), EditorStringName(EditorIcons)));
851
p_theme->set_icon("unchecked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOff"), EditorStringName(EditorIcons)));
852
p_theme->set_icon("unchecked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabled"), EditorStringName(EditorIcons)));
853
854
p_theme->set_icon("checked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnMirrored"), EditorStringName(EditorIcons)));
855
p_theme->set_icon("checked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), EditorStringName(EditorIcons)));
856
p_theme->set_icon("unchecked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffMirrored"), EditorStringName(EditorIcons)));
857
p_theme->set_icon("unchecked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), EditorStringName(EditorIcons)));
858
859
p_theme->set_color(SceneStringName(font_color), "CheckButton", p_config.font_color);
860
p_theme->set_color("font_hover_color", "CheckButton", p_config.font_hover_color);
861
p_theme->set_color("font_hover_pressed_color", "CheckButton", p_config.font_hover_pressed_color);
862
p_theme->set_color("font_focus_color", "CheckButton", p_config.font_focus_color);
863
p_theme->set_color("font_pressed_color", "CheckButton", p_config.font_pressed_color);
864
p_theme->set_color("font_disabled_color", "CheckButton", p_config.font_disabled_color);
865
p_theme->set_color("font_outline_color", "CheckButton", p_config.font_outline_color);
866
867
p_theme->set_color("icon_normal_color", "CheckButton", p_config.icon_normal_color);
868
p_theme->set_color("icon_hover_color", "CheckButton", p_config.icon_hover_color);
869
p_theme->set_color("icon_focus_color", "CheckButton", p_config.icon_focus_color);
870
p_theme->set_color("icon_pressed_color", "CheckButton", p_config.icon_pressed_color);
871
p_theme->set_color("icon_disabled_color", "CheckButton", p_config.icon_disabled_color);
872
873
p_theme->set_constant("h_separation", "CheckButton", 8 * EDSCALE);
874
p_theme->set_constant("check_v_offset", "CheckButton", 0);
875
p_theme->set_constant("outline_size", "CheckButton", 0);
876
877
// CheckBox.
878
{
879
Ref<StyleBoxFlat> checkbox_style = p_config.panel_container_style->duplicate();
880
881
p_theme->set_stylebox(CoreStringName(normal), "CheckBox", checkbox_style);
882
p_theme->set_stylebox(SceneStringName(pressed), "CheckBox", checkbox_style);
883
p_theme->set_stylebox("disabled", "CheckBox", checkbox_style);
884
p_theme->set_stylebox(SceneStringName(hover), "CheckBox", checkbox_style);
885
p_theme->set_stylebox("hover_pressed", "CheckBox", checkbox_style);
886
p_theme->set_icon("checked", "CheckBox", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
887
p_theme->set_icon("unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
888
p_theme->set_icon("radio_checked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));
889
p_theme->set_icon("radio_unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));
890
p_theme->set_icon("checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
891
p_theme->set_icon("unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
892
p_theme->set_icon("radio_checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));
893
p_theme->set_icon("radio_unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));
894
895
p_theme->set_color(SceneStringName(font_color), "CheckBox", p_config.font_color);
896
p_theme->set_color("font_hover_color", "CheckBox", p_config.font_hover_color);
897
p_theme->set_color("font_hover_pressed_color", "CheckBox", p_config.font_hover_pressed_color);
898
p_theme->set_color("font_focus_color", "CheckBox", p_config.font_focus_color);
899
p_theme->set_color("font_pressed_color", "CheckBox", p_config.font_pressed_color);
900
p_theme->set_color("font_disabled_color", "CheckBox", p_config.font_disabled_color);
901
p_theme->set_color("font_outline_color", "CheckBox", p_config.font_outline_color);
902
903
p_theme->set_color("icon_normal_color", "CheckBox", p_config.icon_normal_color);
904
p_theme->set_color("icon_hover_color", "CheckBox", p_config.icon_hover_color);
905
p_theme->set_color("icon_focus_color", "CheckBox", p_config.icon_focus_color);
906
p_theme->set_color("icon_pressed_color", "CheckBox", p_config.icon_pressed_color);
907
p_theme->set_color("icon_disabled_color", "CheckBox", p_config.icon_disabled_color);
908
909
p_theme->set_constant("h_separation", "CheckBox", 8 * EDSCALE);
910
p_theme->set_constant("check_v_offset", "CheckBox", 0);
911
p_theme->set_constant("outline_size", "CheckBox", 0);
912
}
913
914
// LinkButton.
915
916
p_theme->set_stylebox("focus", "LinkButton", p_config.base_empty_style);
917
p_theme->set_color(SceneStringName(font_color), "LinkButton", p_config.font_color);
918
p_theme->set_color("font_hover_color", "LinkButton", p_config.font_hover_color);
919
p_theme->set_color("font_hover_pressed_color", "LinkButton", p_config.font_hover_pressed_color);
920
p_theme->set_color("font_focus_color", "LinkButton", p_config.font_focus_color);
921
p_theme->set_color("font_pressed_color", "LinkButton", p_config.font_pressed_color);
922
p_theme->set_color("font_disabled_color", "LinkButton", p_config.font_disabled_color);
923
p_theme->set_color("font_outline_color", "LinkButton", p_config.font_outline_color);
924
925
p_theme->set_constant("outline_size", "LinkButton", 0);
926
}
927
928
// Tree & ItemList.
929
{
930
Ref<StyleBoxFlat> style_tree_focus = p_config.base_style->duplicate();
931
style_tree_focus->set_bg_color(p_config.highlight_color);
932
style_tree_focus->set_border_width_all(0);
933
934
Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();
935
936
const Color guide_color = p_config.mono_color * Color(1, 1, 1, 0.05);
937
938
// Tree.
939
{
940
p_theme->set_icon("checked", "Tree", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
941
p_theme->set_icon("checked_disabled", "Tree", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
942
p_theme->set_icon("indeterminate", "Tree", p_theme->get_icon(SNAME("GuiIndeterminate"), EditorStringName(EditorIcons)));
943
p_theme->set_icon("indeterminate_disabled", "Tree", p_theme->get_icon(SNAME("GuiIndeterminateDisabled"), EditorStringName(EditorIcons)));
944
p_theme->set_icon("unchecked", "Tree", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
945
p_theme->set_icon("unchecked_disabled", "Tree", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
946
p_theme->set_icon("arrow", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));
947
p_theme->set_icon("arrow_collapsed", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));
948
p_theme->set_icon("arrow_collapsed_mirrored", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));
949
p_theme->set_icon("updown", "Tree", p_theme->get_icon(SNAME("GuiTreeUpdown"), EditorStringName(EditorIcons)));
950
p_theme->set_icon("select_arrow", "Tree", p_theme->get_icon(SNAME("GuiDropdown"), EditorStringName(EditorIcons)));
951
952
p_theme->set_stylebox(SceneStringName(panel), "Tree", p_config.tree_panel_style);
953
p_theme->set_stylebox("focus", "Tree", p_config.button_style_focus);
954
p_theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());
955
p_theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());
956
p_theme->set_stylebox("custom_button_hover", "Tree", p_config.button_style);
957
958
p_theme->set_color("custom_button_font_highlight", "Tree", p_config.font_hover_color);
959
p_theme->set_color(SceneStringName(font_color), "Tree", p_config.font_color);
960
p_theme->set_color("font_hovered_color", "Tree", p_config.mono_color);
961
p_theme->set_color("font_hovered_dimmed_color", "Tree", p_config.font_color);
962
p_theme->set_color("font_hovered_selected_color", "Tree", p_config.mono_color);
963
p_theme->set_color("font_selected_color", "Tree", p_config.mono_color);
964
p_theme->set_color("font_disabled_color", "Tree", p_config.font_disabled_color);
965
p_theme->set_color("font_outline_color", "Tree", p_config.font_outline_color);
966
p_theme->set_color("title_button_color", "Tree", p_config.font_color);
967
p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);
968
969
p_theme->set_constant("v_separation", "Tree", p_config.separation_margin);
970
p_theme->set_constant("h_separation", "Tree", (p_config.increased_margin + 2) * EDSCALE);
971
p_theme->set_constant("guide_width", "Tree", p_config.border_width);
972
p_theme->set_constant("item_margin", "Tree", MAX(3 * p_config.increased_margin * EDSCALE, 12 * EDSCALE));
973
p_theme->set_constant("inner_item_margin_top", "Tree", p_config.separation_margin);
974
p_theme->set_constant("inner_item_margin_bottom", "Tree", p_config.separation_margin);
975
p_theme->set_constant("inner_item_margin_left", "Tree", p_config.increased_margin * EDSCALE);
976
p_theme->set_constant("inner_item_margin_right", "Tree", p_config.increased_margin * EDSCALE);
977
p_theme->set_constant("button_margin", "Tree", p_config.base_margin * EDSCALE);
978
p_theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);
979
p_theme->set_constant("scroll_speed", "Tree", 12);
980
p_theme->set_constant("outline_size", "Tree", 0);
981
p_theme->set_constant("scrollbar_margin_left", "Tree", 0);
982
p_theme->set_constant("scrollbar_margin_top", "Tree", 0);
983
p_theme->set_constant("scrollbar_margin_right", "Tree", 0);
984
p_theme->set_constant("scrollbar_margin_bottom", "Tree", 0);
985
p_theme->set_constant("scrollbar_h_separation", "Tree", 1 * EDSCALE);
986
p_theme->set_constant("scrollbar_v_separation", "Tree", 1 * EDSCALE);
987
988
Color relationship_line_color = p_config.mono_color * Color(1, 1, 1, p_config.relationship_line_opacity);
989
990
p_theme->set_constant("draw_guides", "Tree", p_config.relationship_line_opacity < 0.01);
991
p_theme->set_color("guide_color", "Tree", guide_color);
992
993
int relationship_line_width = 1;
994
Color parent_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.45, 0.0, 1.0));
995
Color children_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.25, 0.0, 1.0));
996
997
p_theme->set_constant("draw_relationship_lines", "Tree", p_config.relationship_line_opacity >= 0.01);
998
p_theme->set_constant("relationship_line_width", "Tree", relationship_line_width);
999
p_theme->set_constant("parent_hl_line_width", "Tree", relationship_line_width * 2);
1000
p_theme->set_constant("children_hl_line_width", "Tree", relationship_line_width);
1001
p_theme->set_constant("parent_hl_line_margin", "Tree", relationship_line_width * 3);
1002
p_theme->set_color("relationship_line_color", "Tree", relationship_line_color);
1003
p_theme->set_color("parent_hl_line_color", "Tree", parent_line_color);
1004
p_theme->set_color("children_hl_line_color", "Tree", children_line_color);
1005
p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);
1006
1007
Ref<StyleBoxFlat> style_tree_btn = p_config.base_style->duplicate();
1008
style_tree_btn->set_bg_color(p_config.highlight_color);
1009
style_tree_btn->set_border_width_all(0);
1010
p_theme->set_stylebox("button_pressed", "Tree", style_tree_btn);
1011
1012
Ref<StyleBoxFlat> style_tree_hover = p_config.base_style->duplicate();
1013
style_tree_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.4));
1014
style_tree_hover->set_border_width_all(0);
1015
p_theme->set_stylebox("hovered", "Tree", style_tree_hover);
1016
p_theme->set_stylebox("button_hover", "Tree", style_tree_hover);
1017
1018
Ref<StyleBoxFlat> style_tree_hover_dimmed = p_config.base_style->duplicate();
1019
style_tree_hover_dimmed->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.2));
1020
style_tree_hover_dimmed->set_border_width_all(0);
1021
p_theme->set_stylebox("hovered_dimmed", "Tree", style_tree_hover_dimmed);
1022
1023
Ref<StyleBoxFlat> style_tree_hover_selected = style_tree_selected->duplicate();
1024
style_tree_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));
1025
style_tree_hover_selected->set_border_width_all(0);
1026
1027
p_theme->set_stylebox("hovered_selected", "Tree", style_tree_hover_selected);
1028
p_theme->set_stylebox("hovered_selected_focus", "Tree", style_tree_hover_selected);
1029
1030
p_theme->set_stylebox("selected_focus", "Tree", style_tree_focus);
1031
p_theme->set_stylebox("selected", "Tree", style_tree_selected);
1032
1033
Ref<StyleBoxFlat> style_tree_cursor = p_config.base_style->duplicate();
1034
style_tree_cursor->set_draw_center(false);
1035
style_tree_cursor->set_border_width_all(MAX(1, p_config.border_width));
1036
style_tree_cursor->set_border_color(p_config.contrast_color_1);
1037
1038
Ref<StyleBoxFlat> style_tree_title = p_config.base_style->duplicate();
1039
style_tree_title->set_bg_color(p_config.dark_color_3);
1040
style_tree_title->set_border_width_all(0);
1041
p_theme->set_stylebox("cursor", "Tree", style_tree_cursor);
1042
p_theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);
1043
p_theme->set_stylebox("title_button_normal", "Tree", style_tree_title);
1044
p_theme->set_stylebox("title_button_hover", "Tree", style_tree_title);
1045
p_theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);
1046
}
1047
1048
// ItemList.
1049
{
1050
Ref<StyleBoxFlat> style_itemlist_bg = p_config.base_style->duplicate();
1051
style_itemlist_bg->set_content_margin_all(p_config.separation_margin);
1052
style_itemlist_bg->set_bg_color(p_config.dark_color_1);
1053
1054
if (p_config.draw_extra_borders) {
1055
style_itemlist_bg->set_border_width_all(Math::round(EDSCALE));
1056
style_itemlist_bg->set_border_color(p_config.extra_border_color_2);
1057
} else {
1058
style_itemlist_bg->set_border_width_all(p_config.border_width);
1059
style_itemlist_bg->set_border_color(p_config.dark_color_3);
1060
}
1061
1062
Ref<StyleBoxFlat> style_itemlist_cursor = p_config.base_style->duplicate();
1063
style_itemlist_cursor->set_draw_center(false);
1064
style_itemlist_cursor->set_border_width_all(MAX(1 * EDSCALE, p_config.border_width));
1065
style_itemlist_cursor->set_border_color(p_config.highlight_color);
1066
1067
Ref<StyleBoxFlat> style_itemlist_hover = style_tree_selected->duplicate();
1068
style_itemlist_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.3));
1069
style_itemlist_hover->set_border_width_all(0);
1070
1071
Ref<StyleBoxFlat> style_itemlist_hover_selected = style_tree_selected->duplicate();
1072
style_itemlist_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));
1073
style_itemlist_hover_selected->set_border_width_all(0);
1074
1075
p_theme->set_stylebox(SceneStringName(panel), "ItemList", style_itemlist_bg);
1076
p_theme->set_stylebox("focus", "ItemList", p_config.button_style_focus);
1077
p_theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);
1078
p_theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);
1079
p_theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);
1080
p_theme->set_stylebox("selected", "ItemList", style_tree_selected);
1081
p_theme->set_stylebox("hovered", "ItemList", style_itemlist_hover);
1082
p_theme->set_stylebox("hovered_selected", "ItemList", style_itemlist_hover_selected);
1083
p_theme->set_stylebox("hovered_selected_focus", "ItemList", style_itemlist_hover_selected);
1084
p_theme->set_color(SceneStringName(font_color), "ItemList", p_config.font_color);
1085
p_theme->set_color("font_hovered_color", "ItemList", p_config.mono_color);
1086
p_theme->set_color("font_hovered_selected_color", "ItemList", p_config.mono_color);
1087
p_theme->set_color("font_selected_color", "ItemList", p_config.mono_color);
1088
p_theme->set_color("font_outline_color", "ItemList", p_config.font_outline_color);
1089
p_theme->set_color("guide_color", "ItemList", Color(1, 1, 1, 0));
1090
p_theme->set_constant("v_separation", "ItemList", p_config.forced_even_separation * EDSCALE);
1091
p_theme->set_constant("h_separation", "ItemList", (p_config.increased_margin + 2) * EDSCALE);
1092
p_theme->set_constant("icon_margin", "ItemList", (p_config.increased_margin + 2) * EDSCALE);
1093
p_theme->set_constant(SceneStringName(line_separation), "ItemList", p_config.separation_margin);
1094
p_theme->set_constant("outline_size", "ItemList", 0);
1095
}
1096
}
1097
1098
// TabBar & TabContainer.
1099
{
1100
Ref<StyleBoxFlat> style_tab_base = p_config.button_style->duplicate();
1101
1102
style_tab_base->set_border_width_all(0);
1103
// Don't round the top corners to avoid creating a small blank space between the tabs and the main panel.
1104
// This also makes the top highlight look better.
1105
style_tab_base->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1106
style_tab_base->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
1107
1108
// When using a border width greater than 0, visually line up the left of the selected tab with the underlying panel.
1109
style_tab_base->set_expand_margin(SIDE_LEFT, -p_config.border_width);
1110
1111
style_tab_base->set_content_margin(SIDE_LEFT, p_config.widget_margin.x + 5 * EDSCALE);
1112
style_tab_base->set_content_margin(SIDE_RIGHT, p_config.widget_margin.x + 5 * EDSCALE);
1113
style_tab_base->set_content_margin(SIDE_BOTTOM, p_config.widget_margin.y);
1114
style_tab_base->set_content_margin(SIDE_TOP, p_config.widget_margin.y);
1115
1116
Ref<StyleBoxFlat> style_tab_selected = style_tab_base->duplicate();
1117
1118
style_tab_selected->set_bg_color(p_config.base_color);
1119
// Add a highlight line at the top of the selected tab.
1120
style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE));
1121
// Make the highlight line prominent, but not too prominent as to not be distracting.
1122
Color tab_highlight = p_config.dark_color_2.lerp(p_config.accent_color, 0.75);
1123
style_tab_selected->set_border_color(tab_highlight);
1124
style_tab_selected->set_corner_radius_all(0);
1125
1126
Ref<StyleBoxFlat> style_tab_hovered = style_tab_base->duplicate();
1127
1128
style_tab_hovered->set_bg_color(p_config.dark_color_1.lerp(p_config.base_color, 0.4));
1129
// Hovered tab has a subtle highlight between normal and selected states.
1130
style_tab_hovered->set_corner_radius_all(0);
1131
1132
Ref<StyleBoxFlat> style_tab_unselected = style_tab_base->duplicate();
1133
style_tab_unselected->set_expand_margin(SIDE_BOTTOM, 0);
1134
style_tab_unselected->set_bg_color(p_config.dark_color_1);
1135
// Add some spacing between unselected tabs to make them easier to distinguish from each other
1136
style_tab_unselected->set_border_color(Color(0, 0, 0, 0));
1137
1138
Ref<StyleBoxFlat> style_tab_disabled = style_tab_base->duplicate();
1139
style_tab_disabled->set_expand_margin(SIDE_BOTTOM, 0);
1140
style_tab_disabled->set_bg_color(p_config.disabled_bg_color);
1141
style_tab_disabled->set_border_color(p_config.disabled_bg_color);
1142
1143
Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate();
1144
1145
Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE);
1146
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1147
style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
1148
p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background);
1149
p_theme->set_stylebox(SceneStringName(panel), "TabContainer", p_config.content_panel_style);
1150
1151
p_theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);
1152
p_theme->set_stylebox("tab_hovered", "TabContainer", style_tab_hovered);
1153
p_theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);
1154
p_theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);
1155
p_theme->set_stylebox("tab_focus", "TabContainer", style_tab_focus);
1156
p_theme->set_stylebox("tab_selected", "TabBar", style_tab_selected);
1157
p_theme->set_stylebox("tab_hovered", "TabBar", style_tab_hovered);
1158
p_theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);
1159
p_theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);
1160
p_theme->set_stylebox("tab_focus", "TabBar", style_tab_focus);
1161
p_theme->set_stylebox("button_pressed", "TabBar", p_config.panel_container_style);
1162
p_theme->set_stylebox("button_highlight", "TabBar", p_config.panel_container_style);
1163
1164
p_theme->set_color("font_selected_color", "TabContainer", p_config.font_color);
1165
p_theme->set_color("font_hovered_color", "TabContainer", p_config.font_color);
1166
p_theme->set_color("font_unselected_color", "TabContainer", p_config.font_disabled_color);
1167
p_theme->set_color("font_outline_color", "TabContainer", p_config.font_outline_color);
1168
p_theme->set_color("font_selected_color", "TabBar", p_config.font_color);
1169
p_theme->set_color("font_hovered_color", "TabBar", p_config.font_color);
1170
p_theme->set_color("font_unselected_color", "TabBar", p_config.font_disabled_color);
1171
p_theme->set_color("font_outline_color", "TabBar", p_config.font_outline_color);
1172
p_theme->set_color("drop_mark_color", "TabContainer", tab_highlight);
1173
p_theme->set_color("drop_mark_color", "TabBar", tab_highlight);
1174
1175
p_theme->set_icon("menu", "TabContainer", p_theme->get_icon(SNAME("GuiTabMenu"), EditorStringName(EditorIcons)));
1176
p_theme->set_icon("menu_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiTabMenuHl"), EditorStringName(EditorIcons)));
1177
p_theme->set_icon("close", "TabBar", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
1178
p_theme->set_icon("increment", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons)));
1179
p_theme->set_icon("decrement", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons)));
1180
p_theme->set_icon("increment", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons)));
1181
p_theme->set_icon("decrement", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons)));
1182
p_theme->set_icon("increment_highlight", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons)));
1183
p_theme->set_icon("decrement_highlight", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons)));
1184
p_theme->set_icon("increment_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons)));
1185
p_theme->set_icon("decrement_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons)));
1186
p_theme->set_icon("drop_mark", "TabContainer", p_theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons)));
1187
p_theme->set_icon("drop_mark", "TabBar", p_theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons)));
1188
1189
p_theme->set_constant("side_margin", "TabContainer", 0);
1190
p_theme->set_constant("outline_size", "TabContainer", 0);
1191
p_theme->set_constant("h_separation", "TabBar", 4 * EDSCALE);
1192
p_theme->set_constant("outline_size", "TabBar", 0);
1193
}
1194
1195
// Separators.
1196
p_theme->set_stylebox("separator", "HSeparator", make_line_stylebox(p_config.separator_color, MAX(Math::round(EDSCALE), p_config.border_width)));
1197
p_theme->set_stylebox("separator", "VSeparator", make_line_stylebox(p_config.separator_color, MAX(Math::round(EDSCALE), p_config.border_width), 0, 0, true));
1198
1199
// LineEdit & TextEdit.
1200
{
1201
Ref<StyleBoxFlat> text_editor_style = p_config.button_style->duplicate();
1202
1203
// Don't round the bottom corners to make the line look sharper.
1204
text_editor_style->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1205
text_editor_style->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
1206
1207
if (p_config.draw_extra_borders) {
1208
text_editor_style->set_border_width_all(Math::round(EDSCALE));
1209
text_editor_style->set_border_color(p_config.extra_border_color_1);
1210
} else {
1211
// Add a bottom line to make LineEdits more visible, especially in sectioned inspectors
1212
// such as the Project Settings.
1213
text_editor_style->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
1214
text_editor_style->set_border_color(p_config.dark_color_2);
1215
}
1216
1217
Ref<StyleBoxFlat> text_editor_disabled_style = text_editor_style->duplicate();
1218
text_editor_disabled_style->set_border_color(p_config.disabled_border_color);
1219
text_editor_disabled_style->set_bg_color(p_config.disabled_bg_color);
1220
1221
// LineEdit.
1222
1223
p_theme->set_stylebox(CoreStringName(normal), "LineEdit", text_editor_style);
1224
p_theme->set_stylebox("focus", "LineEdit", p_config.button_style_focus);
1225
p_theme->set_stylebox("read_only", "LineEdit", text_editor_disabled_style);
1226
1227
p_theme->set_icon("clear", "LineEdit", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
1228
1229
p_theme->set_color(SceneStringName(font_color), "LineEdit", p_config.font_color);
1230
p_theme->set_color("font_selected_color", "LineEdit", p_config.mono_color);
1231
p_theme->set_color("font_uneditable_color", "LineEdit", p_config.font_readonly_color);
1232
p_theme->set_color("font_placeholder_color", "LineEdit", p_config.font_placeholder_color);
1233
p_theme->set_color("font_outline_color", "LineEdit", p_config.font_outline_color);
1234
p_theme->set_color("caret_color", "LineEdit", p_config.font_color);
1235
p_theme->set_color("selection_color", "LineEdit", p_config.selection_color);
1236
p_theme->set_color("clear_button_color", "LineEdit", p_config.font_color);
1237
p_theme->set_color("clear_button_color_pressed", "LineEdit", p_config.accent_color);
1238
1239
p_theme->set_constant("minimum_character_width", "LineEdit", 4);
1240
p_theme->set_constant("outline_size", "LineEdit", 0);
1241
p_theme->set_constant("caret_width", "LineEdit", 1);
1242
1243
// TextEdit.
1244
1245
p_theme->set_stylebox(CoreStringName(normal), "TextEdit", text_editor_style);
1246
p_theme->set_stylebox("focus", "TextEdit", p_config.button_style_focus);
1247
p_theme->set_stylebox("read_only", "TextEdit", text_editor_disabled_style);
1248
1249
p_theme->set_icon("tab", "TextEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));
1250
p_theme->set_icon("space", "TextEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));
1251
1252
p_theme->set_color(SceneStringName(font_color), "TextEdit", p_config.font_color);
1253
p_theme->set_color("font_readonly_color", "TextEdit", p_config.font_readonly_color);
1254
p_theme->set_color("font_placeholder_color", "TextEdit", p_config.font_placeholder_color);
1255
p_theme->set_color("font_outline_color", "TextEdit", p_config.font_outline_color);
1256
p_theme->set_color("caret_color", "TextEdit", p_config.font_color);
1257
p_theme->set_color("selection_color", "TextEdit", p_config.selection_color);
1258
p_theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));
1259
1260
p_theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE);
1261
p_theme->set_constant("outline_size", "TextEdit", 0);
1262
p_theme->set_constant("caret_width", "TextEdit", 1);
1263
}
1264
1265
// Containers.
1266
{
1267
p_theme->set_constant("separation", "BoxContainer", p_config.separation_margin);
1268
p_theme->set_constant("separation", "HBoxContainer", p_config.separation_margin);
1269
p_theme->set_constant("separation", "VBoxContainer", p_config.separation_margin);
1270
p_theme->set_constant("margin_left", "MarginContainer", 0);
1271
p_theme->set_constant("margin_top", "MarginContainer", 0);
1272
p_theme->set_constant("margin_right", "MarginContainer", 0);
1273
p_theme->set_constant("margin_bottom", "MarginContainer", 0);
1274
p_theme->set_constant("h_separation", "GridContainer", p_config.separation_margin);
1275
p_theme->set_constant("v_separation", "GridContainer", p_config.separation_margin);
1276
p_theme->set_constant("h_separation", "FlowContainer", p_config.separation_margin);
1277
p_theme->set_constant("v_separation", "FlowContainer", p_config.separation_margin);
1278
p_theme->set_constant("h_separation", "HFlowContainer", p_config.separation_margin);
1279
p_theme->set_constant("v_separation", "HFlowContainer", p_config.separation_margin);
1280
p_theme->set_constant("h_separation", "VFlowContainer", p_config.separation_margin);
1281
p_theme->set_constant("v_separation", "VFlowContainer", p_config.separation_margin);
1282
1283
// SplitContainer.
1284
1285
p_theme->set_icon("h_grabber", "SplitContainer", p_theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons)));
1286
p_theme->set_icon("v_grabber", "SplitContainer", p_theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons)));
1287
p_theme->set_icon("grabber", "VSplitContainer", p_theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons)));
1288
p_theme->set_icon("grabber", "HSplitContainer", p_theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons)));
1289
1290
p_theme->set_constant("separation", "SplitContainer", p_config.separation_margin);
1291
p_theme->set_constant("separation", "HSplitContainer", p_config.separation_margin);
1292
p_theme->set_constant("separation", "VSplitContainer", p_config.separation_margin);
1293
1294
p_theme->set_constant("minimum_grab_thickness", "SplitContainer", p_config.increased_margin * EDSCALE);
1295
p_theme->set_constant("minimum_grab_thickness", "HSplitContainer", p_config.increased_margin * EDSCALE);
1296
p_theme->set_constant("minimum_grab_thickness", "VSplitContainer", p_config.increased_margin * EDSCALE);
1297
1298
// GridContainer.
1299
p_theme->set_constant("v_separation", "GridContainer", Math::round(p_config.widget_margin.y - 2 * EDSCALE));
1300
1301
// FoldableContainer
1302
1303
Ref<StyleBoxFlat> foldable_container_title = make_flat_stylebox(p_config.dark_color_1.darkened(0.125), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
1304
foldable_container_title->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1305
foldable_container_title->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
1306
p_theme->set_stylebox("title_panel", "FoldableContainer", foldable_container_title);
1307
Ref<StyleBoxFlat> foldable_container_hover = make_flat_stylebox(p_config.dark_color_1.lerp(p_config.base_color, 0.4), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
1308
foldable_container_hover->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1309
foldable_container_hover->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
1310
p_theme->set_stylebox("title_hover_panel", "FoldableContainer", foldable_container_hover);
1311
p_theme->set_stylebox("title_collapsed_panel", "FoldableContainer", make_flat_stylebox(p_config.dark_color_1.darkened(0.125), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
1312
p_theme->set_stylebox("title_collapsed_hover_panel", "FoldableContainer", make_flat_stylebox(p_config.dark_color_1.lerp(p_config.base_color, 0.4), p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
1313
Ref<StyleBoxFlat> foldable_container_panel = make_flat_stylebox(p_config.dark_color_1, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);
1314
foldable_container_panel->set_corner_radius(CORNER_TOP_LEFT, 0);
1315
foldable_container_panel->set_corner_radius(CORNER_TOP_RIGHT, 0);
1316
p_theme->set_stylebox(SceneStringName(panel), "FoldableContainer", foldable_container_panel);
1317
p_theme->set_stylebox("focus", "FoldableContainer", p_config.button_style_focus);
1318
1319
p_theme->set_font(SceneStringName(font), "FoldableContainer", p_theme->get_font(SceneStringName(font), SNAME("HeaderSmall")));
1320
p_theme->set_font_size(SceneStringName(font_size), "FoldableContainer", p_theme->get_font_size(SceneStringName(font_size), SNAME("HeaderSmall")));
1321
1322
p_theme->set_color(SceneStringName(font_color), "FoldableContainer", p_config.font_color);
1323
p_theme->set_color("hover_font_color", "FoldableContainer", p_config.font_hover_color);
1324
p_theme->set_color("collapsed_font_color", "FoldableContainer", p_config.font_pressed_color);
1325
p_theme->set_color("font_outline_color", "FoldableContainer", p_config.font_outline_color);
1326
1327
p_theme->set_icon("expanded_arrow", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));
1328
p_theme->set_icon("expanded_arrow_mirrored", "FoldableContainer", p_theme->get_icon(SNAME("GuiArrowUp"), EditorStringName(EditorIcons)));
1329
p_theme->set_icon("folded_arrow", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));
1330
p_theme->set_icon("folded_arrow_mirrored", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));
1331
1332
p_theme->set_constant("outline_size", "FoldableContainer", 0);
1333
p_theme->set_constant("h_separation", "FoldableContainer", p_config.separation_margin);
1334
}
1335
1336
// Window and dialogs.
1337
{
1338
// Window.
1339
1340
p_theme->set_stylebox("embedded_border", "Window", p_config.window_style);
1341
p_theme->set_stylebox("embedded_unfocused_border", "Window", p_config.window_style);
1342
1343
p_theme->set_color("title_color", "Window", p_config.font_color);
1344
p_theme->set_icon("close", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
1345
p_theme->set_icon("close_pressed", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));
1346
p_theme->set_constant("close_h_offset", "Window", 22 * EDSCALE);
1347
p_theme->set_constant("close_v_offset", "Window", 20 * EDSCALE);
1348
p_theme->set_constant("title_height", "Window", 24 * EDSCALE);
1349
p_theme->set_constant("resize_margin", "Window", 4 * EDSCALE);
1350
p_theme->set_font("title_font", "Window", p_theme->get_font(SNAME("title"), EditorStringName(EditorFonts)));
1351
p_theme->set_font_size("title_font_size", "Window", p_theme->get_font_size(SNAME("title_size"), EditorStringName(EditorFonts)));
1352
1353
// AcceptDialog.
1354
p_theme->set_stylebox(SceneStringName(panel), "AcceptDialog", p_config.dialog_style);
1355
p_theme->set_constant("buttons_separation", "AcceptDialog", 8 * EDSCALE);
1356
// Make buttons with short texts such as "OK" easier to click/tap.
1357
p_theme->set_constant("buttons_min_width", "AcceptDialog", p_config.dialogs_buttons_min_size.x * EDSCALE);
1358
p_theme->set_constant("buttons_min_height", "AcceptDialog", p_config.dialogs_buttons_min_size.y * EDSCALE);
1359
1360
// FileDialog.
1361
p_theme->set_icon("folder", "FileDialog", p_theme->get_icon(SNAME("Folder"), EditorStringName(EditorIcons)));
1362
p_theme->set_icon("parent_folder", "FileDialog", p_theme->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)));
1363
p_theme->set_icon("back_folder", "FileDialog", p_theme->get_icon(SNAME("Back"), EditorStringName(EditorIcons)));
1364
p_theme->set_icon("forward_folder", "FileDialog", p_theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons)));
1365
p_theme->set_icon("reload", "FileDialog", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));
1366
p_theme->set_icon("toggle_hidden", "FileDialog", p_theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons)));
1367
p_theme->set_icon("create_folder", "FileDialog", p_theme->get_icon(SNAME("FolderCreate"), EditorStringName(EditorIcons)));
1368
// Use a different color for folder icons to make them easier to distinguish from files.
1369
// On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color.
1370
p_theme->set_color("folder_icon_color", "FileDialog", (p_config.dark_theme ? Color(1, 1, 1) : Color(4.25, 4.25, 4.25)).lerp(p_config.accent_color, 0.7));
1371
p_theme->set_color("file_disabled_color", "FileDialog", p_config.font_disabled_color);
1372
1373
// PopupDialog.
1374
p_theme->set_stylebox(SceneStringName(panel), "PopupDialog", p_config.popup_style);
1375
1376
// PopupMenu.
1377
{
1378
Ref<StyleBoxFlat> style_popup_menu = p_config.popup_border_style->duplicate();
1379
// Use 1 pixel for the sides, since if 0 is used, the highlight of hovered items is drawn
1380
// on top of the popup border. This causes a 'gap' in the panel border when an item is highlighted,
1381
// and it looks weird. 1px solves this.
1382
style_popup_menu->set_content_margin_individual(Math::round(EDSCALE), 2 * EDSCALE, Math::round(EDSCALE), 2 * EDSCALE);
1383
p_theme->set_stylebox(SceneStringName(panel), "PopupMenu", style_popup_menu);
1384
1385
Ref<StyleBoxFlat> style_menu_hover = p_config.button_style_hover->duplicate();
1386
// Don't use rounded corners for hover highlights since the StyleBox touches the PopupMenu's edges.
1387
style_menu_hover->set_corner_radius_all(0);
1388
p_theme->set_stylebox(SceneStringName(hover), "PopupMenu", style_menu_hover);
1389
1390
Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));
1391
style_popup_separator->set_color(p_config.separator_color);
1392
style_popup_separator->set_grow_begin(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
1393
style_popup_separator->set_grow_end(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
1394
style_popup_separator->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));
1395
1396
Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));
1397
style_popup_labeled_separator_left->set_grow_begin(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
1398
style_popup_labeled_separator_left->set_color(p_config.separator_color);
1399
style_popup_labeled_separator_left->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));
1400
1401
Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));
1402
style_popup_labeled_separator_right->set_grow_end(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));
1403
style_popup_labeled_separator_right->set_color(p_config.separator_color);
1404
style_popup_labeled_separator_right->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));
1405
1406
p_theme->set_stylebox("separator", "PopupMenu", style_popup_separator);
1407
p_theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);
1408
p_theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);
1409
1410
p_theme->set_color(SceneStringName(font_color), "PopupMenu", p_config.font_color);
1411
p_theme->set_color("font_hover_color", "PopupMenu", p_config.font_hover_color);
1412
p_theme->set_color("font_accelerator_color", "PopupMenu", p_config.font_disabled_color);
1413
p_theme->set_color("font_disabled_color", "PopupMenu", p_config.font_disabled_color);
1414
p_theme->set_color("font_separator_color", "PopupMenu", p_config.font_disabled_color);
1415
p_theme->set_color("font_outline_color", "PopupMenu", p_config.font_outline_color);
1416
1417
p_theme->set_icon("checked", "PopupMenu", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));
1418
p_theme->set_icon("unchecked", "PopupMenu", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));
1419
p_theme->set_icon("radio_checked", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));
1420
p_theme->set_icon("radio_unchecked", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));
1421
p_theme->set_icon("checked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));
1422
p_theme->set_icon("unchecked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));
1423
p_theme->set_icon("radio_checked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));
1424
p_theme->set_icon("radio_unchecked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));
1425
p_theme->set_icon("submenu", "PopupMenu", p_theme->get_icon(SNAME("ArrowRight"), EditorStringName(EditorIcons)));
1426
p_theme->set_icon("submenu_mirrored", "PopupMenu", p_theme->get_icon(SNAME("ArrowLeft"), EditorStringName(EditorIcons)));
1427
1428
p_theme->set_constant("v_separation", "PopupMenu", p_config.forced_even_separation * EDSCALE);
1429
p_theme->set_constant("outline_size", "PopupMenu", 0);
1430
p_theme->set_constant("item_start_padding", "PopupMenu", p_config.separation_margin);
1431
p_theme->set_constant("item_end_padding", "PopupMenu", p_config.separation_margin);
1432
}
1433
}
1434
1435
// Sliders and scrollbars.
1436
{
1437
Ref<Texture2D> empty_icon = memnew(ImageTexture);
1438
1439
// HScrollBar.
1440
1441
if (p_config.enable_touch_optimizations) {
1442
p_theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(p_config.separator_color, 50));
1443
} else {
1444
p_theme->set_stylebox("scroll", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, -5, 1, -5, 1));
1445
}
1446
p_theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
1447
p_theme->set_stylebox("grabber", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
1448
p_theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
1449
p_theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
1450
1451
p_theme->set_icon("increment", "HScrollBar", empty_icon);
1452
p_theme->set_icon("increment_highlight", "HScrollBar", empty_icon);
1453
p_theme->set_icon("increment_pressed", "HScrollBar", empty_icon);
1454
p_theme->set_icon("decrement", "HScrollBar", empty_icon);
1455
p_theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);
1456
p_theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);
1457
1458
// VScrollBar.
1459
1460
if (p_config.enable_touch_optimizations) {
1461
p_theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(p_config.separator_color, 50, 1, 1, true));
1462
} else {
1463
p_theme->set_stylebox("scroll", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, -5, 1, -5));
1464
}
1465
p_theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
1466
p_theme->set_stylebox("grabber", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
1467
p_theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));
1468
p_theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));
1469
1470
p_theme->set_icon("increment", "VScrollBar", empty_icon);
1471
p_theme->set_icon("increment_highlight", "VScrollBar", empty_icon);
1472
p_theme->set_icon("increment_pressed", "VScrollBar", empty_icon);
1473
p_theme->set_icon("decrement", "VScrollBar", empty_icon);
1474
p_theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);
1475
p_theme->set_icon("decrement_pressed", "VScrollBar", empty_icon);
1476
1477
// Slider
1478
const int background_margin = MAX(2, p_config.base_margin / 2);
1479
1480
// HSlider.
1481
p_theme->set_icon("grabber_highlight", "HSlider", p_theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons)));
1482
p_theme->set_icon("grabber", "HSlider", p_theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons)));
1483
p_theme->set_stylebox("slider", "HSlider", make_flat_stylebox(p_config.dark_color_3, 0, background_margin, 0, background_margin, p_config.corner_radius));
1484
p_theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(p_config.contrast_color_1, 0, background_margin, 0, background_margin, p_config.corner_radius));
1485
p_theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(p_config.contrast_color_1, 0, background_margin, 0, background_margin));
1486
p_theme->set_constant("center_grabber", "HSlider", 0);
1487
p_theme->set_constant("grabber_offset", "HSlider", 0);
1488
1489
// VSlider.
1490
p_theme->set_icon("grabber", "VSlider", p_theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons)));
1491
p_theme->set_icon("grabber_highlight", "VSlider", p_theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons)));
1492
p_theme->set_stylebox("slider", "VSlider", make_flat_stylebox(p_config.dark_color_3, background_margin, 0, background_margin, 0, p_config.corner_radius));
1493
p_theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(p_config.contrast_color_1, background_margin, 0, background_margin, 0, p_config.corner_radius));
1494
p_theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(p_config.contrast_color_1, background_margin, 0, background_margin, 0));
1495
p_theme->set_constant("center_grabber", "VSlider", 0);
1496
p_theme->set_constant("grabber_offset", "VSlider", 0);
1497
}
1498
1499
// Labels.
1500
{
1501
// RichTextLabel.
1502
1503
p_theme->set_stylebox(CoreStringName(normal), "RichTextLabel", p_config.tree_panel_style);
1504
p_theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());
1505
1506
p_theme->set_color("default_color", "RichTextLabel", p_config.font_color);
1507
p_theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0));
1508
p_theme->set_color("font_outline_color", "RichTextLabel", p_config.font_outline_color);
1509
p_theme->set_color("selection_color", "RichTextLabel", p_config.selection_color);
1510
1511
p_theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);
1512
p_theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);
1513
p_theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * EDSCALE);
1514
p_theme->set_constant("outline_size", "RichTextLabel", 0);
1515
1516
// Label.
1517
1518
p_theme->set_stylebox(CoreStringName(normal), "Label", p_config.base_empty_style);
1519
p_theme->set_stylebox("focus", "Label", p_config.button_style_focus);
1520
1521
p_theme->set_color(SceneStringName(font_color), "Label", p_config.font_color);
1522
p_theme->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0));
1523
p_theme->set_color("font_outline_color", "Label", p_config.font_outline_color);
1524
1525
p_theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);
1526
p_theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);
1527
p_theme->set_constant("shadow_outline_size", "Label", 1 * EDSCALE);
1528
p_theme->set_constant("line_spacing", "Label", 3 * EDSCALE);
1529
p_theme->set_constant("outline_size", "Label", 0);
1530
}
1531
1532
// SpinBox.
1533
{
1534
Ref<Texture2D> empty_icon = memnew(ImageTexture);
1535
p_theme->set_icon("updown", "SpinBox", empty_icon);
1536
p_theme->set_icon("up", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
1537
p_theme->set_icon("up_hover", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
1538
p_theme->set_icon("up_pressed", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
1539
p_theme->set_icon("up_disabled", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));
1540
p_theme->set_icon("down", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
1541
p_theme->set_icon("down_hover", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
1542
p_theme->set_icon("down_pressed", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
1543
p_theme->set_icon("down_disabled", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));
1544
1545
p_theme->set_stylebox("up_background", "SpinBox", make_empty_stylebox());
1546
p_theme->set_stylebox("up_background_hovered", "SpinBox", p_config.button_style_hover);
1547
p_theme->set_stylebox("up_background_pressed", "SpinBox", p_config.button_style_pressed);
1548
p_theme->set_stylebox("up_background_disabled", "SpinBox", make_empty_stylebox());
1549
p_theme->set_stylebox("down_background", "SpinBox", make_empty_stylebox());
1550
p_theme->set_stylebox("down_background_hovered", "SpinBox", p_config.button_style_hover);
1551
p_theme->set_stylebox("down_background_pressed", "SpinBox", p_config.button_style_pressed);
1552
p_theme->set_stylebox("down_background_disabled", "SpinBox", make_empty_stylebox());
1553
1554
p_theme->set_color("up_icon_modulate", "SpinBox", p_config.font_color);
1555
p_theme->set_color("up_hover_icon_modulate", "SpinBox", p_config.font_hover_color);
1556
p_theme->set_color("up_pressed_icon_modulate", "SpinBox", p_config.font_pressed_color);
1557
p_theme->set_color("up_disabled_icon_modulate", "SpinBox", p_config.font_disabled_color);
1558
p_theme->set_color("down_icon_modulate", "SpinBox", p_config.font_color);
1559
p_theme->set_color("down_hover_icon_modulate", "SpinBox", p_config.font_hover_color);
1560
p_theme->set_color("down_pressed_icon_modulate", "SpinBox", p_config.font_pressed_color);
1561
p_theme->set_color("down_disabled_icon_modulate", "SpinBox", p_config.font_disabled_color);
1562
1563
p_theme->set_stylebox("field_and_buttons_separator", "SpinBox", make_empty_stylebox());
1564
p_theme->set_stylebox("up_down_buttons_separator", "SpinBox", make_empty_stylebox());
1565
1566
p_theme->set_constant("buttons_vertical_separation", "SpinBox", 0);
1567
p_theme->set_constant("field_and_buttons_separation", "SpinBox", 2);
1568
p_theme->set_constant("buttons_width", "SpinBox", 16);
1569
#ifndef DISABLE_DEPRECATED
1570
p_theme->set_constant("set_min_buttons_width_from_icons", "SpinBox", 1);
1571
#endif
1572
}
1573
1574
// ProgressBar.
1575
p_theme->set_stylebox("background", "ProgressBar", make_stylebox(p_theme->get_icon(SNAME("GuiProgressBar"), EditorStringName(EditorIcons)), 4, 4, 4, 4, 0, 0, 0, 0));
1576
p_theme->set_stylebox("fill", "ProgressBar", make_stylebox(p_theme->get_icon(SNAME("GuiProgressFill"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 2, 1, 2, 1));
1577
p_theme->set_color(SceneStringName(font_color), "ProgressBar", p_config.font_color);
1578
p_theme->set_color("font_outline_color", "ProgressBar", p_config.font_outline_color);
1579
p_theme->set_constant("outline_size", "ProgressBar", 0);
1580
1581
// GraphEdit and related nodes.
1582
{
1583
// GraphEdit.
1584
1585
p_theme->set_stylebox(SceneStringName(panel), "GraphEdit", p_config.tree_panel_style);
1586
p_theme->set_stylebox("panel_focus", "GraphEdit", p_config.button_style_focus);
1587
p_theme->set_stylebox("menu_panel", "GraphEdit", make_flat_stylebox(p_config.dark_color_1 * Color(1, 1, 1, 0.6), 4, 2, 4, 2, 3));
1588
1589
float grid_base_brightness = p_config.dark_theme ? 1.0 : 0.0;
1590
GraphEdit::GridPattern grid_pattern = (GraphEdit::GridPattern) int(EDITOR_GET("editors/visual_editors/grid_pattern"));
1591
switch (grid_pattern) {
1592
case GraphEdit::GRID_PATTERN_LINES:
1593
p_theme->set_color("grid_major", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.10));
1594
p_theme->set_color("grid_minor", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.05));
1595
break;
1596
case GraphEdit::GRID_PATTERN_DOTS:
1597
p_theme->set_color("grid_major", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.07));
1598
p_theme->set_color("grid_minor", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.07));
1599
break;
1600
default:
1601
WARN_PRINT("Unknown grid pattern.");
1602
break;
1603
}
1604
1605
p_theme->set_color("selection_fill", "GraphEdit", p_theme->get_color(SNAME("box_selection_fill_color"), EditorStringName(Editor)));
1606
p_theme->set_color("selection_stroke", "GraphEdit", p_theme->get_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)));
1607
p_theme->set_color("activity", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));
1608
1609
p_theme->set_color("connection_hover_tint_color", "GraphEdit", p_config.dark_theme ? Color(0, 0, 0, 0.3) : Color(1, 1, 1, 0.3));
1610
p_theme->set_constant("connection_hover_thickness", "GraphEdit", 0);
1611
p_theme->set_color("connection_valid_target_tint_color", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1, 0.4) : Color(0, 0, 0, 0.4));
1612
p_theme->set_color("connection_rim_color", "GraphEdit", p_config.tree_panel_style->get_bg_color());
1613
1614
p_theme->set_icon("zoom_out", "GraphEdit", p_theme->get_icon(SNAME("ZoomLess"), EditorStringName(EditorIcons)));
1615
p_theme->set_icon("zoom_in", "GraphEdit", p_theme->get_icon(SNAME("ZoomMore"), EditorStringName(EditorIcons)));
1616
p_theme->set_icon("zoom_reset", "GraphEdit", p_theme->get_icon(SNAME("ZoomReset"), EditorStringName(EditorIcons)));
1617
p_theme->set_icon("grid_toggle", "GraphEdit", p_theme->get_icon(SNAME("GridToggle"), EditorStringName(EditorIcons)));
1618
p_theme->set_icon("minimap_toggle", "GraphEdit", p_theme->get_icon(SNAME("GridMinimap"), EditorStringName(EditorIcons)));
1619
p_theme->set_icon("snapping_toggle", "GraphEdit", p_theme->get_icon(SNAME("SnapGrid"), EditorStringName(EditorIcons)));
1620
p_theme->set_icon("layout", "GraphEdit", p_theme->get_icon(SNAME("GridLayout"), EditorStringName(EditorIcons)));
1621
1622
// GraphEditMinimap.
1623
{
1624
Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0);
1625
style_minimap_bg->set_border_color(p_config.dark_color_3);
1626
style_minimap_bg->set_border_width_all(1);
1627
p_theme->set_stylebox(SceneStringName(panel), "GraphEditMinimap", style_minimap_bg);
1628
1629
Ref<StyleBoxFlat> style_minimap_camera;
1630
Ref<StyleBoxFlat> style_minimap_node;
1631
if (p_config.dark_theme) {
1632
style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0);
1633
style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45));
1634
style_minimap_node = make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0);
1635
} else {
1636
style_minimap_camera = make_flat_stylebox(Color(0.38, 0.38, 0.38, 0.2), 0, 0, 0, 0);
1637
style_minimap_camera->set_border_color(Color(0.38, 0.38, 0.38, 0.45));
1638
style_minimap_node = make_flat_stylebox(Color(0, 0, 0), 0, 0, 0, 0);
1639
}
1640
style_minimap_camera->set_border_width_all(1);
1641
style_minimap_node->set_anti_aliased(false);
1642
p_theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);
1643
p_theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);
1644
1645
const Color minimap_resizer_color = p_config.dark_theme ? Color(1, 1, 1, 0.65) : Color(0, 0, 0, 0.65);
1646
p_theme->set_icon("resizer", "GraphEditMinimap", p_theme->get_icon(SNAME("GuiResizerTopLeft"), EditorStringName(EditorIcons)));
1647
p_theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color);
1648
}
1649
1650
// GraphElement, GraphNode & GraphFrame.
1651
{
1652
const int gn_margin_top = 2;
1653
const int gn_margin_side = 2;
1654
const int gn_margin_bottom = 2;
1655
1656
const int gn_corner_radius = 3;
1657
1658
const Color gn_bg_color = p_config.dark_theme ? p_config.dark_color_3 : p_config.dark_color_1.lerp(p_config.mono_color, 0.09);
1659
const Color gn_selected_border_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);
1660
const Color gn_frame_bg = gn_bg_color.lerp(p_config.tree_panel_style->get_bg_color(), 0.3);
1661
1662
const bool high_contrast_borders = p_config.draw_extra_borders && p_config.dark_theme;
1663
1664
Ref<StyleBoxFlat> gn_panel_style = make_flat_stylebox(gn_frame_bg, gn_margin_side, gn_margin_top, gn_margin_side, gn_margin_bottom, p_config.corner_radius);
1665
gn_panel_style->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);
1666
gn_panel_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
1667
gn_panel_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
1668
gn_panel_style->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));
1669
gn_panel_style->set_corner_radius_individual(0, 0, gn_corner_radius * EDSCALE, gn_corner_radius * EDSCALE);
1670
gn_panel_style->set_anti_aliased(true);
1671
1672
Ref<StyleBoxFlat> gn_panel_selected_style = gn_panel_style->duplicate();
1673
gn_panel_selected_style->set_bg_color(p_config.dark_theme ? gn_bg_color.lightened(0.15) : gn_bg_color.darkened(0.15));
1674
gn_panel_selected_style->set_border_width(SIDE_TOP, 0);
1675
gn_panel_selected_style->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);
1676
gn_panel_selected_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
1677
gn_panel_selected_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
1678
gn_panel_selected_style->set_border_color(gn_selected_border_color);
1679
1680
const int gn_titlebar_margin_top = 8;
1681
const int gn_titlebar_margin_side = 12;
1682
const int gn_titlebar_margin_bottom = 8;
1683
1684
Ref<StyleBoxFlat> gn_titlebar_style = make_flat_stylebox(gn_bg_color, gn_titlebar_margin_side, gn_titlebar_margin_top, gn_titlebar_margin_side, gn_titlebar_margin_bottom, p_config.corner_radius);
1685
gn_titlebar_style->set_border_width(SIDE_TOP, 2 * EDSCALE);
1686
gn_titlebar_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
1687
gn_titlebar_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
1688
gn_titlebar_style->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));
1689
gn_titlebar_style->set_expand_margin(SIDE_TOP, 2 * EDSCALE);
1690
gn_titlebar_style->set_corner_radius_individual(gn_corner_radius * EDSCALE, gn_corner_radius * EDSCALE, 0, 0);
1691
gn_titlebar_style->set_anti_aliased(true);
1692
1693
Ref<StyleBoxFlat> gn_titlebar_selected_style = gn_titlebar_style->duplicate();
1694
gn_titlebar_selected_style->set_border_color(gn_selected_border_color);
1695
gn_titlebar_selected_style->set_border_width(SIDE_TOP, 2 * EDSCALE);
1696
gn_titlebar_selected_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);
1697
gn_titlebar_selected_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);
1698
gn_titlebar_selected_style->set_expand_margin(SIDE_TOP, 2 * EDSCALE);
1699
1700
Color gn_decoration_color = p_config.dark_color_1.inverted();
1701
1702
// GraphElement.
1703
1704
p_theme->set_stylebox(SceneStringName(panel), "GraphElement", gn_panel_style);
1705
p_theme->set_stylebox("panel_selected", "GraphElement", gn_panel_selected_style);
1706
p_theme->set_stylebox("titlebar", "GraphElement", gn_titlebar_style);
1707
p_theme->set_stylebox("titlebar_selected", "GraphElement", gn_titlebar_selected_style);
1708
1709
p_theme->set_color("resizer_color", "GraphElement", gn_decoration_color);
1710
p_theme->set_icon("resizer", "GraphElement", p_theme->get_icon(SNAME("GuiResizer"), EditorStringName(EditorIcons)));
1711
1712
// GraphNode.
1713
1714
Ref<StyleBoxEmpty> gn_slot_style = make_empty_stylebox(12, 0, 12, 0);
1715
1716
p_theme->set_stylebox(SceneStringName(panel), "GraphNode", gn_panel_style);
1717
p_theme->set_stylebox("panel_selected", "GraphNode", gn_panel_selected_style);
1718
p_theme->set_stylebox("panel_focus", "GraphNode", p_config.button_style_focus);
1719
p_theme->set_stylebox("titlebar", "GraphNode", gn_titlebar_style);
1720
p_theme->set_stylebox("titlebar_selected", "GraphNode", gn_titlebar_selected_style);
1721
p_theme->set_stylebox("slot", "GraphNode", gn_slot_style);
1722
p_theme->set_stylebox("slot_selected", "GraphNode", p_config.button_style_focus);
1723
1724
p_theme->set_color("resizer_color", "GraphNode", gn_decoration_color);
1725
1726
p_theme->set_constant("port_h_offset", "GraphNode", 1);
1727
p_theme->set_constant("separation", "GraphNode", 1 * EDSCALE);
1728
1729
Ref<DPITexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));
1730
// The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%).
1731
port_icon->set_size_override(Size2(12, 12));
1732
p_theme->set_icon("port", "GraphNode", port_icon);
1733
1734
// GraphNode's title Label.
1735
p_theme->set_type_variation("GraphNodeTitleLabel", "Label");
1736
p_theme->set_stylebox(CoreStringName(normal), "GraphNodeTitleLabel", make_empty_stylebox(0, 0, 0, 0));
1737
p_theme->set_color("font_shadow_color", "GraphNodeTitleLabel", p_config.shadow_color);
1738
p_theme->set_constant("shadow_outline_size", "GraphNodeTitleLabel", 4);
1739
p_theme->set_constant("shadow_offset_x", "GraphNodeTitleLabel", 0);
1740
p_theme->set_constant("shadow_offset_y", "GraphNodeTitleLabel", 1);
1741
p_theme->set_constant("line_spacing", "GraphNodeTitleLabel", 3 * EDSCALE);
1742
1743
// GraphFrame.
1744
1745
const int gf_corner_width = 7 * EDSCALE;
1746
const int gf_border_width = 2 * MAX(1, EDSCALE);
1747
1748
Ref<StyleBoxFlat> graphframe_sb = make_flat_stylebox(Color(0.0, 0.0, 0.0, 0.2), gn_margin_side, gn_margin_side, gn_margin_side, gn_margin_bottom, gf_corner_width);
1749
graphframe_sb->set_expand_margin(SIDE_TOP, 38 * EDSCALE);
1750
graphframe_sb->set_border_width_all(gf_border_width);
1751
graphframe_sb->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));
1752
graphframe_sb->set_shadow_size(8 * EDSCALE);
1753
graphframe_sb->set_shadow_color(Color(p_config.shadow_color, p_config.shadow_color.a * 0.25));
1754
graphframe_sb->set_anti_aliased(true);
1755
1756
Ref<StyleBoxFlat> graphframe_sb_selected = graphframe_sb->duplicate();
1757
graphframe_sb_selected->set_border_color(gn_selected_border_color);
1758
1759
p_theme->set_stylebox(SceneStringName(panel), "GraphFrame", graphframe_sb);
1760
p_theme->set_stylebox("panel_selected", "GraphFrame", graphframe_sb_selected);
1761
p_theme->set_stylebox("titlebar", "GraphFrame", make_empty_stylebox(4, 4, 4, 4));
1762
p_theme->set_stylebox("titlebar_selected", "GraphFrame", make_empty_stylebox(4, 4, 4, 4));
1763
p_theme->set_color("resizer_color", "GraphFrame", gn_decoration_color);
1764
1765
// GraphFrame's title Label.
1766
p_theme->set_type_variation("GraphFrameTitleLabel", "Label");
1767
p_theme->set_stylebox(CoreStringName(normal), "GraphFrameTitleLabel", memnew(StyleBoxEmpty));
1768
p_theme->set_font_size(SceneStringName(font_size), "GraphFrameTitleLabel", 22 * EDSCALE);
1769
p_theme->set_color(SceneStringName(font_color), "GraphFrameTitleLabel", Color(1, 1, 1));
1770
p_theme->set_color("font_shadow_color", "GraphFrameTitleLabel", Color(0, 0, 0, 0));
1771
p_theme->set_color("font_outline_color", "GraphFrameTitleLabel", Color(1, 1, 1));
1772
p_theme->set_constant("shadow_offset_x", "GraphFrameTitleLabel", 1 * EDSCALE);
1773
p_theme->set_constant("shadow_offset_y", "GraphFrameTitleLabel", 1 * EDSCALE);
1774
p_theme->set_constant("outline_size", "GraphFrameTitleLabel", 0);
1775
p_theme->set_constant("shadow_outline_size", "GraphFrameTitleLabel", 1 * EDSCALE);
1776
p_theme->set_constant("line_spacing", "GraphFrameTitleLabel", 3 * EDSCALE);
1777
}
1778
1779
// VisualShader reroute node.
1780
{
1781
Ref<StyleBox> vs_reroute_panel_style = make_empty_stylebox();
1782
Ref<StyleBox> vs_reroute_titlebar_style = vs_reroute_panel_style->duplicate();
1783
vs_reroute_titlebar_style->set_content_margin_all(16 * EDSCALE);
1784
p_theme->set_stylebox(SceneStringName(panel), "VSRerouteNode", vs_reroute_panel_style);
1785
p_theme->set_stylebox("panel_selected", "VSRerouteNode", vs_reroute_panel_style);
1786
p_theme->set_stylebox("titlebar", "VSRerouteNode", vs_reroute_titlebar_style);
1787
p_theme->set_stylebox("titlebar_selected", "VSRerouteNode", vs_reroute_titlebar_style);
1788
p_theme->set_stylebox("slot", "VSRerouteNode", make_empty_stylebox());
1789
1790
p_theme->set_color("drag_background", "VSRerouteNode", p_config.dark_theme ? Color(0.19, 0.21, 0.24) : Color(0.8, 0.8, 0.8));
1791
p_theme->set_color("selected_rim_color", "VSRerouteNode", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));
1792
}
1793
}
1794
1795
// ColorPicker and related nodes.
1796
{
1797
// ColorPicker.
1798
p_config.circle_style_focus = p_config.button_style_focus->duplicate();
1799
p_config.circle_style_focus->set_corner_radius_all(256 * EDSCALE);
1800
p_config.circle_style_focus->set_corner_detail(32 * EDSCALE);
1801
1802
p_theme->set_constant("margin", "ColorPicker", p_config.base_margin);
1803
p_theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);
1804
p_theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);
1805
p_theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);
1806
p_theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);
1807
p_theme->set_constant("center_slider_grabbers", "ColorPicker", 1);
1808
1809
p_theme->set_stylebox("sample_focus", "ColorPicker", p_config.button_style_focus);
1810
p_theme->set_stylebox("picker_focus_rectangle", "ColorPicker", p_config.button_style_focus);
1811
p_theme->set_stylebox("picker_focus_circle", "ColorPicker", p_config.circle_style_focus);
1812
p_theme->set_color("focused_not_editing_cursor_color", "ColorPicker", p_config.highlight_color);
1813
1814
p_theme->set_icon("screen_picker", "ColorPicker", p_theme->get_icon(SNAME("ColorPick"), EditorStringName(EditorIcons)));
1815
p_theme->set_icon("shape_circle", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeCircle"), EditorStringName(EditorIcons)));
1816
p_theme->set_icon("shape_rect", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangle"), EditorStringName(EditorIcons)));
1817
p_theme->set_icon("shape_rect_wheel", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangleWheel"), EditorStringName(EditorIcons)));
1818
p_theme->set_icon("add_preset", "ColorPicker", p_theme->get_icon(SNAME("Add"), EditorStringName(EditorIcons)));
1819
p_theme->set_icon("sample_bg", "ColorPicker", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
1820
p_theme->set_icon("sample_revert", "ColorPicker", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));
1821
p_theme->set_icon("overbright_indicator", "ColorPicker", p_theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons)));
1822
p_theme->set_icon("bar_arrow", "ColorPicker", p_theme->get_icon(SNAME("ColorPickerBarArrow"), EditorStringName(EditorIcons)));
1823
p_theme->set_icon("picker_cursor", "ColorPicker", p_theme->get_icon(SNAME("PickerCursor"), EditorStringName(EditorIcons)));
1824
p_theme->set_icon("picker_cursor_bg", "ColorPicker", p_theme->get_icon(SNAME("PickerCursorBg"), EditorStringName(EditorIcons)));
1825
p_theme->set_icon("color_script", "ColorPicker", p_theme->get_icon(SNAME("Script"), EditorStringName(EditorIcons)));
1826
1827
// ColorPickerButton.
1828
p_theme->set_icon("bg", "ColorPickerButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
1829
1830
// ColorPresetButton.
1831
p_theme->set_stylebox("preset_fg", "ColorPresetButton", make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2, 2));
1832
p_theme->set_icon("preset_bg", "ColorPresetButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));
1833
p_theme->set_icon("overbright_indicator", "ColorPresetButton", p_theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons)));
1834
}
1835
}
1836
1837
void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
1838
// Project manager.
1839
{
1840
p_theme->set_stylebox("project_list", "ProjectManager", p_config.tree_panel_style);
1841
p_theme->set_constant("sidebar_button_icon_separation", "ProjectManager", int(6 * EDSCALE));
1842
p_theme->set_icon("browse_folder", "ProjectManager", p_theme->get_icon(SNAME("FolderBrowse"), EditorStringName(EditorIcons)));
1843
p_theme->set_icon("browse_file", "ProjectManager", p_theme->get_icon(SNAME("FileBrowse"), EditorStringName(EditorIcons)));
1844
1845
// ProjectTag.
1846
{
1847
p_theme->set_type_variation("ProjectTagButton", "Button");
1848
1849
Ref<StyleBoxFlat> tag = p_config.button_style->duplicate();
1850
tag->set_bg_color(p_config.dark_theme ? tag->get_bg_color().lightened(0.2) : tag->get_bg_color().darkened(0.2));
1851
tag->set_corner_radius(CORNER_TOP_LEFT, 0);
1852
tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1853
tag->set_corner_radius(CORNER_TOP_RIGHT, 4);
1854
tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);
1855
p_theme->set_stylebox(CoreStringName(normal), "ProjectTagButton", tag);
1856
1857
tag = p_config.button_style_hover->duplicate();
1858
tag->set_corner_radius(CORNER_TOP_LEFT, 0);
1859
tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1860
tag->set_corner_radius(CORNER_TOP_RIGHT, 4);
1861
tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);
1862
p_theme->set_stylebox(SceneStringName(hover), "ProjectTagButton", tag);
1863
1864
tag = p_config.button_style_pressed->duplicate();
1865
tag->set_corner_radius(CORNER_TOP_LEFT, 0);
1866
tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
1867
tag->set_corner_radius(CORNER_TOP_RIGHT, 4);
1868
tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);
1869
p_theme->set_stylebox(SceneStringName(pressed), "ProjectTagButton", tag);
1870
}
1871
}
1872
1873
// Editor and main screen.
1874
{
1875
// Editor background.
1876
Color background_color_opaque = p_config.dark_color_2;
1877
background_color_opaque.a = 1.0;
1878
p_theme->set_color("background", EditorStringName(Editor), background_color_opaque);
1879
p_theme->set_stylebox("Background", EditorStringName(EditorStyles), make_flat_stylebox(background_color_opaque, p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin));
1880
1881
Ref<StyleBoxFlat> editor_panel_foreground = p_config.base_style->duplicate();
1882
editor_panel_foreground->set_corner_radius_all(0);
1883
p_theme->set_stylebox("PanelForeground", EditorStringName(EditorStyles), editor_panel_foreground);
1884
1885
// Editor focus.
1886
p_theme->set_stylebox("Focus", EditorStringName(EditorStyles), p_config.button_style_focus);
1887
1888
Ref<StyleBoxFlat> style_widget_focus_viewport = p_config.button_style_focus->duplicate();
1889
// Use a less opaque color to be less distracting for the 2D and 3D editor viewports.
1890
style_widget_focus_viewport->set_border_color(p_config.accent_color * Color(1, 1, 1, 0.5));
1891
p_theme->set_stylebox("FocusViewport", EditorStringName(EditorStyles), style_widget_focus_viewport);
1892
1893
Ref<StyleBoxFlat> style_widget_scroll_container = p_config.button_style_focus->duplicate();
1894
p_theme->set_stylebox("focus", "ScrollContainer", style_widget_scroll_container);
1895
1896
// This stylebox is used in 3d and 2d viewports (no borders).
1897
Ref<StyleBoxFlat> style_content_panel_vp = p_config.content_panel_style->duplicate();
1898
style_content_panel_vp->set_content_margin_individual(p_config.border_width * 2, p_config.base_margin * EDSCALE, p_config.border_width * 2, p_config.border_width * 2);
1899
p_theme->set_stylebox("Content", EditorStringName(EditorStyles), style_content_panel_vp);
1900
1901
// 3D/Spatial editor.
1902
Ref<StyleBoxFlat> style_info_3d_viewport = p_config.base_style->duplicate();
1903
style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));
1904
style_info_3d_viewport->set_border_width_all(0);
1905
p_theme->set_stylebox("Information3dViewport", EditorStringName(EditorStyles), style_info_3d_viewport);
1906
1907
// 2D and 3D contextual toolbar.
1908
// Use a custom stylebox to make contextual menu items stand out from the rest.
1909
// This helps with editor usability as contextual menu items change when selecting nodes,
1910
// even though it may not be immediately obvious at first.
1911
Ref<StyleBoxFlat> toolbar_stylebox = memnew(StyleBoxFlat);
1912
toolbar_stylebox->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));
1913
toolbar_stylebox->set_anti_aliased(false);
1914
// Add an underline to the StyleBox, but prevent its minimum vertical size from changing.
1915
toolbar_stylebox->set_border_color(p_config.accent_color);
1916
toolbar_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));
1917
toolbar_stylebox->set_content_margin(SIDE_BOTTOM, 0);
1918
toolbar_stylebox->set_expand_margin_individual(4 * EDSCALE, 2 * EDSCALE, 4 * EDSCALE, 4 * EDSCALE);
1919
p_theme->set_stylebox("ContextualToolbar", EditorStringName(EditorStyles), toolbar_stylebox);
1920
1921
// Script editor.
1922
p_theme->set_stylebox("ScriptEditorPanel", EditorStringName(EditorStyles), make_empty_stylebox(p_config.base_margin, 0, p_config.base_margin, p_config.base_margin));
1923
p_theme->set_stylebox("ScriptEditorPanelFloating", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
1924
p_theme->set_stylebox("ScriptEditor", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
1925
1926
// Game view.
1927
p_theme->set_type_variation("GamePanel", "Panel");
1928
Ref<StyleBoxFlat> game_panel = p_theme->get_stylebox(SceneStringName(panel), SNAME("Panel"))->duplicate();
1929
game_panel->set_corner_radius_all(0);
1930
p_theme->set_stylebox(SceneStringName(panel), "GamePanel", game_panel);
1931
1932
// Main menu.
1933
Ref<StyleBoxFlat> menu_transparent_style = p_config.button_style->duplicate();
1934
menu_transparent_style->set_bg_color(Color(1, 1, 1, 0));
1935
menu_transparent_style->set_border_width_all(0);
1936
Ref<StyleBoxFlat> main_screen_button_hover = p_config.button_style_hover->duplicate();
1937
for (int i = 0; i < 4; i++) {
1938
menu_transparent_style->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
1939
main_screen_button_hover->set_content_margin((Side)i, p_config.button_style_hover->get_content_margin((Side)i));
1940
}
1941
p_theme->set_stylebox(CoreStringName(normal), "MainScreenButton", menu_transparent_style);
1942
p_theme->set_stylebox("normal_mirrored", "MainScreenButton", menu_transparent_style);
1943
p_theme->set_stylebox(SceneStringName(pressed), "MainScreenButton", menu_transparent_style);
1944
p_theme->set_stylebox("pressed_mirrored", "MainScreenButton", menu_transparent_style);
1945
p_theme->set_stylebox(SceneStringName(hover), "MainScreenButton", main_screen_button_hover);
1946
p_theme->set_stylebox("hover_mirrored", "MainScreenButton", main_screen_button_hover);
1947
p_theme->set_stylebox("hover_pressed", "MainScreenButton", main_screen_button_hover);
1948
p_theme->set_stylebox("hover_pressed_mirrored", "MainScreenButton", main_screen_button_hover);
1949
1950
p_theme->set_type_variation("MainMenuBar", "FlatMenuButton");
1951
p_theme->set_stylebox(CoreStringName(normal), "MainMenuBar", menu_transparent_style);
1952
p_theme->set_stylebox(SceneStringName(pressed), "MainMenuBar", main_screen_button_hover);
1953
p_theme->set_stylebox(SceneStringName(hover), "MainMenuBar", main_screen_button_hover);
1954
p_theme->set_stylebox("hover_pressed", "MainMenuBar", main_screen_button_hover);
1955
1956
// Run bar.
1957
p_theme->set_type_variation("RunBarButton", "FlatMenuButton");
1958
p_theme->set_stylebox("disabled", "RunBarButton", menu_transparent_style);
1959
p_theme->set_stylebox(SceneStringName(pressed), "RunBarButton", menu_transparent_style);
1960
1961
p_theme->set_type_variation("RunBarButtonMovieMakerDisabled", "RunBarButton");
1962
p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.7));
1963
p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));
1964
p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.9));
1965
p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));
1966
1967
p_theme->set_type_variation("RunBarButtonMovieMakerEnabled", "RunBarButton");
1968
p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.7));
1969
p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));
1970
p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.9));
1971
p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));
1972
1973
// Bottom panel.
1974
Ref<StyleBoxFlat> style_bottom_panel = p_config.content_panel_style->duplicate();
1975
style_bottom_panel->set_corner_radius_all(p_config.corner_radius * EDSCALE);
1976
p_theme->set_stylebox("BottomPanel", EditorStringName(EditorStyles), style_bottom_panel);
1977
p_theme->set_type_variation("BottomPanelButton", "FlatMenuButton");
1978
p_theme->set_stylebox(CoreStringName(normal), "BottomPanelButton", menu_transparent_style);
1979
p_theme->set_stylebox(SceneStringName(pressed), "BottomPanelButton", menu_transparent_style);
1980
p_theme->set_stylebox("hover_pressed", "BottomPanelButton", main_screen_button_hover);
1981
p_theme->set_stylebox(SceneStringName(hover), "BottomPanelButton", main_screen_button_hover);
1982
// Don't tint the icon even when in "pressed" state.
1983
p_theme->set_color("icon_pressed_color", "BottomPanelButton", Color(1, 1, 1, 1));
1984
Color icon_hover_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.0);
1985
icon_hover_color.a = 1.0;
1986
p_theme->set_color("icon_hover_color", "BottomPanelButton", icon_hover_color);
1987
p_theme->set_color("icon_hover_pressed_color", "BottomPanelButton", icon_hover_color);
1988
1989
// Audio bus.
1990
p_theme->set_stylebox("normal", "EditorAudioBus", style_bottom_panel);
1991
p_theme->set_stylebox("master", "EditorAudioBus", p_config.button_style_disabled);
1992
p_theme->set_stylebox("focus", "EditorAudioBus", p_config.button_style_focus);
1993
}
1994
1995
// Editor GUI widgets.
1996
{
1997
// EditorSpinSlider.
1998
p_theme->set_color("label_color", "EditorSpinSlider", p_config.font_color);
1999
p_theme->set_color("read_only_label_color", "EditorSpinSlider", p_config.font_readonly_color);
2000
2001
Ref<StyleBoxFlat> editor_spin_label_bg = p_config.base_style->duplicate();
2002
editor_spin_label_bg->set_bg_color(p_config.dark_color_3);
2003
editor_spin_label_bg->set_border_width_all(0);
2004
p_theme->set_stylebox("label_bg", "EditorSpinSlider", editor_spin_label_bg);
2005
2006
// TODO Use separate arrows instead like on SpinBox. Planned for a different PR.
2007
p_theme->set_icon("updown", "EditorSpinSlider", p_theme->get_icon(SNAME("GuiSpinboxUpdown"), EditorStringName(EditorIcons)));
2008
p_theme->set_icon("updown_disabled", "EditorSpinSlider", p_theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), EditorStringName(EditorIcons)));
2009
2010
// Launch Pad and Play buttons.
2011
Ref<StyleBoxFlat> style_launch_pad = make_flat_stylebox(p_config.dark_color_1, 2 * EDSCALE, 0, 2 * EDSCALE, 0, p_config.corner_radius);
2012
style_launch_pad->set_corner_radius_all(p_config.corner_radius * EDSCALE);
2013
p_theme->set_stylebox("LaunchPadNormal", EditorStringName(EditorStyles), style_launch_pad);
2014
Ref<StyleBoxFlat> style_launch_pad_movie = style_launch_pad->duplicate();
2015
style_launch_pad_movie->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));
2016
style_launch_pad_movie->set_border_color(p_config.accent_color);
2017
style_launch_pad_movie->set_border_width_all(Math::round(2 * EDSCALE));
2018
p_theme->set_stylebox("LaunchPadMovieMode", EditorStringName(EditorStyles), style_launch_pad_movie);
2019
Ref<StyleBoxFlat> style_launch_pad_recovery_mode = style_launch_pad->duplicate();
2020
style_launch_pad_recovery_mode->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));
2021
style_launch_pad_recovery_mode->set_border_color(p_config.warning_color);
2022
style_launch_pad_recovery_mode->set_border_width_all(Math::round(2 * EDSCALE));
2023
p_theme->set_stylebox("LaunchPadRecoveryMode", EditorStringName(EditorStyles), style_launch_pad_recovery_mode);
2024
2025
p_theme->set_stylebox("MovieWriterButtonNormal", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
2026
Ref<StyleBoxFlat> style_write_movie_button = p_config.button_style_pressed->duplicate();
2027
style_write_movie_button->set_bg_color(p_config.accent_color);
2028
style_write_movie_button->set_corner_radius_all(p_config.corner_radius * EDSCALE);
2029
style_write_movie_button->set_content_margin(SIDE_TOP, 0);
2030
style_write_movie_button->set_content_margin(SIDE_BOTTOM, 0);
2031
style_write_movie_button->set_content_margin(SIDE_LEFT, 0);
2032
style_write_movie_button->set_content_margin(SIDE_RIGHT, 0);
2033
style_write_movie_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
2034
p_theme->set_stylebox("MovieWriterButtonPressed", EditorStringName(EditorStyles), style_write_movie_button);
2035
2036
// Profiler autostart indicator panel.
2037
Ref<StyleBoxFlat> style_profiler_autostart = style_launch_pad->duplicate();
2038
style_profiler_autostart->set_bg_color(Color(1, 0.867, 0.396));
2039
p_theme->set_type_variation("ProfilerAutostartIndicator", "Button");
2040
p_theme->set_stylebox(CoreStringName(normal), "ProfilerAutostartIndicator", style_profiler_autostart);
2041
p_theme->set_stylebox(SceneStringName(pressed), "ProfilerAutostartIndicator", style_profiler_autostart);
2042
p_theme->set_stylebox("hover", "ProfilerAutostartIndicator", style_profiler_autostart);
2043
2044
// Recovery mode button style
2045
Ref<StyleBoxFlat> style_recovery_mode_button = p_config.button_style_pressed->duplicate();
2046
style_recovery_mode_button->set_bg_color(p_config.warning_color);
2047
style_recovery_mode_button->set_corner_radius_all(p_config.corner_radius * EDSCALE);
2048
style_recovery_mode_button->set_content_margin_all(0);
2049
// Recovery mode button is implicitly styled from the panel's background.
2050
// So, remove any existing borders. (e.g. from draw_extra_borders config)
2051
style_recovery_mode_button->set_border_width_all(0);
2052
style_recovery_mode_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
2053
p_theme->set_stylebox("RecoveryModeButton", EditorStringName(EditorStyles), style_recovery_mode_button);
2054
}
2055
2056
// Standard GUI variations.
2057
{
2058
// Custom theme type for MarginContainer with 4px margins.
2059
p_theme->set_type_variation("MarginContainer4px", "MarginContainer");
2060
p_theme->set_constant("margin_left", "MarginContainer4px", 4 * EDSCALE);
2061
p_theme->set_constant("margin_top", "MarginContainer4px", 4 * EDSCALE);
2062
p_theme->set_constant("margin_right", "MarginContainer4px", 4 * EDSCALE);
2063
p_theme->set_constant("margin_bottom", "MarginContainer4px", 4 * EDSCALE);
2064
2065
// Header LinkButton variation.
2066
p_theme->set_type_variation("HeaderSmallLink", "LinkButton");
2067
p_theme->set_font(SceneStringName(font), "HeaderSmallLink", p_theme->get_font(SceneStringName(font), SNAME("HeaderSmall")));
2068
p_theme->set_font_size(SceneStringName(font_size), "HeaderSmallLink", p_theme->get_font_size(SceneStringName(font_size), SNAME("HeaderSmall")));
2069
2070
// Flat button variations.
2071
{
2072
Ref<StyleBoxEmpty> style_flat_button = make_empty_stylebox();
2073
Ref<StyleBoxFlat> style_flat_button_hover = p_config.button_style_hover->duplicate();
2074
Ref<StyleBoxFlat> style_flat_button_pressed = p_config.button_style_pressed->duplicate();
2075
2076
for (int i = 0; i < 4; i++) {
2077
style_flat_button->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
2078
style_flat_button_hover->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
2079
style_flat_button_pressed->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));
2080
}
2081
Color flat_pressed_color = p_config.dark_color_1.lightened(0.24).lerp(p_config.accent_color, 0.2) * Color(0.8, 0.8, 0.8, 0.85);
2082
if (p_config.dark_theme) {
2083
flat_pressed_color = p_config.dark_color_1.lerp(p_config.accent_color, 0.12) * Color(0.6, 0.6, 0.6, 0.85);
2084
}
2085
style_flat_button_pressed->set_bg_color(flat_pressed_color);
2086
2087
p_theme->set_stylebox(CoreStringName(normal), SceneStringName(FlatButton), style_flat_button);
2088
p_theme->set_stylebox(SceneStringName(hover), SceneStringName(FlatButton), style_flat_button_hover);
2089
p_theme->set_stylebox(SceneStringName(pressed), SceneStringName(FlatButton), style_flat_button_pressed);
2090
p_theme->set_stylebox("disabled", SceneStringName(FlatButton), style_flat_button);
2091
2092
p_theme->set_stylebox(CoreStringName(normal), "FlatMenuButton", style_flat_button);
2093
p_theme->set_stylebox(SceneStringName(hover), "FlatMenuButton", style_flat_button_hover);
2094
p_theme->set_stylebox(SceneStringName(pressed), "FlatMenuButton", style_flat_button_pressed);
2095
p_theme->set_stylebox("disabled", "FlatMenuButton", style_flat_button);
2096
2097
// Variation for Editor Log filter buttons.
2098
2099
p_theme->set_type_variation("EditorLogFilterButton", "Button");
2100
// When pressed, don't tint the icons with the accent color, just leave them normal.
2101
p_theme->set_color("icon_pressed_color", "EditorLogFilterButton", p_config.icon_normal_color);
2102
// When unpressed, dim the icons.
2103
Color icon_normal_color = Color(p_config.icon_normal_color, (p_config.dark_theme ? 0.4 : 0.8));
2104
p_theme->set_color("icon_normal_color", "EditorLogFilterButton", icon_normal_color);
2105
Color icon_hover_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.0);
2106
icon_hover_color.a = 1.0;
2107
p_theme->set_color("icon_hover_color", "EditorLogFilterButton", icon_hover_color);
2108
p_theme->set_color("icon_hover_pressed_color", "EditorLogFilterButton", icon_hover_color);
2109
2110
// When pressed, add a small bottom border to the buttons to better show their active state,
2111
// similar to active tabs.
2112
Ref<StyleBoxFlat> editor_log_button_pressed = style_flat_button_pressed->duplicate();
2113
editor_log_button_pressed->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);
2114
editor_log_button_pressed->set_border_color(p_config.accent_color);
2115
if (!p_config.dark_theme) {
2116
editor_log_button_pressed->set_bg_color(flat_pressed_color.lightened(0.5));
2117
}
2118
p_theme->set_stylebox(CoreStringName(normal), "EditorLogFilterButton", style_flat_button);
2119
p_theme->set_stylebox(SceneStringName(hover), "EditorLogFilterButton", style_flat_button_hover);
2120
p_theme->set_stylebox(SceneStringName(pressed), "EditorLogFilterButton", editor_log_button_pressed);
2121
}
2122
2123
// Buttons styles that stand out against the panel background (e.g. AssetLib).
2124
{
2125
p_theme->set_type_variation("PanelBackgroundButton", "Button");
2126
2127
Ref<StyleBoxFlat> panel_button_style = p_config.button_style->duplicate();
2128
panel_button_style->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.08));
2129
2130
Ref<StyleBoxFlat> panel_button_style_hover = p_config.button_style_hover->duplicate();
2131
panel_button_style_hover->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.16));
2132
2133
Ref<StyleBoxFlat> panel_button_style_pressed = p_config.button_style_pressed->duplicate();
2134
panel_button_style_pressed->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.20));
2135
2136
Ref<StyleBoxFlat> panel_button_style_disabled = p_config.button_style_disabled->duplicate();
2137
panel_button_style_disabled->set_bg_color(p_config.disabled_bg_color);
2138
2139
p_theme->set_stylebox(CoreStringName(normal), "PanelBackgroundButton", panel_button_style);
2140
p_theme->set_stylebox(SceneStringName(hover), "PanelBackgroundButton", panel_button_style_hover);
2141
p_theme->set_stylebox(SceneStringName(pressed), "PanelBackgroundButton", panel_button_style_pressed);
2142
p_theme->set_stylebox("disabled", "PanelBackgroundButton", panel_button_style_disabled);
2143
}
2144
2145
// Top bar selectors.
2146
{
2147
p_theme->set_type_variation("TopBarOptionButton", "OptionButton");
2148
p_theme->set_font(SceneStringName(font), "TopBarOptionButton", p_theme->get_font(SNAME("bold"), EditorStringName(EditorFonts)));
2149
p_theme->set_font_size(SceneStringName(font_size), "TopBarOptionButton", p_theme->get_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)));
2150
}
2151
2152
// Complex editor windows.
2153
{
2154
Ref<StyleBoxFlat> style_complex_window = p_config.window_style->duplicate();
2155
style_complex_window->set_bg_color(p_config.dark_color_2);
2156
style_complex_window->set_border_color(p_config.dark_color_2);
2157
p_theme->set_stylebox(SceneStringName(panel), "EditorSettingsDialog", style_complex_window);
2158
p_theme->set_stylebox(SceneStringName(panel), "ProjectSettingsEditor", style_complex_window);
2159
p_theme->set_stylebox(SceneStringName(panel), "EditorAbout", style_complex_window);
2160
}
2161
2162
// InspectorActionButton.
2163
{
2164
p_theme->set_type_variation("InspectorActionButton", "Button");
2165
2166
const float action_extra_margin = 32 * EDSCALE;
2167
p_theme->set_constant("h_separation", "InspectorActionButton", action_extra_margin);
2168
2169
Color color_inspector_action = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);
2170
color_inspector_action.a = 0.5;
2171
Ref<StyleBoxFlat> style_inspector_action = p_config.button_style->duplicate();
2172
style_inspector_action->set_bg_color(color_inspector_action);
2173
style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
2174
p_theme->set_stylebox(CoreStringName(normal), "InspectorActionButton", style_inspector_action);
2175
2176
style_inspector_action = p_config.button_style->duplicate();
2177
style_inspector_action->set_bg_color(color_inspector_action);
2178
style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
2179
p_theme->set_stylebox("normal_mirrored", "InspectorActionButton", style_inspector_action);
2180
2181
style_inspector_action = p_config.button_style_hover->duplicate();
2182
style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
2183
p_theme->set_stylebox(SceneStringName(hover), "InspectorActionButton", style_inspector_action);
2184
2185
style_inspector_action = p_config.button_style_hover->duplicate();
2186
style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
2187
p_theme->set_stylebox("hover_mirrored", "InspectorActionButton", style_inspector_action);
2188
2189
style_inspector_action = p_config.button_style_pressed->duplicate();
2190
style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
2191
p_theme->set_stylebox(SceneStringName(pressed), "InspectorActionButton", style_inspector_action);
2192
2193
style_inspector_action = p_config.button_style_pressed->duplicate();
2194
style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
2195
p_theme->set_stylebox("pressed_mirrored", "InspectorActionButton", style_inspector_action);
2196
2197
style_inspector_action = p_config.button_style_disabled->duplicate();
2198
style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);
2199
p_theme->set_stylebox("disabled", "InspectorActionButton", style_inspector_action);
2200
2201
style_inspector_action = p_config.button_style_disabled->duplicate();
2202
style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);
2203
p_theme->set_stylebox("disabled_mirrored", "InspectorActionButton", style_inspector_action);
2204
}
2205
2206
// Buttons in material previews.
2207
{
2208
const Color dim_light_color = p_config.icon_normal_color.darkened(0.24);
2209
const Color dim_light_highlighted_color = p_config.icon_normal_color.darkened(0.18);
2210
Ref<StyleBox> sb_empty_borderless = make_empty_stylebox();
2211
2212
p_theme->set_type_variation("PreviewLightButton", "Button");
2213
// When pressed, don't use the accent color tint. When unpressed, dim the icon.
2214
p_theme->set_color("icon_normal_color", "PreviewLightButton", dim_light_color);
2215
p_theme->set_color("icon_focus_color", "PreviewLightButton", dim_light_color);
2216
p_theme->set_color("icon_pressed_color", "PreviewLightButton", p_config.icon_normal_color);
2217
p_theme->set_color("icon_hover_pressed_color", "PreviewLightButton", p_config.icon_normal_color);
2218
// Unpressed icon is dim, so use a dim highlight.
2219
p_theme->set_color("icon_hover_color", "PreviewLightButton", dim_light_highlighted_color);
2220
2221
p_theme->set_stylebox(CoreStringName(normal), "PreviewLightButton", sb_empty_borderless);
2222
p_theme->set_stylebox(SceneStringName(hover), "PreviewLightButton", sb_empty_borderless);
2223
p_theme->set_stylebox("focus", "PreviewLightButton", sb_empty_borderless);
2224
p_theme->set_stylebox(SceneStringName(pressed), "PreviewLightButton", sb_empty_borderless);
2225
}
2226
2227
// TabContainerOdd variation.
2228
{
2229
// Can be used on tabs against the base color background (e.g. nested tabs).
2230
p_theme->set_type_variation("TabContainerOdd", "TabContainer");
2231
2232
Ref<StyleBoxFlat> style_tab_selected_odd = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->duplicate();
2233
style_tab_selected_odd->set_bg_color(p_config.disabled_bg_color);
2234
p_theme->set_stylebox("tab_selected", "TabContainerOdd", style_tab_selected_odd);
2235
2236
Ref<StyleBoxFlat> style_content_panel_odd = p_config.content_panel_style->duplicate();
2237
style_content_panel_odd->set_bg_color(p_config.disabled_bg_color);
2238
p_theme->set_stylebox(SceneStringName(panel), "TabContainerOdd", style_content_panel_odd);
2239
}
2240
2241
// EditorValidationPanel.
2242
p_theme->set_stylebox(SceneStringName(panel), "EditorValidationPanel", p_config.tree_panel_style);
2243
2244
// Secondary trees and item lists.
2245
p_theme->set_type_variation("TreeSecondary", "Tree");
2246
p_theme->set_type_variation("ItemListSecondary", "ItemList");
2247
}
2248
2249
// Editor inspector.
2250
{
2251
// Panel.
2252
Ref<StyleBoxFlat> editor_inspector_panel = p_config.tree_panel_style->duplicate();
2253
editor_inspector_panel->set_border_width_all(0);
2254
editor_inspector_panel->set_content_margin_all(0);
2255
p_theme->set_stylebox(SceneStringName(panel), "EditorInspector", editor_inspector_panel);
2256
2257
// Vertical separation between inspector categories and sections.
2258
p_theme->set_constant("v_separation", "EditorInspector", 0);
2259
2260
// EditorProperty.
2261
2262
Ref<StyleBoxFlat> style_property_bg = p_config.base_style->duplicate();
2263
style_property_bg->set_bg_color(p_config.highlight_color);
2264
style_property_bg->set_border_width_all(0);
2265
2266
Ref<StyleBoxFlat> style_property_child_bg = p_config.base_style->duplicate();
2267
style_property_child_bg->set_bg_color(p_config.dark_color_2);
2268
style_property_child_bg->set_border_width_all(0);
2269
2270
p_theme->set_stylebox("bg", "EditorProperty", memnew(StyleBoxEmpty));
2271
p_theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg);
2272
p_theme->set_stylebox("child_bg", "EditorProperty", style_property_child_bg);
2273
p_theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE);
2274
p_theme->set_constant("v_separation", "EditorProperty", p_config.increased_margin * EDSCALE);
2275
2276
const Color property_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5);
2277
const Color readonly_color = property_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.25);
2278
const Color readonly_warning_color = p_config.error_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.25);
2279
2280
p_theme->set_color("property_color", "EditorProperty", property_color);
2281
p_theme->set_color("readonly_color", "EditorProperty", readonly_color);
2282
p_theme->set_color("warning_color", "EditorProperty", p_config.warning_color);
2283
p_theme->set_color("readonly_warning_color", "EditorProperty", readonly_warning_color);
2284
2285
Ref<StyleBoxFlat> style_property_group_note = p_config.base_style->duplicate();
2286
Color property_group_note_color = p_config.accent_color;
2287
property_group_note_color.a = 0.1;
2288
style_property_group_note->set_bg_color(property_group_note_color);
2289
p_theme->set_stylebox("bg_group_note", "EditorProperty", style_property_group_note);
2290
2291
// EditorInspectorSection.
2292
2293
Color inspector_section_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.35);
2294
p_theme->set_color(SceneStringName(font_color), "EditorInspectorSection", inspector_section_color);
2295
2296
Color inspector_indent_color = p_config.accent_color;
2297
inspector_indent_color.a = 0.2;
2298
Ref<StyleBoxFlat> inspector_indent_style = make_flat_stylebox(inspector_indent_color, 2.0 * EDSCALE, 0, 2.0 * EDSCALE, 0);
2299
p_theme->set_stylebox("indent_box", "EditorInspectorSection", inspector_indent_style);
2300
p_theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE);
2301
p_theme->set_constant("h_separation", "EditorInspectorSection", 2.0 * EDSCALE);
2302
2303
Color prop_category_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);
2304
Color prop_section_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.09);
2305
Color prop_subsection_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.06);
2306
2307
p_theme->set_color("prop_category", EditorStringName(Editor), prop_category_color);
2308
p_theme->set_color("prop_section", EditorStringName(Editor), prop_section_color);
2309
p_theme->set_color("prop_subsection", EditorStringName(Editor), prop_subsection_color);
2310
#ifndef DISABLE_DEPRECATED // Used before 4.3.
2311
p_theme->set_color("property_color", EditorStringName(Editor), prop_category_color);
2312
#endif
2313
2314
// EditorInspectorCategory.
2315
2316
Ref<StyleBoxFlat> category_bg = p_config.base_style->duplicate();
2317
category_bg->set_bg_color(prop_category_color);
2318
category_bg->set_border_color(prop_category_color);
2319
category_bg->set_content_margin_all(0);
2320
p_theme->set_stylebox("bg", "EditorInspectorCategory", category_bg);
2321
2322
p_theme->set_constant("inspector_margin", EditorStringName(Editor), 12 * EDSCALE);
2323
2324
// Colored EditorProperty.
2325
for (int i = 0; i < 16; i++) {
2326
Color si_base_color = p_config.accent_color;
2327
2328
float hue_rotate = (i * 2 % 16) / 16.0;
2329
si_base_color.set_hsv(Math::fmod(float(si_base_color.get_h() + hue_rotate), float(1.0)), si_base_color.get_s(), si_base_color.get_v());
2330
si_base_color = p_config.accent_color.lerp(si_base_color, p_config.subresource_hue_tint);
2331
2332
// Sub-inspector background.
2333
Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
2334
sub_inspector_bg->set_bg_color(p_config.dark_color_1.lerp(si_base_color, 0.08));
2335
sub_inspector_bg->set_border_width_all(2 * EDSCALE);
2336
sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));
2337
sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
2338
sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
2339
sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
2340
2341
p_theme->set_stylebox("sub_inspector_bg" + itos(i + 1), EditorStringName(EditorStyles), sub_inspector_bg);
2342
2343
// EditorProperty background while it has a sub-inspector open.
2344
Ref<StyleBoxFlat> bg_color = make_flat_stylebox(si_base_color * Color(0.7, 0.7, 0.7, 0.8), 0, 0, 0, 0, p_config.corner_radius);
2345
bg_color->set_anti_aliased(false);
2346
bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
2347
bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
2348
2349
p_theme->set_stylebox("sub_inspector_property_bg" + itos(i + 1), EditorStringName(EditorStyles), bg_color);
2350
2351
// Dictionary editor add item.
2352
// Expand to the left and right by 4px to compensate for the dictionary editor margins.
2353
2354
Color style_dictionary_bg_color = p_config.dark_color_3.lerp(si_base_color, 0.08);
2355
Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(style_dictionary_bg_color, 0, 4, 0, 4, p_config.corner_radius);
2356
style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);
2357
style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
2358
p_theme->set_stylebox("DictionaryAddItem" + itos(i + 1), EditorStringName(EditorStyles), style_dictionary_add_item);
2359
}
2360
Color si_base_color = p_config.accent_color;
2361
2362
// Sub-inspector background.
2363
Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();
2364
sub_inspector_bg->set_bg_color(Color(1, 1, 1, 0));
2365
sub_inspector_bg->set_border_width_all(2 * EDSCALE);
2366
sub_inspector_bg->set_border_color(p_config.dark_color_1.lerp(si_base_color, 0.15));
2367
sub_inspector_bg->set_content_margin_all(4 * EDSCALE);
2368
sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);
2369
sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);
2370
2371
p_theme->set_stylebox("sub_inspector_bg0", EditorStringName(EditorStyles), sub_inspector_bg);
2372
2373
// Sub-inspector background no border.
2374
2375
Ref<StyleBoxFlat> sub_inspector_bg_no_border = p_config.base_style->duplicate();
2376
sub_inspector_bg_no_border->set_content_margin_all(2 * EDSCALE);
2377
sub_inspector_bg_no_border->set_bg_color(p_config.dark_color_2.lerp(p_config.dark_color_3, 0.15));
2378
p_theme->set_stylebox("sub_inspector_bg_no_border", EditorStringName(EditorStyles), sub_inspector_bg_no_border);
2379
2380
// EditorProperty background while it has a sub-inspector open.
2381
Ref<StyleBoxFlat> bg_color = make_flat_stylebox(p_config.dark_color_1.lerp(si_base_color, 0.15), 0, 0, 0, 0, p_config.corner_radius);
2382
bg_color->set_anti_aliased(false);
2383
bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
2384
bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
2385
2386
p_theme->set_stylebox("sub_inspector_property_bg0", EditorStringName(EditorStyles), bg_color);
2387
2388
p_theme->set_color("sub_inspector_property_color", EditorStringName(EditorStyles), p_config.dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));
2389
2390
// Dictionary editor.
2391
2392
// Expand to the left and right by 4px to compensate for the dictionary editor margins.
2393
Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(prop_subsection_color, 0, 4, 0, 4, p_config.corner_radius);
2394
style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);
2395
style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);
2396
p_theme->set_stylebox("DictionaryAddItem0", EditorStringName(EditorStyles), style_dictionary_add_item);
2397
}
2398
2399
// Animation Editor.
2400
{
2401
// Timeline general.
2402
p_theme->set_constant("timeline_v_separation", "AnimationTrackEditor", 0);
2403
p_theme->set_constant("track_v_separation", "AnimationTrackEditor", 0);
2404
2405
// AnimationTimelineEdit.
2406
// "primary" is used for integer timeline values, "secondary" for decimals.
2407
2408
Ref<StyleBoxFlat> style_time_unavailable = make_flat_stylebox(p_config.dark_color_2, 0, 0, 0, 0, 0);
2409
Ref<StyleBoxFlat> style_time_available = make_flat_stylebox(p_config.font_color * Color(1, 1, 1, 0.2), 0, 0, 0, 0, 0);
2410
2411
p_theme->set_stylebox("time_unavailable", "AnimationTimelineEdit", style_time_unavailable);
2412
p_theme->set_stylebox("time_available", "AnimationTimelineEdit", style_time_available);
2413
2414
p_theme->set_color("v_line_primary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));
2415
p_theme->set_color("v_line_secondary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));
2416
p_theme->set_color("h_line_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));
2417
p_theme->set_color("font_primary_color", "AnimationTimelineEdit", p_config.font_color);
2418
p_theme->set_color("font_secondary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.5));
2419
2420
p_theme->set_constant("v_line_primary_margin", "AnimationTimelineEdit", 0);
2421
p_theme->set_constant("v_line_secondary_margin", "AnimationTimelineEdit", 0);
2422
p_theme->set_constant("v_line_primary_width", "AnimationTimelineEdit", 1 * EDSCALE);
2423
p_theme->set_constant("v_line_secondary_width", "AnimationTimelineEdit", 1 * EDSCALE);
2424
p_theme->set_constant("text_primary_margin", "AnimationTimelineEdit", 3 * EDSCALE);
2425
p_theme->set_constant("text_secondary_margin", "AnimationTimelineEdit", 3 * EDSCALE);
2426
2427
// AnimationTrackEdit.
2428
2429
Ref<StyleBoxFlat> style_animation_track_odd = make_flat_stylebox(Color(0.5, 0.5, 0.5, 0.05), 0, 0, 0, 0, p_config.corner_radius);
2430
Ref<StyleBoxFlat> style_animation_track_hover = make_flat_stylebox(Color(0.5, 0.5, 0.5, 0.1), 0, 0, 0, 0, p_config.corner_radius);
2431
2432
p_theme->set_stylebox("odd", "AnimationTrackEdit", style_animation_track_odd);
2433
p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEdit", style_animation_track_hover);
2434
p_theme->set_stylebox("focus", "AnimationTrackEdit", p_config.button_style_focus);
2435
2436
p_theme->set_color("h_line_color", "AnimationTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));
2437
2438
p_theme->set_constant("h_separation", "AnimationTrackEdit", (p_config.increased_margin + 2) * EDSCALE);
2439
p_theme->set_constant("outer_margin", "AnimationTrackEdit", p_config.increased_margin * 6 * EDSCALE);
2440
2441
// AnimationTrackEditGroup.
2442
2443
Ref<StyleBoxFlat> style_animation_track_header = make_flat_stylebox(p_config.dark_color_2 * Color(1, 1, 1, 0.6), p_config.increased_margin * 3, 0, 0, 0, p_config.corner_radius);
2444
2445
p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);
2446
2447
p_theme->set_color("h_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));
2448
p_theme->set_color("v_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));
2449
2450
p_theme->set_constant("h_separation", "AnimationTrackEditGroup", (p_config.increased_margin + 2) * EDSCALE);
2451
p_theme->set_constant("v_separation", "AnimationTrackEditGroup", 0);
2452
2453
// AnimationBezierTrackEdit.
2454
2455
p_theme->set_color("focus_color", "AnimationBezierTrackEdit", p_config.accent_color * Color(1, 1, 1, 0.7));
2456
p_theme->set_color("track_focus_color", "AnimationBezierTrackEdit", p_config.accent_color * Color(1, 1, 1, 0.5));
2457
p_theme->set_color("h_line_color", "AnimationBezierTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));
2458
p_theme->set_color("v_line_color", "AnimationBezierTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));
2459
2460
p_theme->set_constant("h_separation", "AnimationBezierTrackEdit", (p_config.increased_margin + 2) * EDSCALE);
2461
p_theme->set_constant("v_separation", "AnimationBezierTrackEdit", p_config.forced_even_separation * EDSCALE);
2462
}
2463
2464
// Editor help.
2465
{
2466
Ref<StyleBoxFlat> style_editor_help = p_config.base_style->duplicate();
2467
style_editor_help->set_bg_color(p_config.dark_color_2);
2468
style_editor_help->set_border_color(p_config.dark_color_3);
2469
p_theme->set_stylebox("background", "EditorHelp", style_editor_help);
2470
2471
const Color kbd_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5);
2472
2473
p_theme->set_color("title_color", "EditorHelp", p_config.accent_color);
2474
p_theme->set_color("headline_color", "EditorHelp", p_config.mono_color);
2475
p_theme->set_color("text_color", "EditorHelp", p_config.font_color);
2476
p_theme->set_color("comment_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));
2477
p_theme->set_color("symbol_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));
2478
p_theme->set_color("value_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));
2479
p_theme->set_color("qualifier_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.8));
2480
p_theme->set_color("type_color", "EditorHelp", p_config.accent_color.lerp(p_config.font_color, 0.5));
2481
p_theme->set_color("override_color", "EditorHelp", p_config.warning_color);
2482
p_theme->set_color("selection_color", "EditorHelp", p_config.selection_color);
2483
p_theme->set_color("link_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.8));
2484
p_theme->set_color("code_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.6));
2485
p_theme->set_color("kbd_color", "EditorHelp", p_config.accent_color.lerp(kbd_color, 0.6));
2486
p_theme->set_color("code_bg_color", "EditorHelp", p_config.dark_color_3);
2487
p_theme->set_color("kbd_bg_color", "EditorHelp", p_config.dark_color_1);
2488
p_theme->set_color("param_bg_color", "EditorHelp", p_config.dark_color_1);
2489
p_theme->set_constant(SceneStringName(line_separation), "EditorHelp", Math::round(6 * EDSCALE));
2490
p_theme->set_constant("table_h_separation", "EditorHelp", 16 * EDSCALE);
2491
p_theme->set_constant("table_v_separation", "EditorHelp", 6 * EDSCALE);
2492
p_theme->set_constant("text_highlight_h_padding", "EditorHelp", 1 * EDSCALE);
2493
p_theme->set_constant("text_highlight_v_padding", "EditorHelp", 2 * EDSCALE);
2494
}
2495
2496
// EditorHelpBitTitle.
2497
{
2498
Ref<StyleBoxFlat> style = p_config.tree_panel_style->duplicate();
2499
style->set_bg_color(p_config.dark_theme ? style->get_bg_color().lightened(0.04) : style->get_bg_color().darkened(0.04));
2500
style->set_border_color(p_config.dark_theme ? style->get_border_color().lightened(0.04) : style->get_border_color().darkened(0.04));
2501
style->set_corner_radius(CORNER_BOTTOM_LEFT, 0);
2502
style->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);
2503
2504
p_theme->set_type_variation("EditorHelpBitTitle", "RichTextLabel");
2505
p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitTitle", style);
2506
}
2507
2508
// EditorHelpBitContent.
2509
{
2510
Ref<StyleBoxFlat> style = p_config.tree_panel_style->duplicate();
2511
style->set_corner_radius(CORNER_TOP_LEFT, 0);
2512
style->set_corner_radius(CORNER_TOP_RIGHT, 0);
2513
2514
p_theme->set_type_variation("EditorHelpBitContent", "RichTextLabel");
2515
p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitContent", style);
2516
}
2517
2518
// Asset Library.
2519
p_theme->set_stylebox("bg", "AssetLib", p_config.base_empty_style);
2520
p_theme->set_stylebox(SceneStringName(panel), "AssetLib", p_config.content_panel_style);
2521
p_theme->set_color("status_color", "AssetLib", Color(0.5, 0.5, 0.5)); // FIXME: Use a defined color instead.
2522
p_theme->set_icon("dismiss", "AssetLib", p_theme->get_icon(SNAME("Close"), EditorStringName(EditorIcons)));
2523
2524
// Debugger.
2525
{
2526
Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate();
2527
debugger_panel_style->set_border_width(SIDE_BOTTOM, 0);
2528
p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style);
2529
2530
// This pattern of get_font()->get_height(get_font_size()) is used quite a lot and is very verbose.
2531
// FIXME: Introduce Theme::get_font_height() / Control::get_theme_font_height() / Window::get_theme_font_height().
2532
const int offset_i1 = p_theme->get_font(SNAME("tab_selected"), SNAME("TabContainer"))->get_height(p_theme->get_font_size(SNAME("tab_selected"), SNAME("TabContainer")));
2533
const int offset_i2 = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height;
2534
const int offset_i3 = p_theme->get_stylebox(SceneStringName(panel), SNAME("TabContainer"))->get_content_margin(SIDE_TOP);
2535
const int invisible_top_offset = offset_i1 + offset_i2 + offset_i3;
2536
2537
Ref<StyleBoxFlat> invisible_top_panel_style = p_config.content_panel_style->duplicate();
2538
invisible_top_panel_style->set_expand_margin(SIDE_TOP, -invisible_top_offset);
2539
invisible_top_panel_style->set_content_margin(SIDE_TOP, 0);
2540
p_theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), invisible_top_panel_style);
2541
}
2542
2543
// Resource and node editors.
2544
{
2545
// TextureRegion editor.
2546
Ref<StyleBoxFlat> style_texture_region_bg = p_config.tree_panel_style->duplicate();
2547
style_texture_region_bg->set_content_margin_all(0);
2548
p_theme->set_stylebox("TextureRegionPreviewBG", EditorStringName(EditorStyles), style_texture_region_bg);
2549
p_theme->set_stylebox("TextureRegionPreviewFG", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));
2550
2551
// Theme editor.
2552
{
2553
p_theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25));
2554
2555
Color theme_preview_picker_bg_color = p_config.accent_color;
2556
theme_preview_picker_bg_color.a = 0.2;
2557
Ref<StyleBoxFlat> theme_preview_picker_sb = make_flat_stylebox(theme_preview_picker_bg_color, 0, 0, 0, 0);
2558
theme_preview_picker_sb->set_border_color(p_config.accent_color);
2559
theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE);
2560
p_theme->set_stylebox("preview_picker_overlay", "ThemeEditor", theme_preview_picker_sb);
2561
2562
Color theme_preview_picker_label_bg_color = p_config.accent_color;
2563
theme_preview_picker_label_bg_color.set_v(0.5);
2564
Ref<StyleBoxFlat> theme_preview_picker_label_sb = make_flat_stylebox(theme_preview_picker_label_bg_color, 4.0, 1.0, 4.0, 3.0);
2565
p_theme->set_stylebox("preview_picker_label", "ThemeEditor", theme_preview_picker_label_sb);
2566
2567
Ref<StyleBoxFlat> style_theme_preview_tab = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainerOdd"))->duplicate();
2568
style_theme_preview_tab->set_expand_margin(SIDE_BOTTOM, 5 * EDSCALE);
2569
p_theme->set_stylebox("ThemeEditorPreviewFG", EditorStringName(EditorStyles), style_theme_preview_tab);
2570
2571
Ref<StyleBoxFlat> style_theme_preview_bg_tab = p_theme->get_stylebox(SNAME("tab_unselected"), SNAME("TabContainer"))->duplicate();
2572
style_theme_preview_bg_tab->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);
2573
p_theme->set_stylebox("ThemeEditorPreviewBG", EditorStringName(EditorStyles), style_theme_preview_bg_tab);
2574
}
2575
2576
// VisualShader editor.
2577
p_theme->set_stylebox("label_style", "VShaderEditor", make_empty_stylebox(4, 6, 4, 6));
2578
2579
// StateMachine graph.
2580
{
2581
p_theme->set_stylebox(SceneStringName(panel), "GraphStateMachine", p_config.tree_panel_style);
2582
p_theme->set_stylebox("error_panel", "GraphStateMachine", p_config.tree_panel_style);
2583
p_theme->set_color("error_color", "GraphStateMachine", p_config.error_color);
2584
2585
const int sm_margin_side = 10 * EDSCALE;
2586
const int sm_margin_bottom = 2;
2587
const Color sm_bg_color = p_config.dark_theme ? p_config.dark_color_3 : p_config.dark_color_1.lerp(p_config.mono_color, 0.09);
2588
2589
Ref<StyleBoxFlat> sm_node_style = make_flat_stylebox(p_config.dark_color_3 * Color(1, 1, 1, 0.7), sm_margin_side, 24 * EDSCALE, sm_margin_side, sm_margin_bottom, p_config.corner_radius);
2590
sm_node_style->set_border_width_all(p_config.border_width);
2591
sm_node_style->set_border_color(sm_bg_color);
2592
2593
Ref<StyleBoxFlat> sm_node_selected_style = make_flat_stylebox(sm_bg_color * Color(1, 1, 1, 0.9), sm_margin_side, 24 * EDSCALE, sm_margin_side, sm_margin_bottom, p_config.corner_radius);
2594
sm_node_selected_style->set_border_width_all(2 * EDSCALE + p_config.border_width);
2595
sm_node_selected_style->set_border_color(p_config.accent_color * Color(1, 1, 1, 0.9));
2596
sm_node_selected_style->set_shadow_size(8 * EDSCALE);
2597
sm_node_selected_style->set_shadow_color(p_config.shadow_color);
2598
2599
Ref<StyleBoxFlat> sm_node_playing_style = sm_node_selected_style->duplicate();
2600
sm_node_playing_style->set_border_color(p_config.warning_color);
2601
sm_node_playing_style->set_shadow_color(p_config.warning_color * Color(1, 1, 1, 0.2));
2602
sm_node_playing_style->set_draw_center(false);
2603
2604
p_theme->set_stylebox("node_frame", "GraphStateMachine", sm_node_style);
2605
p_theme->set_stylebox("node_frame_selected", "GraphStateMachine", sm_node_selected_style);
2606
p_theme->set_stylebox("node_frame_playing", "GraphStateMachine", sm_node_playing_style);
2607
2608
Ref<StyleBoxFlat> sm_node_start_style = sm_node_style->duplicate();
2609
sm_node_start_style->set_border_width_all(1 * EDSCALE);
2610
sm_node_start_style->set_border_color(p_config.success_color.lightened(0.24));
2611
p_theme->set_stylebox("node_frame_start", "GraphStateMachine", sm_node_start_style);
2612
2613
Ref<StyleBoxFlat> sm_node_end_style = sm_node_style->duplicate();
2614
sm_node_end_style->set_border_width_all(1 * EDSCALE);
2615
sm_node_end_style->set_border_color(p_config.error_color);
2616
p_theme->set_stylebox("node_frame_end", "GraphStateMachine", sm_node_end_style);
2617
2618
p_theme->set_font("node_title_font", "GraphStateMachine", p_theme->get_font(SceneStringName(font), SNAME("Label")));
2619
p_theme->set_font_size("node_title_font_size", "GraphStateMachine", p_theme->get_font_size(SceneStringName(font_size), SNAME("Label")));
2620
p_theme->set_color("node_title_font_color", "GraphStateMachine", p_config.font_color);
2621
2622
p_theme->set_color("transition_color", "GraphStateMachine", p_config.font_color);
2623
p_theme->set_color("transition_disabled_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.2));
2624
p_theme->set_color("transition_icon_color", "GraphStateMachine", Color(1, 1, 1));
2625
p_theme->set_color("transition_icon_disabled_color", "GraphStateMachine", Color(1, 1, 1, 0.2));
2626
p_theme->set_color("highlight_color", "GraphStateMachine", p_config.accent_color);
2627
p_theme->set_color("highlight_disabled_color", "GraphStateMachine", p_config.accent_color * Color(1, 1, 1, 0.6));
2628
p_theme->set_color("focus_color", "GraphStateMachine", p_config.accent_color);
2629
p_theme->set_color("guideline_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3));
2630
2631
p_theme->set_color("playback_color", "GraphStateMachine", p_config.font_color);
2632
p_theme->set_color("playback_background_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3));
2633
}
2634
}
2635
}
2636
2637
void _load_text_editor_theme() {
2638
EditorSettings *settings = EditorSettings::get_singleton();
2639
const String theme_name = settings->get_setting("text_editor/theme/color_theme");
2640
2641
ERR_FAIL_COND(EditorSettings::is_default_text_editor_theme(theme_name.get_file().to_lower()));
2642
2643
const String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(theme_name + ".tet");
2644
2645
Ref<ConfigFile> cf;
2646
cf.instantiate();
2647
Error err = cf->load(theme_path);
2648
ERR_FAIL_COND_MSG(err != OK, vformat("Failed to load text editor theme file '%s': %s", theme_name, error_names[err]));
2649
2650
const PackedStringArray keys = cf->get_section_keys("color_theme");
2651
2652
for (const String &key : keys) {
2653
const String setting_key = "text_editor/theme/highlighting/" + key;
2654
// Don't load if it's not an actual setting, or if it isn't a color setting.
2655
if (!settings->has_setting(setting_key) || !key.contains("color")) {
2656
continue;
2657
}
2658
const String val = cf->get_value("color_theme", key);
2659
// Make sure it is actually a color.
2660
if (val.is_valid_html_color()) {
2661
const Color color_value = Color::html(val);
2662
// Change manually to prevent settings_changed spam.
2663
settings->set_initial_value(setting_key, color_value);
2664
settings->set_manually(setting_key, color_value);
2665
}
2666
}
2667
// If it doesn't load a setting just use what is currently loaded.
2668
}
2669
2670
void EditorThemeManager::_populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
2671
const String text_editor_color_theme = EDITOR_GET("text_editor/theme/color_theme");
2672
const bool is_default_theme = text_editor_color_theme == "Default";
2673
const bool is_godot2_theme = text_editor_color_theme == "Godot 2";
2674
const bool is_custom_theme = text_editor_color_theme == "Custom";
2675
if (is_default_theme || is_godot2_theme || is_custom_theme) {
2676
HashMap<StringName, Color> colors;
2677
if (is_default_theme || is_custom_theme) {
2678
// Adaptive colors for comments and elements with lower relevance.
2679
const Color dim_color = Color(p_config.font_color, 0.5);
2680
const float mono_value = p_config.mono_color.r;
2681
const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);
2682
const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);
2683
const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.27);
2684
2685
// Syntax highlight token colors.
2686
colors["text_editor/theme/highlighting/symbol_color"] = p_config.dark_theme ? Color(0.67, 0.79, 1) : Color(0, 0, 0.61);
2687
colors["text_editor/theme/highlighting/keyword_color"] = p_config.dark_theme ? Color(1.0, 0.44, 0.52) : Color(0.9, 0.135, 0.51);
2688
colors["text_editor/theme/highlighting/control_flow_keyword_color"] = p_config.dark_theme ? Color(1.0, 0.55, 0.8) : Color(0.743, 0.12, 0.8);
2689
colors["text_editor/theme/highlighting/base_type_color"] = p_config.dark_theme ? Color(0.26, 1.0, 0.76) : Color(0, 0.6, 0.2);
2690
colors["text_editor/theme/highlighting/engine_type_color"] = p_config.dark_theme ? Color(0.56, 1, 0.86) : Color(0.11, 0.55, 0.4);
2691
colors["text_editor/theme/highlighting/user_type_color"] = p_config.dark_theme ? Color(0.78, 1, 0.93) : Color(0.18, 0.45, 0.4);
2692
colors["text_editor/theme/highlighting/comment_color"] = p_config.dark_theme ? dim_color : Color(0.08, 0.08, 0.08, 0.5);
2693
colors["text_editor/theme/highlighting/doc_comment_color"] = p_config.dark_theme ? Color(0.6, 0.7, 0.8, 0.8) : Color(0.15, 0.15, 0.4, 0.7);
2694
colors["text_editor/theme/highlighting/string_color"] = p_config.dark_theme ? Color(1, 0.93, 0.63) : Color(0.6, 0.42, 0);
2695
2696
// Use the brightest background color on a light theme (which generally uses a negative contrast rate).
2697
colors["text_editor/theme/highlighting/background_color"] = p_config.dark_theme ? p_config.dark_color_2 : p_config.dark_color_3;
2698
colors["text_editor/theme/highlighting/completion_background_color"] = p_config.dark_theme ? p_config.base_color : p_config.dark_color_2;
2699
colors["text_editor/theme/highlighting/completion_selected_color"] = alpha1;
2700
colors["text_editor/theme/highlighting/completion_existing_color"] = alpha2;
2701
// Same opacity as the scroll grabber editor icon.
2702
colors["text_editor/theme/highlighting/completion_scroll_color"] = Color(mono_value, mono_value, mono_value, 0.29);
2703
colors["text_editor/theme/highlighting/completion_scroll_hovered_color"] = Color(mono_value, mono_value, mono_value, 0.4);
2704
colors["text_editor/theme/highlighting/completion_font_color"] = p_config.font_color;
2705
colors["text_editor/theme/highlighting/text_color"] = p_config.font_color;
2706
colors["text_editor/theme/highlighting/line_number_color"] = dim_color;
2707
colors["text_editor/theme/highlighting/safe_line_number_color"] = p_config.dark_theme ? (dim_color * Color(1, 1.2, 1, 1.5)) : Color(0, 0.4, 0, 0.75);
2708
colors["text_editor/theme/highlighting/caret_color"] = p_config.mono_color;
2709
colors["text_editor/theme/highlighting/caret_background_color"] = p_config.mono_color.inverted();
2710
colors["text_editor/theme/highlighting/text_selected_color"] = Color(0, 0, 0, 0);
2711
colors["text_editor/theme/highlighting/selection_color"] = p_config.selection_color;
2712
colors["text_editor/theme/highlighting/brace_mismatch_color"] = p_config.dark_theme ? p_config.error_color : Color(1, 0.08, 0, 1);
2713
colors["text_editor/theme/highlighting/current_line_color"] = alpha1;
2714
colors["text_editor/theme/highlighting/line_length_guideline_color"] = p_config.dark_theme ? p_config.base_color : p_config.dark_color_2;
2715
colors["text_editor/theme/highlighting/word_highlighted_color"] = alpha1;
2716
colors["text_editor/theme/highlighting/number_color"] = p_config.dark_theme ? Color(0.63, 1, 0.88) : Color(0, 0.55, 0.28, 1);
2717
colors["text_editor/theme/highlighting/function_color"] = p_config.dark_theme ? Color(0.34, 0.7, 1.0) : Color(0, 0.225, 0.9, 1);
2718
colors["text_editor/theme/highlighting/member_variable_color"] = p_config.dark_theme ? Color(0.34, 0.7, 1.0).lerp(p_config.mono_color, 0.6) : Color(0, 0.4, 0.68, 1);
2719
colors["text_editor/theme/highlighting/mark_color"] = Color(p_config.error_color.r, p_config.error_color.g, p_config.error_color.b, 0.3);
2720
colors["text_editor/theme/highlighting/warning_color"] = Color(p_config.warning_color.r, p_config.warning_color.g, p_config.warning_color.b, 0.15);
2721
colors["text_editor/theme/highlighting/bookmark_color"] = Color(0.08, 0.49, 0.98);
2722
colors["text_editor/theme/highlighting/breakpoint_color"] = p_config.dark_theme ? p_config.error_color : Color(1, 0.27, 0.2, 1);
2723
colors["text_editor/theme/highlighting/executing_line_color"] = Color(0.98, 0.89, 0.27);
2724
colors["text_editor/theme/highlighting/code_folding_color"] = alpha3;
2725
colors["text_editor/theme/highlighting/folded_code_region_color"] = Color(0.68, 0.46, 0.77, 0.2);
2726
colors["text_editor/theme/highlighting/search_result_color"] = alpha1;
2727
colors["text_editor/theme/highlighting/search_result_border_color"] = p_config.dark_theme ? Color(0.41, 0.61, 0.91, 0.38) : Color(0, 0.4, 1, 0.38);
2728
2729
if (p_config.dark_theme) {
2730
colors["text_editor/theme/highlighting/gdscript/function_definition_color"] = Color(0.4, 0.9, 1.0);
2731
colors["text_editor/theme/highlighting/gdscript/global_function_color"] = Color(0.64, 0.64, 0.96);
2732
colors["text_editor/theme/highlighting/gdscript/node_path_color"] = Color(0.72, 0.77, 0.49);
2733
colors["text_editor/theme/highlighting/gdscript/node_reference_color"] = Color(0.39, 0.76, 0.35);
2734
colors["text_editor/theme/highlighting/gdscript/annotation_color"] = Color(1.0, 0.7, 0.45);
2735
colors["text_editor/theme/highlighting/gdscript/string_name_color"] = Color(1.0, 0.76, 0.65);
2736
colors["text_editor/theme/highlighting/comment_markers/critical_color"] = Color(0.77, 0.35, 0.35);
2737
colors["text_editor/theme/highlighting/comment_markers/warning_color"] = Color(0.72, 0.61, 0.48);
2738
colors["text_editor/theme/highlighting/comment_markers/notice_color"] = Color(0.56, 0.67, 0.51);
2739
} else {
2740
colors["text_editor/theme/highlighting/gdscript/function_definition_color"] = Color(0, 0.6, 0.6);
2741
colors["text_editor/theme/highlighting/gdscript/global_function_color"] = Color(0.36, 0.18, 0.72);
2742
colors["text_editor/theme/highlighting/gdscript/node_path_color"] = Color(0.18, 0.55, 0);
2743
colors["text_editor/theme/highlighting/gdscript/node_reference_color"] = Color(0.0, 0.5, 0);
2744
colors["text_editor/theme/highlighting/gdscript/annotation_color"] = Color(0.8, 0.37, 0);
2745
colors["text_editor/theme/highlighting/gdscript/string_name_color"] = Color(0.8, 0.56, 0.45);
2746
colors["text_editor/theme/highlighting/comment_markers/critical_color"] = Color(0.8, 0.14, 0.14);
2747
colors["text_editor/theme/highlighting/comment_markers/warning_color"] = Color(0.75, 0.39, 0.03);
2748
colors["text_editor/theme/highlighting/comment_markers/notice_color"] = Color(0.24, 0.54, 0.09);
2749
}
2750
} else if (is_godot2_theme) {
2751
colors = EditorSettings::get_godot2_text_editor_theme();
2752
}
2753
EditorSettings *settings = EditorSettings::get_singleton();
2754
for (const KeyValue<StringName, Color> &setting : colors) {
2755
settings->set_initial_value(setting.key, setting.value);
2756
if (is_default_theme || is_godot2_theme) {
2757
settings->set_manually(setting.key, setting.value);
2758
}
2759
}
2760
} else {
2761
// Custom user theme.
2762
_load_text_editor_theme();
2763
}
2764
2765
// Now theme is loaded, apply it to CodeEdit.
2766
p_theme->set_font(SceneStringName(font), "CodeEdit", p_theme->get_font(SNAME("source"), EditorStringName(EditorFonts)));
2767
p_theme->set_font_size(SceneStringName(font_size), "CodeEdit", p_theme->get_font_size(SNAME("source_size"), EditorStringName(EditorFonts)));
2768
2769
/* clang-format off */
2770
p_theme->set_icon("tab", "CodeEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));
2771
p_theme->set_icon("space", "CodeEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));
2772
p_theme->set_icon("folded", "CodeEdit", p_theme->get_icon(SNAME("CodeFoldedRightArrow"), EditorStringName(EditorIcons)));
2773
p_theme->set_icon("can_fold", "CodeEdit", p_theme->get_icon(SNAME("CodeFoldDownArrow"), EditorStringName(EditorIcons)));
2774
p_theme->set_icon("folded_code_region", "CodeEdit", p_theme->get_icon(SNAME("CodeRegionFoldedRightArrow"), EditorStringName(EditorIcons)));
2775
p_theme->set_icon("can_fold_code_region", "CodeEdit", p_theme->get_icon(SNAME("CodeRegionFoldDownArrow"), EditorStringName(EditorIcons)));
2776
p_theme->set_icon("executing_line", "CodeEdit", p_theme->get_icon(SNAME("TextEditorPlay"), EditorStringName(EditorIcons)));
2777
p_theme->set_icon("breakpoint", "CodeEdit", p_theme->get_icon(SNAME("Breakpoint"), EditorStringName(EditorIcons)));
2778
/* clang-format on */
2779
2780
p_theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));
2781
2782
const Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color");
2783
Ref<StyleBoxFlat> code_edit_stylebox = make_flat_stylebox(background_color, p_config.widget_margin.x, p_config.widget_margin.y, p_config.widget_margin.x, p_config.widget_margin.y, p_config.corner_radius);
2784
p_theme->set_stylebox(CoreStringName(normal), "CodeEdit", code_edit_stylebox);
2785
p_theme->set_stylebox("read_only", "CodeEdit", code_edit_stylebox);
2786
p_theme->set_stylebox("focus", "CodeEdit", memnew(StyleBoxEmpty));
2787
2788
p_theme->set_color("background_color", "CodeEdit", Color(0, 0, 0, 0)); // Unset any color, we use a stylebox.
2789
2790
/* clang-format off */
2791
p_theme->set_color("completion_background_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_background_color"));
2792
p_theme->set_color("completion_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_selected_color"));
2793
p_theme->set_color("completion_existing_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_existing_color"));
2794
p_theme->set_color("completion_scroll_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_color"));
2795
p_theme->set_color("completion_scroll_hovered_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_hovered_color"));
2796
p_theme->set_color(SceneStringName(font_color), "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_color"));
2797
p_theme->set_color("line_number_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_number_color"));
2798
p_theme->set_color("caret_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/caret_color"));
2799
p_theme->set_color("font_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_selected_color"));
2800
p_theme->set_color("selection_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/selection_color"));
2801
p_theme->set_color("brace_mismatch_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/brace_mismatch_color"));
2802
p_theme->set_color("current_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/current_line_color"));
2803
p_theme->set_color("line_length_guideline_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_length_guideline_color"));
2804
p_theme->set_color("word_highlighted_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/word_highlighted_color"));
2805
p_theme->set_color("bookmark_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/bookmark_color"));
2806
p_theme->set_color("breakpoint_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/breakpoint_color"));
2807
p_theme->set_color("executing_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/executing_line_color"));
2808
p_theme->set_color("code_folding_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/code_folding_color"));
2809
p_theme->set_color("folded_code_region_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/folded_code_region_color"));
2810
p_theme->set_color("search_result_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_color"));
2811
p_theme->set_color("search_result_border_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_border_color"));
2812
/* clang-format on */
2813
}
2814
2815
void EditorThemeManager::_populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {
2816
EditorSettings *ed_settings = EditorSettings::get_singleton();
2817
String visual_shader_color_theme = ed_settings->get("editors/visual_editors/color_theme");
2818
if (visual_shader_color_theme == "Default") {
2819
// Connection type colors
2820
ed_settings->set_initial_value("editors/visual_editors/connection_colors/scalar_color", Color(0.55, 0.55, 0.55), true);
2821
ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector2_color", Color(0.44, 0.43, 0.64), true);
2822
ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector3_color", Color(0.337, 0.314, 0.71), true);
2823
ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector4_color", Color(0.7, 0.65, 0.147), true);
2824
ed_settings->set_initial_value("editors/visual_editors/connection_colors/boolean_color", Color(0.243, 0.612, 0.349), true);
2825
ed_settings->set_initial_value("editors/visual_editors/connection_colors/transform_color", Color(0.71, 0.357, 0.64), true);
2826
ed_settings->set_initial_value("editors/visual_editors/connection_colors/sampler_color", Color(0.659, 0.4, 0.137), true);
2827
2828
// Node category colors (used for the node headers)
2829
ed_settings->set_initial_value("editors/visual_editors/category_colors/output_color", Color(0.26, 0.10, 0.15), true);
2830
ed_settings->set_initial_value("editors/visual_editors/category_colors/color_color", Color(0.5, 0.5, 0.1), true);
2831
ed_settings->set_initial_value("editors/visual_editors/category_colors/conditional_color", Color(0.208, 0.522, 0.298), true);
2832
ed_settings->set_initial_value("editors/visual_editors/category_colors/input_color", Color(0.502, 0.2, 0.204), true);
2833
ed_settings->set_initial_value("editors/visual_editors/category_colors/scalar_color", Color(0.1, 0.5, 0.6), true);
2834
ed_settings->set_initial_value("editors/visual_editors/category_colors/textures_color", Color(0.5, 0.3, 0.1), true);
2835
ed_settings->set_initial_value("editors/visual_editors/category_colors/transform_color", Color(0.5, 0.3, 0.5), true);
2836
ed_settings->set_initial_value("editors/visual_editors/category_colors/utility_color", Color(0.2, 0.2, 0.2), true);
2837
ed_settings->set_initial_value("editors/visual_editors/category_colors/vector_color", Color(0.2, 0.2, 0.5), true);
2838
ed_settings->set_initial_value("editors/visual_editors/category_colors/special_color", Color(0.098, 0.361, 0.294), true);
2839
ed_settings->set_initial_value("editors/visual_editors/category_colors/particle_color", Color(0.12, 0.358, 0.8), true);
2840
2841
} else if (visual_shader_color_theme == "Legacy") {
2842
// Connection type colors
2843
ed_settings->set_initial_value("editors/visual_editors/connection_colors/scalar_color", Color(0.38, 0.85, 0.96), true);
2844
ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector2_color", Color(0.74, 0.57, 0.95), true);
2845
ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector3_color", Color(0.84, 0.49, 0.93), true);
2846
ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector4_color", Color(1.0, 0.125, 0.95), true);
2847
ed_settings->set_initial_value("editors/visual_editors/connection_colors/boolean_color", Color(0.55, 0.65, 0.94), true);
2848
ed_settings->set_initial_value("editors/visual_editors/connection_colors/transform_color", Color(0.96, 0.66, 0.43), true);
2849
ed_settings->set_initial_value("editors/visual_editors/connection_colors/sampler_color", Color(1.0, 1.0, 0.0), true);
2850
2851
// Node category colors (used for the node headers)
2852
Ref<StyleBoxFlat> gn_panel_style = p_theme->get_stylebox(SceneStringName(panel), "GraphNode");
2853
Color gn_bg_color = gn_panel_style->get_bg_color();
2854
ed_settings->set_initial_value("editors/visual_editors/category_colors/output_color", gn_bg_color, true);
2855
ed_settings->set_initial_value("editors/visual_editors/category_colors/color_color", gn_bg_color, true);
2856
ed_settings->set_initial_value("editors/visual_editors/category_colors/conditional_color", gn_bg_color, true);
2857
ed_settings->set_initial_value("editors/visual_editors/category_colors/input_color", gn_bg_color, true);
2858
ed_settings->set_initial_value("editors/visual_editors/category_colors/scalar_color", gn_bg_color, true);
2859
ed_settings->set_initial_value("editors/visual_editors/category_colors/textures_color", gn_bg_color, true);
2860
ed_settings->set_initial_value("editors/visual_editors/category_colors/transform_color", gn_bg_color, true);
2861
ed_settings->set_initial_value("editors/visual_editors/category_colors/utility_color", gn_bg_color, true);
2862
ed_settings->set_initial_value("editors/visual_editors/category_colors/vector_color", gn_bg_color, true);
2863
ed_settings->set_initial_value("editors/visual_editors/category_colors/special_color", gn_bg_color, true);
2864
ed_settings->set_initial_value("editors/visual_editors/category_colors/particle_color", gn_bg_color, true);
2865
}
2866
}
2867
2868
void EditorThemeManager::_reset_dirty_flag() {
2869
outdated_cache_dirty = true;
2870
}
2871
2872
// Public interface for theme generation.
2873
2874
Ref<EditorTheme> EditorThemeManager::generate_theme(const Ref<EditorTheme> &p_old_theme) {
2875
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Generate Theme");
2876
2877
Ref<EditorTheme> theme = _create_base_theme(p_old_theme);
2878
2879
OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Merge Custom Theme");
2880
2881
const String custom_theme_path = EDITOR_GET("interface/theme/custom_theme");
2882
if (!custom_theme_path.is_empty()) {
2883
Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path);
2884
if (custom_theme.is_valid()) {
2885
theme->merge_with(custom_theme);
2886
}
2887
}
2888
2889
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Merge Custom Theme");
2890
2891
OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Generate Theme");
2892
benchmark_run++;
2893
2894
return theme;
2895
}
2896
2897
bool EditorThemeManager::is_generated_theme_outdated() {
2898
// This list includes settings used by files in the editor/themes folder.
2899
// Note that the editor scale is purposefully omitted because it cannot be changed
2900
// without a restart, so there is no point regenerating the theme.
2901
2902
if (outdated_cache_dirty) {
2903
// TODO: We can use this information more intelligently to do partial theme updates and speed things up.
2904
outdated_cache = EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") ||
2905
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/font") ||
2906
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/main_font") ||
2907
EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/code_font") ||
2908
EditorSettings::get_singleton()->check_changed_settings_in_group("editors/visual_editors") ||
2909
EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||
2910
EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/help/help") ||
2911
EditorSettings::get_singleton()->check_changed_settings_in_group("docks/property_editor/subresource_hue_tint") ||
2912
EditorSettings::get_singleton()->check_changed_settings_in_group("filesystem/file_dialog/thumbnail_size") ||
2913
EditorSettings::get_singleton()->check_changed_settings_in_group("run/output/font_size");
2914
2915
// The outdated flag is relevant at the moment of changing editor settings.
2916
callable_mp_static(&EditorThemeManager::_reset_dirty_flag).call_deferred();
2917
outdated_cache_dirty = false;
2918
}
2919
2920
return outdated_cache;
2921
}
2922
2923
bool EditorThemeManager::is_dark_theme() {
2924
// Light color mode for icons and fonts means it's a dark theme, and vice versa.
2925
int icon_font_color_setting = EDITOR_GET("interface/theme/icon_and_font_color");
2926
2927
if (icon_font_color_setting == ColorMode::AUTO_COLOR) {
2928
Color base_color = EDITOR_GET("interface/theme/base_color");
2929
return base_color.get_luminance() < 0.5;
2930
}
2931
2932
return icon_font_color_setting == ColorMode::LIGHT_COLOR;
2933
}
2934
2935
void EditorThemeManager::initialize() {
2936
EditorColorMap::create();
2937
EditorTheme::initialize();
2938
}
2939
2940
void EditorThemeManager::finalize() {
2941
EditorColorMap::finish();
2942
EditorTheme::finalize();
2943
}
2944
2945