Path: blob/master/editor/themes/editor_theme_manager.cpp
9898 views
/**************************************************************************/1/* editor_theme_manager.cpp */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#include "editor_theme_manager.h"3132#include "core/error/error_macros.h"33#include "core/io/resource_loader.h"34#include "editor/editor_string_names.h"35#include "editor/file_system/editor_paths.h"36#include "editor/settings/editor_settings.h"37#include "editor/themes/editor_color_map.h"38#include "editor/themes/editor_fonts.h"39#include "editor/themes/editor_icons.h"40#include "editor/themes/editor_scale.h"41#include "editor/themes/editor_theme.h"42#include "scene/gui/graph_edit.h"43#include "scene/resources/dpi_texture.h"44#include "scene/resources/image_texture.h"45#include "scene/resources/style_box_flat.h"46#include "scene/resources/style_box_line.h"47#include "scene/resources/style_box_texture.h"48#include "scene/resources/texture.h"4950// Theme configuration.5152uint32_t EditorThemeManager::ThemeConfiguration::hash() {53uint32_t hash = hash_murmur3_one_float(EDSCALE);5455// Basic properties.5657hash = hash_murmur3_one_32(preset.hash(), hash);58hash = hash_murmur3_one_32(spacing_preset.hash(), hash);5960hash = hash_murmur3_one_32(base_color.to_rgba32(), hash);61hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);62hash = hash_murmur3_one_float(contrast, hash);63hash = hash_murmur3_one_float(icon_saturation, hash);6465// Extra properties.6667hash = hash_murmur3_one_32(base_spacing, hash);68hash = hash_murmur3_one_32(extra_spacing, hash);69hash = hash_murmur3_one_32(border_width, hash);70hash = hash_murmur3_one_32(corner_radius, hash);7172hash = hash_murmur3_one_32((int)draw_extra_borders, hash);73hash = hash_murmur3_one_float(relationship_line_opacity, hash);74hash = hash_murmur3_one_32(thumb_size, hash);75hash = hash_murmur3_one_32(class_icon_size, hash);76hash = hash_murmur3_one_32((int)enable_touch_optimizations, hash);77hash = hash_murmur3_one_float(gizmo_handle_scale, hash);78hash = hash_murmur3_one_32(color_picker_button_height, hash);79hash = hash_murmur3_one_float(subresource_hue_tint, hash);8081hash = hash_murmur3_one_float(default_contrast, hash);8283// Generated properties.8485hash = hash_murmur3_one_32((int)dark_theme, hash);8687return hash;88}8990uint32_t EditorThemeManager::ThemeConfiguration::hash_fonts() {91uint32_t hash = hash_murmur3_one_float(EDSCALE);9293// TODO: Implement the hash based on what editor_register_fonts() uses.9495return hash;96}9798uint32_t EditorThemeManager::ThemeConfiguration::hash_icons() {99uint32_t hash = hash_murmur3_one_float(EDSCALE);100101hash = hash_murmur3_one_32(accent_color.to_rgba32(), hash);102hash = hash_murmur3_one_float(icon_saturation, hash);103104hash = hash_murmur3_one_32(thumb_size, hash);105hash = hash_murmur3_one_float(gizmo_handle_scale, hash);106107hash = hash_murmur3_one_32((int)dark_theme, hash);108109return hash;110}111112// Benchmarks.113114int EditorThemeManager::benchmark_run = 0;115116String EditorThemeManager::get_benchmark_key() {117if (benchmark_run == 0) {118return "EditorTheme (Startup)";119}120121return vformat("EditorTheme (Run %d)", benchmark_run);122}123124// Generation helper methods.125126Ref<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) {127Ref<StyleBoxTexture> style(memnew(StyleBoxTexture));128style->set_texture(p_texture);129style->set_texture_margin_individual(p_left * EDSCALE, p_top * EDSCALE, p_right * EDSCALE, p_bottom * EDSCALE);130style->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);131style->set_draw_center(p_draw_center);132return style;133}134135Ref<StyleBoxEmpty> make_empty_stylebox(float p_margin_left = -1, float p_margin_top = -1, float p_margin_right = -1, float p_margin_bottom = -1) {136Ref<StyleBoxEmpty> style(memnew(StyleBoxEmpty));137style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);138return style;139}140141Ref<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) {142Ref<StyleBoxFlat> style(memnew(StyleBoxFlat));143style->set_bg_color(p_color);144// Adjust level of detail based on the corners' effective sizes.145style->set_corner_detail(Math::ceil(0.8 * p_corner_width * EDSCALE));146style->set_corner_radius_all(p_corner_width * EDSCALE);147style->set_content_margin_individual(p_margin_left * EDSCALE, p_margin_top * EDSCALE, p_margin_right * EDSCALE, p_margin_bottom * EDSCALE);148// Work around issue about antialiased edges being blurrier (GH-35279).149style->set_anti_aliased(false);150return style;151}152153Ref<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) {154Ref<StyleBoxLine> style(memnew(StyleBoxLine));155style->set_color(p_color);156style->set_grow_begin(p_grow_begin);157style->set_grow_end(p_grow_end);158style->set_thickness(p_thickness);159style->set_vertical(p_vertical);160return style;161}162163// Theme generation and population routines.164165Ref<EditorTheme> EditorThemeManager::_create_base_theme(const Ref<EditorTheme> &p_old_theme) {166OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Create Base Theme");167168Ref<EditorTheme> theme = memnew(EditorTheme);169ThemeConfiguration config = _create_theme_config(theme);170theme->set_generated_hash(config.hash());171theme->set_generated_fonts_hash(config.hash_fonts());172theme->set_generated_icons_hash(config.hash_icons());173174print_verbose(vformat("EditorTheme: Generating new theme for the config '%d'.", theme->get_generated_hash()));175176_create_shared_styles(theme, config);177178// Register icons.179{180OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Icons");181182// External functions, see editor_icons.cpp.183editor_configure_icons(config.dark_theme);184185// If settings are comparable to the old theme, then just copy existing icons over.186// Otherwise, regenerate them.187bool keep_old_icons = (p_old_theme.is_valid() && theme->get_generated_icons_hash() == p_old_theme->get_generated_icons_hash());188if (keep_old_icons) {189print_verbose("EditorTheme: Can keep old icons, copying.");190editor_copy_icons(theme, p_old_theme);191} else {192print_verbose("EditorTheme: Generating new icons.");193editor_register_icons(theme, config.dark_theme, config.icon_saturation, config.thumb_size, config.gizmo_handle_scale);194}195196OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Icons");197}198199// Register fonts.200{201OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Register Fonts");202203// TODO: Check if existing font definitions from the old theme are usable and copy them.204205// External function, see editor_fonts.cpp.206print_verbose("EditorTheme: Generating new fonts.");207editor_register_fonts(theme);208209OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Register Fonts");210}211212// TODO: Check if existing style definitions from the old theme are usable and copy them.213214print_verbose("EditorTheme: Generating new styles.");215_populate_standard_styles(theme, config);216_populate_editor_styles(theme, config);217_populate_text_editor_styles(theme, config);218_populate_visual_shader_styles(theme, config);219220OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Create Base Theme");221return theme;222}223224EditorThemeManager::ThemeConfiguration EditorThemeManager::_create_theme_config(const Ref<EditorTheme> &p_theme) {225ThemeConfiguration config;226227// Basic properties.228229config.preset = EDITOR_GET("interface/theme/preset");230config.spacing_preset = EDITOR_GET("interface/theme/spacing_preset");231232config.base_color = EDITOR_GET("interface/theme/base_color");233config.accent_color = EDITOR_GET("interface/theme/accent_color");234config.contrast = EDITOR_GET("interface/theme/contrast");235config.icon_saturation = EDITOR_GET("interface/theme/icon_saturation");236237// Extra properties.238239config.base_spacing = EDITOR_GET("interface/theme/base_spacing");240config.extra_spacing = EDITOR_GET("interface/theme/additional_spacing");241// Ensure borders are visible when using an editor scale below 100%.242config.border_width = CLAMP((int)EDITOR_GET("interface/theme/border_size"), 0, 2) * MAX(1, EDSCALE);243config.corner_radius = CLAMP((int)EDITOR_GET("interface/theme/corner_radius"), 0, 6);244245config.draw_extra_borders = EDITOR_GET("interface/theme/draw_extra_borders");246config.relationship_line_opacity = EDITOR_GET("interface/theme/relationship_line_opacity");247config.thumb_size = EDITOR_GET("filesystem/file_dialog/thumbnail_size");248config.class_icon_size = 16 * EDSCALE;249config.enable_touch_optimizations = EDITOR_GET("interface/touchscreen/enable_touch_optimizations");250config.gizmo_handle_scale = EDITOR_GET("interface/touchscreen/scale_gizmo_handles");251config.color_picker_button_height = 28 * EDSCALE;252config.subresource_hue_tint = EDITOR_GET("docks/property_editor/subresource_hue_tint");253254config.default_contrast = 0.3; // Make sure to keep this in sync with the editor settings definition.255256// Handle main theme preset.257{258const bool follow_system_theme = EDITOR_GET("interface/theme/follow_system_theme");259const bool use_system_accent_color = EDITOR_GET("interface/theme/use_system_accent_color");260DisplayServer *display_server = DisplayServer::get_singleton();261Color system_base_color = display_server->get_base_color();262Color system_accent_color = display_server->get_accent_color();263264if (follow_system_theme) {265String dark_theme = "Default";266String light_theme = "Light";267268config.preset = light_theme; // Assume light theme if we can't detect system theme attributes.269270if (system_base_color == Color(0, 0, 0, 0)) {271if (display_server->is_dark_mode_supported() && display_server->is_dark_mode()) {272config.preset = dark_theme;273}274} else {275if (system_base_color.get_luminance() < 0.5) {276config.preset = dark_theme;277}278}279}280281if (config.preset != "Custom") {282Color preset_accent_color;283Color preset_base_color;284float preset_contrast = 0;285bool preset_draw_extra_borders = false;286287// Please use alphabetical order if you're adding a new theme here.288if (config.preset == "Breeze Dark") {289preset_accent_color = Color(0.26, 0.76, 1.00);290preset_base_color = Color(0.24, 0.26, 0.28);291preset_contrast = config.default_contrast;292} else if (config.preset == "Godot 2") {293preset_accent_color = Color(0.53, 0.67, 0.89);294preset_base_color = Color(0.24, 0.23, 0.27);295preset_contrast = config.default_contrast;296} else if (config.preset == "Gray") {297preset_accent_color = Color(0.44, 0.73, 0.98);298preset_base_color = Color(0.24, 0.24, 0.24);299preset_contrast = config.default_contrast;300} else if (config.preset == "Light") {301preset_accent_color = Color(0.18, 0.50, 1.00);302preset_base_color = Color(0.9, 0.9, 0.9);303// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".304preset_contrast = -0.06;305} else if (config.preset == "Solarized (Dark)") {306preset_accent_color = Color(0.15, 0.55, 0.82);307preset_base_color = Color(0.03, 0.21, 0.26);308preset_contrast = 0.23;309} else if (config.preset == "Solarized (Light)") {310preset_accent_color = Color(0.15, 0.55, 0.82);311preset_base_color = Color(0.89, 0.86, 0.79);312// A negative contrast rate looks better for light themes, since it better follows the natural order of UI "elevation".313preset_contrast = -0.06;314} else if (config.preset == "Black (OLED)") {315preset_accent_color = Color(0.45, 0.75, 1.0);316preset_base_color = Color(0, 0, 0);317// The contrast rate value is irrelevant on a fully black theme.318preset_contrast = 0.0;319preset_draw_extra_borders = true;320} else { // Default321preset_accent_color = Color(0.44, 0.73, 0.98);322preset_base_color = Color(0.21, 0.24, 0.29);323preset_contrast = config.default_contrast;324}325326config.accent_color = preset_accent_color;327config.base_color = preset_base_color;328config.contrast = preset_contrast;329config.draw_extra_borders = preset_draw_extra_borders;330331EditorSettings::get_singleton()->set_initial_value("interface/theme/accent_color", config.accent_color);332EditorSettings::get_singleton()->set_initial_value("interface/theme/base_color", config.base_color);333EditorSettings::get_singleton()->set_initial_value("interface/theme/contrast", config.contrast);334EditorSettings::get_singleton()->set_initial_value("interface/theme/draw_extra_borders", config.draw_extra_borders);335}336337if (follow_system_theme && system_base_color != Color(0, 0, 0, 0)) {338config.base_color = system_base_color;339config.preset = "Custom";340}341342if (use_system_accent_color && system_accent_color != Color(0, 0, 0, 0)) {343config.accent_color = system_accent_color;344config.preset = "Custom";345}346347// Enforce values in case they were adjusted or overridden.348EditorSettings::get_singleton()->set_manually("interface/theme/preset", config.preset);349EditorSettings::get_singleton()->set_manually("interface/theme/accent_color", config.accent_color);350EditorSettings::get_singleton()->set_manually("interface/theme/base_color", config.base_color);351EditorSettings::get_singleton()->set_manually("interface/theme/contrast", config.contrast);352EditorSettings::get_singleton()->set_manually("interface/theme/draw_extra_borders", config.draw_extra_borders);353}354355// Handle theme spacing preset.356{357if (config.spacing_preset != "Custom") {358int preset_base_spacing = 0;359int preset_extra_spacing = 0;360Size2 preset_dialogs_buttons_min_size;361362if (config.spacing_preset == "Compact") {363preset_base_spacing = 0;364preset_extra_spacing = 4;365preset_dialogs_buttons_min_size = Size2(90, 26);366} else if (config.spacing_preset == "Spacious") {367preset_base_spacing = 6;368preset_extra_spacing = 2;369preset_dialogs_buttons_min_size = Size2(112, 36);370} else { // Default371preset_base_spacing = 4;372preset_extra_spacing = 0;373preset_dialogs_buttons_min_size = Size2(105, 34);374}375376config.base_spacing = preset_base_spacing;377config.extra_spacing = preset_extra_spacing;378config.dialogs_buttons_min_size = preset_dialogs_buttons_min_size;379380EditorSettings::get_singleton()->set_initial_value("interface/theme/base_spacing", config.base_spacing);381EditorSettings::get_singleton()->set_initial_value("interface/theme/additional_spacing", config.extra_spacing);382}383384// Enforce values in case they were adjusted or overridden.385EditorSettings::get_singleton()->set_manually("interface/theme/spacing_preset", config.spacing_preset);386EditorSettings::get_singleton()->set_manually("interface/theme/base_spacing", config.base_spacing);387EditorSettings::get_singleton()->set_manually("interface/theme/additional_spacing", config.extra_spacing);388}389390// Generated properties.391392config.dark_theme = is_dark_theme();393394config.base_margin = config.base_spacing;395config.increased_margin = config.base_spacing + config.extra_spacing;396config.separation_margin = (config.base_spacing + config.extra_spacing / 2) * EDSCALE;397config.popup_margin = config.base_margin * 2.4 * EDSCALE;398// Make sure content doesn't stick to window decorations; this can be fixed in future with layout changes.399config.window_border_margin = MAX(1, config.base_margin * 2);400config.top_bar_separation = config.base_margin * 2 * EDSCALE;401402// Force the v_separation to be even so that the spacing on top and bottom is even.403// If the vsep is odd and cannot be split into 2 even groups (of pixels), then it will be lopsided.404// We add 2 to the vsep to give it some extra spacing which looks a bit more modern (see Windows, for example).405const int separation_base = config.increased_margin + 6;406config.forced_even_separation = separation_base + (separation_base % 2);407408return config;409}410411void EditorThemeManager::_create_shared_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {412// Colors.413{414// Base colors.415416p_theme->set_color("base_color", EditorStringName(Editor), p_config.base_color);417p_theme->set_color("accent_color", EditorStringName(Editor), p_config.accent_color);418419// White (dark theme) or black (light theme), will be used to generate the rest of the colors420p_config.mono_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);421422// Ensure base colors are in the 0..1 luminance range to avoid 8-bit integer overflow or text rendering issues.423// Some places in the editor use 8-bit integer colors.424p_config.dark_color_1 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast).clamp();425p_config.dark_color_2 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 1.5).clamp();426p_config.dark_color_3 = p_config.base_color.lerp(Color(0, 0, 0, 1), p_config.contrast * 2).clamp();427428p_config.contrast_color_1 = p_config.base_color.lerp(p_config.mono_color, MAX(p_config.contrast, p_config.default_contrast));429p_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));430431p_config.highlight_color = Color(p_config.accent_color.r, p_config.accent_color.g, p_config.accent_color.b, 0.275);432p_config.highlight_disabled_color = p_config.highlight_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.5);433434p_config.success_color = Color(0.45, 0.95, 0.5);435p_config.warning_color = Color(1, 0.87, 0.4);436p_config.error_color = Color(1, 0.47, 0.42);437if (!p_config.dark_theme) {438// Darken some colors to be readable on a light background.439p_config.success_color = p_config.success_color.lerp(p_config.mono_color, 0.35);440p_config.warning_color = Color(0.82, 0.56, 0.1);441p_config.error_color = Color(0.8, 0.22, 0.22);442}443444p_theme->set_color("mono_color", EditorStringName(Editor), p_config.mono_color);445p_theme->set_color("dark_color_1", EditorStringName(Editor), p_config.dark_color_1);446p_theme->set_color("dark_color_2", EditorStringName(Editor), p_config.dark_color_2);447p_theme->set_color("dark_color_3", EditorStringName(Editor), p_config.dark_color_3);448p_theme->set_color("contrast_color_1", EditorStringName(Editor), p_config.contrast_color_1);449p_theme->set_color("contrast_color_2", EditorStringName(Editor), p_config.contrast_color_2);450p_theme->set_color("highlight_color", EditorStringName(Editor), p_config.highlight_color);451p_theme->set_color("highlight_disabled_color", EditorStringName(Editor), p_config.highlight_disabled_color);452p_theme->set_color("success_color", EditorStringName(Editor), p_config.success_color);453p_theme->set_color("warning_color", EditorStringName(Editor), p_config.warning_color);454p_theme->set_color("error_color", EditorStringName(Editor), p_config.error_color);455#ifndef DISABLE_DEPRECATED // Used before 4.3.456p_theme->set_color("disabled_highlight_color", EditorStringName(Editor), p_config.highlight_disabled_color);457#endif458459// Only used when the Draw Extra Borders editor setting is enabled.460p_config.extra_border_color_1 = Color(0.5, 0.5, 0.5);461p_config.extra_border_color_2 = p_config.dark_theme ? Color(0.3, 0.3, 0.3) : Color(0.7, 0.7, 0.7);462463p_theme->set_color("extra_border_color_1", EditorStringName(Editor), p_config.extra_border_color_1);464p_theme->set_color("extra_border_color_2", EditorStringName(Editor), p_config.extra_border_color_2);465466// Font colors.467468p_config.font_color = p_config.mono_color.lerp(p_config.base_color, 0.25);469p_config.font_focus_color = p_config.mono_color.lerp(p_config.base_color, 0.125);470p_config.font_hover_color = p_config.mono_color.lerp(p_config.base_color, 0.125);471p_config.font_pressed_color = p_config.accent_color;472p_config.font_hover_pressed_color = p_config.font_hover_color.lerp(p_config.accent_color, 0.74);473p_config.font_disabled_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.35);474p_config.font_readonly_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.65);475p_config.font_placeholder_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.5);476p_config.font_outline_color = Color(0, 0, 0, 0);477478p_theme->set_color(SceneStringName(font_color), EditorStringName(Editor), p_config.font_color);479p_theme->set_color("font_focus_color", EditorStringName(Editor), p_config.font_focus_color);480p_theme->set_color("font_hover_color", EditorStringName(Editor), p_config.font_hover_color);481p_theme->set_color("font_pressed_color", EditorStringName(Editor), p_config.font_pressed_color);482p_theme->set_color("font_hover_pressed_color", EditorStringName(Editor), p_config.font_hover_pressed_color);483p_theme->set_color("font_disabled_color", EditorStringName(Editor), p_config.font_disabled_color);484p_theme->set_color("font_readonly_color", EditorStringName(Editor), p_config.font_readonly_color);485p_theme->set_color("font_placeholder_color", EditorStringName(Editor), p_config.font_placeholder_color);486p_theme->set_color("font_outline_color", EditorStringName(Editor), p_config.font_outline_color);487#ifndef DISABLE_DEPRECATED // Used before 4.3.488p_theme->set_color("readonly_font_color", EditorStringName(Editor), p_config.font_readonly_color);489p_theme->set_color("disabled_font_color", EditorStringName(Editor), p_config.font_disabled_color);490p_theme->set_color("readonly_color", EditorStringName(Editor), p_config.font_readonly_color);491p_theme->set_color("highlighted_font_color", EditorStringName(Editor), p_config.font_hover_color); // Closest equivalent.492#endif493494// Icon colors.495496p_config.icon_normal_color = Color(1, 1, 1);497p_config.icon_focus_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.45);498p_config.icon_focus_color.a = 1.0;499p_config.icon_hover_color = p_config.icon_focus_color;500// Make the pressed icon color overbright because icons are not completely white on a dark theme.501// On a light theme, icons are dark, so we need to modulate them with an even brighter color.502p_config.icon_pressed_color = p_config.accent_color * (p_config.dark_theme ? 1.15 : 3.5);503p_config.icon_pressed_color.a = 1.0;504p_config.icon_disabled_color = Color(p_config.icon_normal_color, 0.4);505506p_theme->set_color("icon_normal_color", EditorStringName(Editor), p_config.icon_normal_color);507p_theme->set_color("icon_focus_color", EditorStringName(Editor), p_config.icon_focus_color);508p_theme->set_color("icon_hover_color", EditorStringName(Editor), p_config.icon_hover_color);509p_theme->set_color("icon_pressed_color", EditorStringName(Editor), p_config.icon_pressed_color);510p_theme->set_color("icon_disabled_color", EditorStringName(Editor), p_config.icon_disabled_color);511512// Additional GUI colors.513514p_config.shadow_color = Color(0, 0, 0, p_config.dark_theme ? 0.3 : 0.1);515p_config.selection_color = p_config.accent_color * Color(1, 1, 1, 0.4);516p_config.disabled_border_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.7);517p_config.disabled_bg_color = p_config.mono_color.inverted().lerp(p_config.base_color, 0.9);518p_config.separator_color = Color(p_config.mono_color.r, p_config.mono_color.g, p_config.mono_color.b, 0.1);519520p_theme->set_color("selection_color", EditorStringName(Editor), p_config.selection_color);521p_theme->set_color("disabled_border_color", EditorStringName(Editor), p_config.disabled_border_color);522p_theme->set_color("disabled_bg_color", EditorStringName(Editor), p_config.disabled_bg_color);523p_theme->set_color("separator_color", EditorStringName(Editor), p_config.separator_color);524525// Additional editor colors.526527p_theme->set_color("box_selection_fill_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.3));528p_theme->set_color("box_selection_stroke_color", EditorStringName(Editor), p_config.accent_color * Color(1, 1, 1, 0.8));529530p_theme->set_color("axis_x_color", EditorStringName(Editor), Color(0.96, 0.20, 0.32));531p_theme->set_color("axis_y_color", EditorStringName(Editor), Color(0.53, 0.84, 0.01));532p_theme->set_color("axis_z_color", EditorStringName(Editor), Color(0.16, 0.55, 0.96));533p_theme->set_color("axis_w_color", EditorStringName(Editor), Color(0.55, 0.55, 0.55));534535const float prop_color_saturation = p_config.accent_color.get_s() * 0.75;536const float prop_color_value = p_config.accent_color.get_v();537538p_theme->set_color("property_color_x", EditorStringName(Editor), Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));539p_theme->set_color("property_color_y", EditorStringName(Editor), Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));540p_theme->set_color("property_color_z", EditorStringName(Editor), Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value));541p_theme->set_color("property_color_w", EditorStringName(Editor), Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value));542543// Special colors for rendering methods.544545p_theme->set_color("forward_plus_color", EditorStringName(Editor), Color::hex(0x5d8c3fff));546p_theme->set_color("mobile_color", EditorStringName(Editor), Color::hex(0xa5557dff));547p_theme->set_color("gl_compatibility_color", EditorStringName(Editor), Color::hex(0x5586a4ff));548549if (p_config.dark_theme) {550p_theme->set_color("highend_color", EditorStringName(Editor), Color(1.0, 0.0, 0.0));551} else {552p_theme->set_color("highend_color", EditorStringName(Editor), Color::hex(0xad1128ff));553}554}555556// Constants.557{558// Can't save single float in theme, so using Color.559p_theme->set_color("icon_saturation", EditorStringName(Editor), Color(p_config.icon_saturation, p_config.icon_saturation, p_config.icon_saturation));560561// Controls may rely on the scale for their internal drawing logic.562p_theme->set_default_base_scale(EDSCALE);563p_theme->set_constant("scale", EditorStringName(Editor), EDSCALE);564565p_theme->set_constant("thumb_size", EditorStringName(Editor), p_config.thumb_size);566p_theme->set_constant("class_icon_size", EditorStringName(Editor), p_config.class_icon_size);567p_theme->set_constant("color_picker_button_height", EditorStringName(Editor), p_config.color_picker_button_height);568p_theme->set_constant("gizmo_handle_scale", EditorStringName(Editor), p_config.gizmo_handle_scale);569570p_theme->set_constant("base_margin", EditorStringName(Editor), p_config.base_margin);571p_theme->set_constant("increased_margin", EditorStringName(Editor), p_config.increased_margin);572p_theme->set_constant("window_border_margin", EditorStringName(Editor), p_config.window_border_margin);573p_theme->set_constant("top_bar_separation", EditorStringName(Editor), p_config.top_bar_separation);574575p_theme->set_constant("dark_theme", EditorStringName(Editor), p_config.dark_theme);576}577578// Styleboxes.579{580// This is the basic stylebox, used as a base for most other styleboxes (through `duplicate()`).581p_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);582p_config.base_style->set_border_width_all(p_config.border_width);583p_config.base_style->set_border_color(p_config.base_color);584585p_config.base_empty_style = make_empty_stylebox(p_config.base_margin, p_config.base_margin, p_config.base_margin, p_config.base_margin);586587// Button styles.588{589p_config.widget_margin = Vector2(p_config.increased_margin + 2, p_config.increased_margin + 1) * EDSCALE;590591p_config.button_style = p_config.base_style->duplicate();592p_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);593p_config.button_style->set_bg_color(p_config.dark_color_1);594if (p_config.draw_extra_borders) {595p_config.button_style->set_border_width_all(Math::round(EDSCALE));596p_config.button_style->set_border_color(p_config.extra_border_color_1);597} else {598p_config.button_style->set_border_color(p_config.dark_color_2);599}600601p_config.button_style_disabled = p_config.button_style->duplicate();602p_config.button_style_disabled->set_bg_color(p_config.disabled_bg_color);603if (p_config.draw_extra_borders) {604p_config.button_style_disabled->set_border_color(p_config.extra_border_color_2);605} else {606p_config.button_style_disabled->set_border_color(p_config.disabled_border_color);607}608609p_config.button_style_focus = p_config.button_style->duplicate();610p_config.button_style_focus->set_draw_center(false);611p_config.button_style_focus->set_border_width_all(Math::round(2 * MAX(1, EDSCALE)));612p_config.button_style_focus->set_border_color(p_config.accent_color);613614p_config.button_style_pressed = p_config.button_style->duplicate();615p_config.button_style_pressed->set_bg_color(p_config.dark_color_1.darkened(0.125));616617p_config.button_style_hover = p_config.button_style->duplicate();618p_config.button_style_hover->set_bg_color(p_config.mono_color * Color(1, 1, 1, 0.11));619if (p_config.draw_extra_borders) {620p_config.button_style_hover->set_border_color(p_config.extra_border_color_1);621} else {622p_config.button_style_hover->set_border_color(p_config.mono_color * Color(1, 1, 1, 0.05));623}624}625626// Windows and popups.627{628p_config.popup_style = p_config.base_style->duplicate();629p_config.popup_style->set_content_margin_all(p_config.popup_margin);630p_config.popup_style->set_border_color(p_config.contrast_color_1);631p_config.popup_style->set_shadow_color(p_config.shadow_color);632p_config.popup_style->set_shadow_size(4 * EDSCALE);633// Popups are separate windows by default in the editor. Windows currently don't support per-pixel transparency634// in 4.0, and even if it was, it may not always work in practice (e.g. running with compositing disabled).635p_config.popup_style->set_corner_radius_all(0);636637p_config.popup_border_style = p_config.popup_style->duplicate();638p_config.popup_border_style->set_content_margin_all(MAX(Math::round(EDSCALE), p_config.border_width) + 2 + (p_config.base_margin * 1.5) * EDSCALE);639// Always display a border for popups like PopupMenus so they can be distinguished from their background.640p_config.popup_border_style->set_border_width_all(MAX(Math::round(EDSCALE), p_config.border_width));641if (p_config.draw_extra_borders) {642p_config.popup_border_style->set_border_color(p_config.extra_border_color_2);643} else {644p_config.popup_border_style->set_border_color(p_config.dark_color_2);645}646647p_config.window_style = p_config.popup_style->duplicate();648p_config.window_style->set_border_color(p_config.base_color);649p_config.window_style->set_border_width(SIDE_TOP, 24 * EDSCALE);650p_config.window_style->set_expand_margin(SIDE_TOP, 24 * EDSCALE);651652// Prevent corner artifacts between window title and body.653p_config.dialog_style = p_config.base_style->duplicate();654p_config.dialog_style->set_corner_radius(CORNER_TOP_LEFT, 0);655p_config.dialog_style->set_corner_radius(CORNER_TOP_RIGHT, 0);656p_config.dialog_style->set_content_margin_all(p_config.popup_margin);657// Prevent visible line between window title and body.658p_config.dialog_style->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);659}660661// Panels.662{663p_config.panel_container_style = p_config.button_style->duplicate();664p_config.panel_container_style->set_draw_center(false);665p_config.panel_container_style->set_border_width_all(0);666667// Content panel for tabs and similar containers.668669// Compensate for the border.670const int content_panel_margin = p_config.base_margin * EDSCALE + p_config.border_width;671672p_config.content_panel_style = p_config.base_style->duplicate();673p_config.content_panel_style->set_border_color(p_config.dark_color_3);674p_config.content_panel_style->set_border_width_all(p_config.border_width);675p_config.content_panel_style->set_border_width(Side::SIDE_TOP, 0);676p_config.content_panel_style->set_corner_radius(CORNER_TOP_LEFT, 0);677p_config.content_panel_style->set_corner_radius(CORNER_TOP_RIGHT, 0);678p_config.content_panel_style->set_content_margin_individual(content_panel_margin, 2 * EDSCALE + content_panel_margin, content_panel_margin, content_panel_margin);679680// Trees and similarly inset panels.681682p_config.tree_panel_style = p_config.base_style->duplicate();683// Make Trees easier to distinguish from other controls by using a darker background color.684p_config.tree_panel_style->set_bg_color(p_config.dark_color_1.lerp(p_config.dark_color_2, 0.5));685if (p_config.draw_extra_borders) {686p_config.tree_panel_style->set_border_width_all(Math::round(EDSCALE));687p_config.tree_panel_style->set_border_color(p_config.extra_border_color_2);688} else {689p_config.tree_panel_style->set_border_color(p_config.dark_color_3);690}691}692}693}694695void EditorThemeManager::_populate_standard_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {696// Panels.697{698// Panel.699p_theme->set_stylebox(SceneStringName(panel), "Panel", make_flat_stylebox(p_config.dark_color_1, 6, 4, 6, 4, p_config.corner_radius));700701// PanelContainer.702p_theme->set_stylebox(SceneStringName(panel), "PanelContainer", p_config.panel_container_style);703704// TooltipPanel & TooltipLabel.705{706// TooltipPanel is also used for custom tooltips, while TooltipLabel707// is only relevant for default tooltips.708709p_theme->set_color(SceneStringName(font_color), "TooltipLabel", p_config.font_hover_color);710p_theme->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0));711712Ref<StyleBoxFlat> style_tooltip = p_config.popup_style->duplicate();713style_tooltip->set_shadow_size(0);714style_tooltip->set_content_margin_all(p_config.base_margin * EDSCALE * 0.5);715style_tooltip->set_bg_color(p_config.dark_color_3 * Color(0.8, 0.8, 0.8, 0.9));716style_tooltip->set_border_width_all(0);717p_theme->set_stylebox(SceneStringName(panel), "TooltipPanel", style_tooltip);718}719720// PopupPanel721p_theme->set_stylebox(SceneStringName(panel), "PopupPanel", p_config.popup_border_style);722}723724// Buttons.725{726// Button.727728p_theme->set_stylebox(CoreStringName(normal), "Button", p_config.button_style);729p_theme->set_stylebox(SceneStringName(hover), "Button", p_config.button_style_hover);730p_theme->set_stylebox(SceneStringName(pressed), "Button", p_config.button_style_pressed);731p_theme->set_stylebox("focus", "Button", p_config.button_style_focus);732p_theme->set_stylebox("disabled", "Button", p_config.button_style_disabled);733734p_theme->set_color(SceneStringName(font_color), "Button", p_config.font_color);735p_theme->set_color("font_hover_color", "Button", p_config.font_hover_color);736p_theme->set_color("font_hover_pressed_color", "Button", p_config.font_hover_pressed_color);737p_theme->set_color("font_focus_color", "Button", p_config.font_focus_color);738p_theme->set_color("font_pressed_color", "Button", p_config.font_pressed_color);739p_theme->set_color("font_disabled_color", "Button", p_config.font_disabled_color);740p_theme->set_color("font_outline_color", "Button", p_config.font_outline_color);741742p_theme->set_color("icon_normal_color", "Button", p_config.icon_normal_color);743p_theme->set_color("icon_hover_color", "Button", p_config.icon_hover_color);744p_theme->set_color("icon_focus_color", "Button", p_config.icon_focus_color);745p_theme->set_color("icon_hover_pressed_color", "Button", p_config.icon_pressed_color);746p_theme->set_color("icon_pressed_color", "Button", p_config.icon_pressed_color);747p_theme->set_color("icon_disabled_color", "Button", p_config.icon_disabled_color);748749p_theme->set_constant("h_separation", "Button", 4 * EDSCALE);750p_theme->set_constant("outline_size", "Button", 0);751752p_theme->set_constant("align_to_largest_stylebox", "Button", 1); // Enabled.753754// MenuButton.755756p_theme->set_stylebox(CoreStringName(normal), "MenuButton", p_config.panel_container_style);757p_theme->set_stylebox(SceneStringName(hover), "MenuButton", p_config.button_style_hover);758p_theme->set_stylebox(SceneStringName(pressed), "MenuButton", p_config.panel_container_style);759p_theme->set_stylebox("focus", "MenuButton", p_config.panel_container_style);760p_theme->set_stylebox("disabled", "MenuButton", p_config.panel_container_style);761762p_theme->set_color(SceneStringName(font_color), "MenuButton", p_config.font_color);763p_theme->set_color("font_hover_color", "MenuButton", p_config.font_hover_color);764p_theme->set_color("font_hover_pressed_color", "MenuButton", p_config.font_hover_pressed_color);765p_theme->set_color("font_focus_color", "MenuButton", p_config.font_focus_color);766p_theme->set_color("font_outline_color", "MenuButton", p_config.font_outline_color);767768p_theme->set_constant("outline_size", "MenuButton", 0);769770// MenuBar.771772p_theme->set_stylebox(CoreStringName(normal), "MenuBar", p_config.button_style);773p_theme->set_stylebox(SceneStringName(hover), "MenuBar", p_config.button_style_hover);774p_theme->set_stylebox(SceneStringName(pressed), "MenuBar", p_config.button_style_pressed);775p_theme->set_stylebox("disabled", "MenuBar", p_config.button_style_disabled);776777p_theme->set_color(SceneStringName(font_color), "MenuBar", p_config.font_color);778p_theme->set_color("font_hover_color", "MenuBar", p_config.font_hover_color);779p_theme->set_color("font_hover_pressed_color", "MenuBar", p_config.font_hover_pressed_color);780p_theme->set_color("font_focus_color", "MenuBar", p_config.font_focus_color);781p_theme->set_color("font_pressed_color", "MenuBar", p_config.font_pressed_color);782p_theme->set_color("font_disabled_color", "MenuBar", p_config.font_disabled_color);783p_theme->set_color("font_outline_color", "MenuBar", p_config.font_outline_color);784785p_theme->set_color("icon_normal_color", "MenuBar", p_config.icon_normal_color);786p_theme->set_color("icon_hover_color", "MenuBar", p_config.icon_hover_color);787p_theme->set_color("icon_focus_color", "MenuBar", p_config.icon_focus_color);788p_theme->set_color("icon_pressed_color", "MenuBar", p_config.icon_pressed_color);789p_theme->set_color("icon_disabled_color", "MenuBar", p_config.icon_disabled_color);790791p_theme->set_constant("h_separation", "MenuBar", 4 * EDSCALE);792p_theme->set_constant("outline_size", "MenuBar", 0);793794// OptionButton.795{796Ref<StyleBoxFlat> option_button_focus_style = p_config.button_style_focus->duplicate();797Ref<StyleBoxFlat> option_button_normal_style = p_config.button_style->duplicate();798Ref<StyleBoxFlat> option_button_hover_style = p_config.button_style_hover->duplicate();799Ref<StyleBoxFlat> option_button_pressed_style = p_config.button_style_pressed->duplicate();800Ref<StyleBoxFlat> option_button_disabled_style = p_config.button_style_disabled->duplicate();801802option_button_focus_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);803option_button_normal_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);804option_button_hover_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);805option_button_pressed_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);806option_button_disabled_style->set_content_margin(SIDE_RIGHT, 4 * EDSCALE);807808p_theme->set_stylebox("focus", "OptionButton", option_button_focus_style);809p_theme->set_stylebox(CoreStringName(normal), "OptionButton", p_config.button_style);810p_theme->set_stylebox(SceneStringName(hover), "OptionButton", p_config.button_style_hover);811p_theme->set_stylebox(SceneStringName(pressed), "OptionButton", p_config.button_style_pressed);812p_theme->set_stylebox("disabled", "OptionButton", p_config.button_style_disabled);813814p_theme->set_stylebox("normal_mirrored", "OptionButton", option_button_normal_style);815p_theme->set_stylebox("hover_mirrored", "OptionButton", option_button_hover_style);816p_theme->set_stylebox("pressed_mirrored", "OptionButton", option_button_pressed_style);817p_theme->set_stylebox("disabled_mirrored", "OptionButton", option_button_disabled_style);818819p_theme->set_color(SceneStringName(font_color), "OptionButton", p_config.font_color);820p_theme->set_color("font_hover_color", "OptionButton", p_config.font_hover_color);821p_theme->set_color("font_hover_pressed_color", "OptionButton", p_config.font_hover_pressed_color);822p_theme->set_color("font_focus_color", "OptionButton", p_config.font_focus_color);823p_theme->set_color("font_pressed_color", "OptionButton", p_config.font_pressed_color);824p_theme->set_color("font_disabled_color", "OptionButton", p_config.font_disabled_color);825p_theme->set_color("font_outline_color", "OptionButton", p_config.font_outline_color);826827p_theme->set_color("icon_normal_color", "OptionButton", p_config.icon_normal_color);828p_theme->set_color("icon_hover_color", "OptionButton", p_config.icon_hover_color);829p_theme->set_color("icon_focus_color", "OptionButton", p_config.icon_focus_color);830p_theme->set_color("icon_pressed_color", "OptionButton", p_config.icon_pressed_color);831p_theme->set_color("icon_disabled_color", "OptionButton", p_config.icon_disabled_color);832833p_theme->set_icon("arrow", "OptionButton", p_theme->get_icon(SNAME("GuiOptionArrow"), EditorStringName(EditorIcons)));834p_theme->set_constant("arrow_margin", "OptionButton", p_config.widget_margin.x - 2 * EDSCALE);835p_theme->set_constant("modulate_arrow", "OptionButton", true);836p_theme->set_constant("h_separation", "OptionButton", 4 * EDSCALE);837p_theme->set_constant("outline_size", "OptionButton", 0);838}839840// CheckButton.841842p_theme->set_stylebox(CoreStringName(normal), "CheckButton", p_config.panel_container_style);843p_theme->set_stylebox(SceneStringName(pressed), "CheckButton", p_config.panel_container_style);844p_theme->set_stylebox("disabled", "CheckButton", p_config.panel_container_style);845p_theme->set_stylebox(SceneStringName(hover), "CheckButton", p_config.panel_container_style);846p_theme->set_stylebox("hover_pressed", "CheckButton", p_config.panel_container_style);847848p_theme->set_icon("checked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOn"), EditorStringName(EditorIcons)));849p_theme->set_icon("checked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabled"), EditorStringName(EditorIcons)));850p_theme->set_icon("unchecked", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOff"), EditorStringName(EditorIcons)));851p_theme->set_icon("unchecked_disabled", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabled"), EditorStringName(EditorIcons)));852853p_theme->set_icon("checked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnMirrored"), EditorStringName(EditorIcons)));854p_theme->set_icon("checked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOnDisabledMirrored"), EditorStringName(EditorIcons)));855p_theme->set_icon("unchecked_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffMirrored"), EditorStringName(EditorIcons)));856p_theme->set_icon("unchecked_disabled_mirrored", "CheckButton", p_theme->get_icon(SNAME("GuiToggleOffDisabledMirrored"), EditorStringName(EditorIcons)));857858p_theme->set_color(SceneStringName(font_color), "CheckButton", p_config.font_color);859p_theme->set_color("font_hover_color", "CheckButton", p_config.font_hover_color);860p_theme->set_color("font_hover_pressed_color", "CheckButton", p_config.font_hover_pressed_color);861p_theme->set_color("font_focus_color", "CheckButton", p_config.font_focus_color);862p_theme->set_color("font_pressed_color", "CheckButton", p_config.font_pressed_color);863p_theme->set_color("font_disabled_color", "CheckButton", p_config.font_disabled_color);864p_theme->set_color("font_outline_color", "CheckButton", p_config.font_outline_color);865866p_theme->set_color("icon_normal_color", "CheckButton", p_config.icon_normal_color);867p_theme->set_color("icon_hover_color", "CheckButton", p_config.icon_hover_color);868p_theme->set_color("icon_focus_color", "CheckButton", p_config.icon_focus_color);869p_theme->set_color("icon_pressed_color", "CheckButton", p_config.icon_pressed_color);870p_theme->set_color("icon_disabled_color", "CheckButton", p_config.icon_disabled_color);871872p_theme->set_constant("h_separation", "CheckButton", 8 * EDSCALE);873p_theme->set_constant("check_v_offset", "CheckButton", 0);874p_theme->set_constant("outline_size", "CheckButton", 0);875876// CheckBox.877{878Ref<StyleBoxFlat> checkbox_style = p_config.panel_container_style->duplicate();879880p_theme->set_stylebox(CoreStringName(normal), "CheckBox", checkbox_style);881p_theme->set_stylebox(SceneStringName(pressed), "CheckBox", checkbox_style);882p_theme->set_stylebox("disabled", "CheckBox", checkbox_style);883p_theme->set_stylebox(SceneStringName(hover), "CheckBox", checkbox_style);884p_theme->set_stylebox("hover_pressed", "CheckBox", checkbox_style);885p_theme->set_icon("checked", "CheckBox", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));886p_theme->set_icon("unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));887p_theme->set_icon("radio_checked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));888p_theme->set_icon("radio_unchecked", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));889p_theme->set_icon("checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));890p_theme->set_icon("unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));891p_theme->set_icon("radio_checked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));892p_theme->set_icon("radio_unchecked_disabled", "CheckBox", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));893894p_theme->set_color(SceneStringName(font_color), "CheckBox", p_config.font_color);895p_theme->set_color("font_hover_color", "CheckBox", p_config.font_hover_color);896p_theme->set_color("font_hover_pressed_color", "CheckBox", p_config.font_hover_pressed_color);897p_theme->set_color("font_focus_color", "CheckBox", p_config.font_focus_color);898p_theme->set_color("font_pressed_color", "CheckBox", p_config.font_pressed_color);899p_theme->set_color("font_disabled_color", "CheckBox", p_config.font_disabled_color);900p_theme->set_color("font_outline_color", "CheckBox", p_config.font_outline_color);901902p_theme->set_color("icon_normal_color", "CheckBox", p_config.icon_normal_color);903p_theme->set_color("icon_hover_color", "CheckBox", p_config.icon_hover_color);904p_theme->set_color("icon_focus_color", "CheckBox", p_config.icon_focus_color);905p_theme->set_color("icon_pressed_color", "CheckBox", p_config.icon_pressed_color);906p_theme->set_color("icon_disabled_color", "CheckBox", p_config.icon_disabled_color);907908p_theme->set_constant("h_separation", "CheckBox", 8 * EDSCALE);909p_theme->set_constant("check_v_offset", "CheckBox", 0);910p_theme->set_constant("outline_size", "CheckBox", 0);911}912913// LinkButton.914915p_theme->set_stylebox("focus", "LinkButton", p_config.base_empty_style);916p_theme->set_color(SceneStringName(font_color), "LinkButton", p_config.font_color);917p_theme->set_color("font_hover_color", "LinkButton", p_config.font_hover_color);918p_theme->set_color("font_hover_pressed_color", "LinkButton", p_config.font_hover_pressed_color);919p_theme->set_color("font_focus_color", "LinkButton", p_config.font_focus_color);920p_theme->set_color("font_pressed_color", "LinkButton", p_config.font_pressed_color);921p_theme->set_color("font_disabled_color", "LinkButton", p_config.font_disabled_color);922p_theme->set_color("font_outline_color", "LinkButton", p_config.font_outline_color);923924p_theme->set_constant("outline_size", "LinkButton", 0);925}926927// Tree & ItemList.928{929Ref<StyleBoxFlat> style_tree_focus = p_config.base_style->duplicate();930style_tree_focus->set_bg_color(p_config.highlight_color);931style_tree_focus->set_border_width_all(0);932933Ref<StyleBoxFlat> style_tree_selected = style_tree_focus->duplicate();934935const Color guide_color = p_config.mono_color * Color(1, 1, 1, 0.05);936937// Tree.938{939p_theme->set_icon("checked", "Tree", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));940p_theme->set_icon("checked_disabled", "Tree", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));941p_theme->set_icon("indeterminate", "Tree", p_theme->get_icon(SNAME("GuiIndeterminate"), EditorStringName(EditorIcons)));942p_theme->set_icon("indeterminate_disabled", "Tree", p_theme->get_icon(SNAME("GuiIndeterminateDisabled"), EditorStringName(EditorIcons)));943p_theme->set_icon("unchecked", "Tree", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));944p_theme->set_icon("unchecked_disabled", "Tree", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));945p_theme->set_icon("arrow", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));946p_theme->set_icon("arrow_collapsed", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));947p_theme->set_icon("arrow_collapsed_mirrored", "Tree", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));948p_theme->set_icon("updown", "Tree", p_theme->get_icon(SNAME("GuiTreeUpdown"), EditorStringName(EditorIcons)));949p_theme->set_icon("select_arrow", "Tree", p_theme->get_icon(SNAME("GuiDropdown"), EditorStringName(EditorIcons)));950951p_theme->set_stylebox(SceneStringName(panel), "Tree", p_config.tree_panel_style);952p_theme->set_stylebox("focus", "Tree", p_config.button_style_focus);953p_theme->set_stylebox("custom_button", "Tree", make_empty_stylebox());954p_theme->set_stylebox("custom_button_pressed", "Tree", make_empty_stylebox());955p_theme->set_stylebox("custom_button_hover", "Tree", p_config.button_style);956957p_theme->set_color("custom_button_font_highlight", "Tree", p_config.font_hover_color);958p_theme->set_color(SceneStringName(font_color), "Tree", p_config.font_color);959p_theme->set_color("font_hovered_color", "Tree", p_config.mono_color);960p_theme->set_color("font_hovered_dimmed_color", "Tree", p_config.font_color);961p_theme->set_color("font_hovered_selected_color", "Tree", p_config.mono_color);962p_theme->set_color("font_selected_color", "Tree", p_config.mono_color);963p_theme->set_color("font_disabled_color", "Tree", p_config.font_disabled_color);964p_theme->set_color("font_outline_color", "Tree", p_config.font_outline_color);965p_theme->set_color("title_button_color", "Tree", p_config.font_color);966p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);967968p_theme->set_constant("v_separation", "Tree", p_config.separation_margin);969p_theme->set_constant("h_separation", "Tree", (p_config.increased_margin + 2) * EDSCALE);970p_theme->set_constant("guide_width", "Tree", p_config.border_width);971p_theme->set_constant("item_margin", "Tree", MAX(3 * p_config.increased_margin * EDSCALE, 12 * EDSCALE));972p_theme->set_constant("inner_item_margin_top", "Tree", p_config.separation_margin);973p_theme->set_constant("inner_item_margin_bottom", "Tree", p_config.separation_margin);974p_theme->set_constant("inner_item_margin_left", "Tree", p_config.increased_margin * EDSCALE);975p_theme->set_constant("inner_item_margin_right", "Tree", p_config.increased_margin * EDSCALE);976p_theme->set_constant("button_margin", "Tree", p_config.base_margin * EDSCALE);977p_theme->set_constant("scroll_border", "Tree", 40 * EDSCALE);978p_theme->set_constant("scroll_speed", "Tree", 12);979p_theme->set_constant("outline_size", "Tree", 0);980p_theme->set_constant("scrollbar_margin_left", "Tree", 0);981p_theme->set_constant("scrollbar_margin_top", "Tree", 0);982p_theme->set_constant("scrollbar_margin_right", "Tree", 0);983p_theme->set_constant("scrollbar_margin_bottom", "Tree", 0);984p_theme->set_constant("scrollbar_h_separation", "Tree", 1 * EDSCALE);985p_theme->set_constant("scrollbar_v_separation", "Tree", 1 * EDSCALE);986987Color relationship_line_color = p_config.mono_color * Color(1, 1, 1, p_config.relationship_line_opacity);988989p_theme->set_constant("draw_guides", "Tree", p_config.relationship_line_opacity < 0.01);990p_theme->set_color("guide_color", "Tree", guide_color);991992int relationship_line_width = 1;993Color parent_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.45, 0.0, 1.0));994Color children_line_color = p_config.mono_color * Color(1, 1, 1, CLAMP(p_config.relationship_line_opacity + 0.25, 0.0, 1.0));995996p_theme->set_constant("draw_relationship_lines", "Tree", p_config.relationship_line_opacity >= 0.01);997p_theme->set_constant("relationship_line_width", "Tree", relationship_line_width);998p_theme->set_constant("parent_hl_line_width", "Tree", relationship_line_width * 2);999p_theme->set_constant("children_hl_line_width", "Tree", relationship_line_width);1000p_theme->set_constant("parent_hl_line_margin", "Tree", relationship_line_width * 3);1001p_theme->set_color("relationship_line_color", "Tree", relationship_line_color);1002p_theme->set_color("parent_hl_line_color", "Tree", parent_line_color);1003p_theme->set_color("children_hl_line_color", "Tree", children_line_color);1004p_theme->set_color("drop_position_color", "Tree", p_config.accent_color);10051006Ref<StyleBoxFlat> style_tree_btn = p_config.base_style->duplicate();1007style_tree_btn->set_bg_color(p_config.highlight_color);1008style_tree_btn->set_border_width_all(0);1009p_theme->set_stylebox("button_pressed", "Tree", style_tree_btn);10101011Ref<StyleBoxFlat> style_tree_hover = p_config.base_style->duplicate();1012style_tree_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.4));1013style_tree_hover->set_border_width_all(0);1014p_theme->set_stylebox("hovered", "Tree", style_tree_hover);1015p_theme->set_stylebox("button_hover", "Tree", style_tree_hover);10161017Ref<StyleBoxFlat> style_tree_hover_dimmed = p_config.base_style->duplicate();1018style_tree_hover_dimmed->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.2));1019style_tree_hover_dimmed->set_border_width_all(0);1020p_theme->set_stylebox("hovered_dimmed", "Tree", style_tree_hover_dimmed);10211022Ref<StyleBoxFlat> style_tree_hover_selected = style_tree_selected->duplicate();1023style_tree_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));1024style_tree_hover_selected->set_border_width_all(0);10251026p_theme->set_stylebox("hovered_selected", "Tree", style_tree_hover_selected);1027p_theme->set_stylebox("hovered_selected_focus", "Tree", style_tree_hover_selected);10281029p_theme->set_stylebox("selected_focus", "Tree", style_tree_focus);1030p_theme->set_stylebox("selected", "Tree", style_tree_selected);10311032Ref<StyleBoxFlat> style_tree_cursor = p_config.base_style->duplicate();1033style_tree_cursor->set_draw_center(false);1034style_tree_cursor->set_border_width_all(MAX(1, p_config.border_width));1035style_tree_cursor->set_border_color(p_config.contrast_color_1);10361037Ref<StyleBoxFlat> style_tree_title = p_config.base_style->duplicate();1038style_tree_title->set_bg_color(p_config.dark_color_3);1039style_tree_title->set_border_width_all(0);1040p_theme->set_stylebox("cursor", "Tree", style_tree_cursor);1041p_theme->set_stylebox("cursor_unfocused", "Tree", style_tree_cursor);1042p_theme->set_stylebox("title_button_normal", "Tree", style_tree_title);1043p_theme->set_stylebox("title_button_hover", "Tree", style_tree_title);1044p_theme->set_stylebox("title_button_pressed", "Tree", style_tree_title);1045}10461047// ItemList.1048{1049Ref<StyleBoxFlat> style_itemlist_bg = p_config.base_style->duplicate();1050style_itemlist_bg->set_content_margin_all(p_config.separation_margin);1051style_itemlist_bg->set_bg_color(p_config.dark_color_1);10521053if (p_config.draw_extra_borders) {1054style_itemlist_bg->set_border_width_all(Math::round(EDSCALE));1055style_itemlist_bg->set_border_color(p_config.extra_border_color_2);1056} else {1057style_itemlist_bg->set_border_width_all(p_config.border_width);1058style_itemlist_bg->set_border_color(p_config.dark_color_3);1059}10601061Ref<StyleBoxFlat> style_itemlist_cursor = p_config.base_style->duplicate();1062style_itemlist_cursor->set_draw_center(false);1063style_itemlist_cursor->set_border_width_all(MAX(1 * EDSCALE, p_config.border_width));1064style_itemlist_cursor->set_border_color(p_config.highlight_color);10651066Ref<StyleBoxFlat> style_itemlist_hover = style_tree_selected->duplicate();1067style_itemlist_hover->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 0.3));1068style_itemlist_hover->set_border_width_all(0);10691070Ref<StyleBoxFlat> style_itemlist_hover_selected = style_tree_selected->duplicate();1071style_itemlist_hover_selected->set_bg_color(p_config.highlight_color * Color(1, 1, 1, 1.2));1072style_itemlist_hover_selected->set_border_width_all(0);10731074p_theme->set_stylebox(SceneStringName(panel), "ItemList", style_itemlist_bg);1075p_theme->set_stylebox("focus", "ItemList", p_config.button_style_focus);1076p_theme->set_stylebox("cursor", "ItemList", style_itemlist_cursor);1077p_theme->set_stylebox("cursor_unfocused", "ItemList", style_itemlist_cursor);1078p_theme->set_stylebox("selected_focus", "ItemList", style_tree_focus);1079p_theme->set_stylebox("selected", "ItemList", style_tree_selected);1080p_theme->set_stylebox("hovered", "ItemList", style_itemlist_hover);1081p_theme->set_stylebox("hovered_selected", "ItemList", style_itemlist_hover_selected);1082p_theme->set_stylebox("hovered_selected_focus", "ItemList", style_itemlist_hover_selected);1083p_theme->set_color(SceneStringName(font_color), "ItemList", p_config.font_color);1084p_theme->set_color("font_hovered_color", "ItemList", p_config.mono_color);1085p_theme->set_color("font_hovered_selected_color", "ItemList", p_config.mono_color);1086p_theme->set_color("font_selected_color", "ItemList", p_config.mono_color);1087p_theme->set_color("font_outline_color", "ItemList", p_config.font_outline_color);1088p_theme->set_color("guide_color", "ItemList", Color(1, 1, 1, 0));1089p_theme->set_constant("v_separation", "ItemList", p_config.forced_even_separation * EDSCALE);1090p_theme->set_constant("h_separation", "ItemList", (p_config.increased_margin + 2) * EDSCALE);1091p_theme->set_constant("icon_margin", "ItemList", (p_config.increased_margin + 2) * EDSCALE);1092p_theme->set_constant(SceneStringName(line_separation), "ItemList", p_config.separation_margin);1093p_theme->set_constant("outline_size", "ItemList", 0);1094}1095}10961097// TabBar & TabContainer.1098{1099Ref<StyleBoxFlat> style_tab_base = p_config.button_style->duplicate();11001101style_tab_base->set_border_width_all(0);1102// Don't round the top corners to avoid creating a small blank space between the tabs and the main panel.1103// This also makes the top highlight look better.1104style_tab_base->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1105style_tab_base->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);11061107// When using a border width greater than 0, visually line up the left of the selected tab with the underlying panel.1108style_tab_base->set_expand_margin(SIDE_LEFT, -p_config.border_width);11091110style_tab_base->set_content_margin(SIDE_LEFT, p_config.widget_margin.x + 5 * EDSCALE);1111style_tab_base->set_content_margin(SIDE_RIGHT, p_config.widget_margin.x + 5 * EDSCALE);1112style_tab_base->set_content_margin(SIDE_BOTTOM, p_config.widget_margin.y);1113style_tab_base->set_content_margin(SIDE_TOP, p_config.widget_margin.y);11141115Ref<StyleBoxFlat> style_tab_selected = style_tab_base->duplicate();11161117style_tab_selected->set_bg_color(p_config.base_color);1118// Add a highlight line at the top of the selected tab.1119style_tab_selected->set_border_width(SIDE_TOP, Math::round(2 * EDSCALE));1120// Make the highlight line prominent, but not too prominent as to not be distracting.1121Color tab_highlight = p_config.dark_color_2.lerp(p_config.accent_color, 0.75);1122style_tab_selected->set_border_color(tab_highlight);1123style_tab_selected->set_corner_radius_all(0);11241125Ref<StyleBoxFlat> style_tab_hovered = style_tab_base->duplicate();11261127style_tab_hovered->set_bg_color(p_config.dark_color_1.lerp(p_config.base_color, 0.4));1128// Hovered tab has a subtle highlight between normal and selected states.1129style_tab_hovered->set_corner_radius_all(0);11301131Ref<StyleBoxFlat> style_tab_unselected = style_tab_base->duplicate();1132style_tab_unselected->set_expand_margin(SIDE_BOTTOM, 0);1133style_tab_unselected->set_bg_color(p_config.dark_color_1);1134// Add some spacing between unselected tabs to make them easier to distinguish from each other1135style_tab_unselected->set_border_color(Color(0, 0, 0, 0));11361137Ref<StyleBoxFlat> style_tab_disabled = style_tab_base->duplicate();1138style_tab_disabled->set_expand_margin(SIDE_BOTTOM, 0);1139style_tab_disabled->set_bg_color(p_config.disabled_bg_color);1140style_tab_disabled->set_border_color(p_config.disabled_bg_color);11411142Ref<StyleBoxFlat> style_tab_focus = p_config.button_style_focus->duplicate();11431144Ref<StyleBoxFlat> style_tabbar_background = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0, p_config.corner_radius * EDSCALE);1145style_tabbar_background->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1146style_tabbar_background->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);1147p_theme->set_stylebox("tabbar_background", "TabContainer", style_tabbar_background);1148p_theme->set_stylebox(SceneStringName(panel), "TabContainer", p_config.content_panel_style);11491150p_theme->set_stylebox("tab_selected", "TabContainer", style_tab_selected);1151p_theme->set_stylebox("tab_hovered", "TabContainer", style_tab_hovered);1152p_theme->set_stylebox("tab_unselected", "TabContainer", style_tab_unselected);1153p_theme->set_stylebox("tab_disabled", "TabContainer", style_tab_disabled);1154p_theme->set_stylebox("tab_focus", "TabContainer", style_tab_focus);1155p_theme->set_stylebox("tab_selected", "TabBar", style_tab_selected);1156p_theme->set_stylebox("tab_hovered", "TabBar", style_tab_hovered);1157p_theme->set_stylebox("tab_unselected", "TabBar", style_tab_unselected);1158p_theme->set_stylebox("tab_disabled", "TabBar", style_tab_disabled);1159p_theme->set_stylebox("tab_focus", "TabBar", style_tab_focus);1160p_theme->set_stylebox("button_pressed", "TabBar", p_config.panel_container_style);1161p_theme->set_stylebox("button_highlight", "TabBar", p_config.panel_container_style);11621163p_theme->set_color("font_selected_color", "TabContainer", p_config.font_color);1164p_theme->set_color("font_hovered_color", "TabContainer", p_config.font_color);1165p_theme->set_color("font_unselected_color", "TabContainer", p_config.font_disabled_color);1166p_theme->set_color("font_outline_color", "TabContainer", p_config.font_outline_color);1167p_theme->set_color("font_selected_color", "TabBar", p_config.font_color);1168p_theme->set_color("font_hovered_color", "TabBar", p_config.font_color);1169p_theme->set_color("font_unselected_color", "TabBar", p_config.font_disabled_color);1170p_theme->set_color("font_outline_color", "TabBar", p_config.font_outline_color);1171p_theme->set_color("drop_mark_color", "TabContainer", tab_highlight);1172p_theme->set_color("drop_mark_color", "TabBar", tab_highlight);11731174p_theme->set_icon("menu", "TabContainer", p_theme->get_icon(SNAME("GuiTabMenu"), EditorStringName(EditorIcons)));1175p_theme->set_icon("menu_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiTabMenuHl"), EditorStringName(EditorIcons)));1176p_theme->set_icon("close", "TabBar", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));1177p_theme->set_icon("increment", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons)));1178p_theme->set_icon("decrement", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons)));1179p_theme->set_icon("increment", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowRight"), EditorStringName(EditorIcons)));1180p_theme->set_icon("decrement", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowLeft"), EditorStringName(EditorIcons)));1181p_theme->set_icon("increment_highlight", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons)));1182p_theme->set_icon("decrement_highlight", "TabBar", p_theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons)));1183p_theme->set_icon("increment_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowRightHl"), EditorStringName(EditorIcons)));1184p_theme->set_icon("decrement_highlight", "TabContainer", p_theme->get_icon(SNAME("GuiScrollArrowLeftHl"), EditorStringName(EditorIcons)));1185p_theme->set_icon("drop_mark", "TabContainer", p_theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons)));1186p_theme->set_icon("drop_mark", "TabBar", p_theme->get_icon(SNAME("GuiTabDropMark"), EditorStringName(EditorIcons)));11871188p_theme->set_constant("side_margin", "TabContainer", 0);1189p_theme->set_constant("outline_size", "TabContainer", 0);1190p_theme->set_constant("h_separation", "TabBar", 4 * EDSCALE);1191p_theme->set_constant("outline_size", "TabBar", 0);1192}11931194// Separators.1195p_theme->set_stylebox("separator", "HSeparator", make_line_stylebox(p_config.separator_color, MAX(Math::round(EDSCALE), p_config.border_width)));1196p_theme->set_stylebox("separator", "VSeparator", make_line_stylebox(p_config.separator_color, MAX(Math::round(EDSCALE), p_config.border_width), 0, 0, true));11971198// LineEdit & TextEdit.1199{1200Ref<StyleBoxFlat> text_editor_style = p_config.button_style->duplicate();12011202// Don't round the bottom corners to make the line look sharper.1203text_editor_style->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1204text_editor_style->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);12051206if (p_config.draw_extra_borders) {1207text_editor_style->set_border_width_all(Math::round(EDSCALE));1208text_editor_style->set_border_color(p_config.extra_border_color_1);1209} else {1210// Add a bottom line to make LineEdits more visible, especially in sectioned inspectors1211// such as the Project Settings.1212text_editor_style->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));1213text_editor_style->set_border_color(p_config.dark_color_2);1214}12151216Ref<StyleBoxFlat> text_editor_disabled_style = text_editor_style->duplicate();1217text_editor_disabled_style->set_border_color(p_config.disabled_border_color);1218text_editor_disabled_style->set_bg_color(p_config.disabled_bg_color);12191220// LineEdit.12211222p_theme->set_stylebox(CoreStringName(normal), "LineEdit", text_editor_style);1223p_theme->set_stylebox("focus", "LineEdit", p_config.button_style_focus);1224p_theme->set_stylebox("read_only", "LineEdit", text_editor_disabled_style);12251226p_theme->set_icon("clear", "LineEdit", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));12271228p_theme->set_color(SceneStringName(font_color), "LineEdit", p_config.font_color);1229p_theme->set_color("font_selected_color", "LineEdit", p_config.mono_color);1230p_theme->set_color("font_uneditable_color", "LineEdit", p_config.font_readonly_color);1231p_theme->set_color("font_placeholder_color", "LineEdit", p_config.font_placeholder_color);1232p_theme->set_color("font_outline_color", "LineEdit", p_config.font_outline_color);1233p_theme->set_color("caret_color", "LineEdit", p_config.font_color);1234p_theme->set_color("selection_color", "LineEdit", p_config.selection_color);1235p_theme->set_color("clear_button_color", "LineEdit", p_config.font_color);1236p_theme->set_color("clear_button_color_pressed", "LineEdit", p_config.accent_color);12371238p_theme->set_constant("minimum_character_width", "LineEdit", 4);1239p_theme->set_constant("outline_size", "LineEdit", 0);1240p_theme->set_constant("caret_width", "LineEdit", 1);12411242// TextEdit.12431244p_theme->set_stylebox(CoreStringName(normal), "TextEdit", text_editor_style);1245p_theme->set_stylebox("focus", "TextEdit", p_config.button_style_focus);1246p_theme->set_stylebox("read_only", "TextEdit", text_editor_disabled_style);12471248p_theme->set_icon("tab", "TextEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));1249p_theme->set_icon("space", "TextEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));12501251p_theme->set_color(SceneStringName(font_color), "TextEdit", p_config.font_color);1252p_theme->set_color("font_readonly_color", "TextEdit", p_config.font_readonly_color);1253p_theme->set_color("font_placeholder_color", "TextEdit", p_config.font_placeholder_color);1254p_theme->set_color("font_outline_color", "TextEdit", p_config.font_outline_color);1255p_theme->set_color("caret_color", "TextEdit", p_config.font_color);1256p_theme->set_color("selection_color", "TextEdit", p_config.selection_color);1257p_theme->set_color("background_color", "TextEdit", Color(0, 0, 0, 0));12581259p_theme->set_constant("line_spacing", "TextEdit", 4 * EDSCALE);1260p_theme->set_constant("outline_size", "TextEdit", 0);1261p_theme->set_constant("caret_width", "TextEdit", 1);1262}12631264// Containers.1265{1266p_theme->set_constant("separation", "BoxContainer", p_config.separation_margin);1267p_theme->set_constant("separation", "HBoxContainer", p_config.separation_margin);1268p_theme->set_constant("separation", "VBoxContainer", p_config.separation_margin);1269p_theme->set_constant("margin_left", "MarginContainer", 0);1270p_theme->set_constant("margin_top", "MarginContainer", 0);1271p_theme->set_constant("margin_right", "MarginContainer", 0);1272p_theme->set_constant("margin_bottom", "MarginContainer", 0);1273p_theme->set_constant("h_separation", "GridContainer", p_config.separation_margin);1274p_theme->set_constant("v_separation", "GridContainer", p_config.separation_margin);1275p_theme->set_constant("h_separation", "FlowContainer", p_config.separation_margin);1276p_theme->set_constant("v_separation", "FlowContainer", p_config.separation_margin);1277p_theme->set_constant("h_separation", "HFlowContainer", p_config.separation_margin);1278p_theme->set_constant("v_separation", "HFlowContainer", p_config.separation_margin);1279p_theme->set_constant("h_separation", "VFlowContainer", p_config.separation_margin);1280p_theme->set_constant("v_separation", "VFlowContainer", p_config.separation_margin);12811282// SplitContainer.12831284p_theme->set_icon("h_grabber", "SplitContainer", p_theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons)));1285p_theme->set_icon("v_grabber", "SplitContainer", p_theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons)));1286p_theme->set_icon("grabber", "VSplitContainer", p_theme->get_icon(SNAME("GuiVsplitter"), EditorStringName(EditorIcons)));1287p_theme->set_icon("grabber", "HSplitContainer", p_theme->get_icon(SNAME("GuiHsplitter"), EditorStringName(EditorIcons)));12881289p_theme->set_constant("separation", "SplitContainer", p_config.separation_margin);1290p_theme->set_constant("separation", "HSplitContainer", p_config.separation_margin);1291p_theme->set_constant("separation", "VSplitContainer", p_config.separation_margin);12921293p_theme->set_constant("minimum_grab_thickness", "SplitContainer", p_config.increased_margin * EDSCALE);1294p_theme->set_constant("minimum_grab_thickness", "HSplitContainer", p_config.increased_margin * EDSCALE);1295p_theme->set_constant("minimum_grab_thickness", "VSplitContainer", p_config.increased_margin * EDSCALE);12961297// GridContainer.1298p_theme->set_constant("v_separation", "GridContainer", Math::round(p_config.widget_margin.y - 2 * EDSCALE));12991300// FoldableContainer13011302Ref<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);1303foldable_container_title->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1304foldable_container_title->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);1305p_theme->set_stylebox("title_panel", "FoldableContainer", foldable_container_title);1306Ref<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);1307foldable_container_hover->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1308foldable_container_hover->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);1309p_theme->set_stylebox("title_hover_panel", "FoldableContainer", foldable_container_hover);1310p_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));1311p_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));1312Ref<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);1313foldable_container_panel->set_corner_radius(CORNER_TOP_LEFT, 0);1314foldable_container_panel->set_corner_radius(CORNER_TOP_RIGHT, 0);1315p_theme->set_stylebox(SceneStringName(panel), "FoldableContainer", foldable_container_panel);1316p_theme->set_stylebox("focus", "FoldableContainer", p_config.button_style_focus);13171318p_theme->set_font(SceneStringName(font), "FoldableContainer", p_theme->get_font(SceneStringName(font), SNAME("HeaderSmall")));1319p_theme->set_font_size(SceneStringName(font_size), "FoldableContainer", p_theme->get_font_size(SceneStringName(font_size), SNAME("HeaderSmall")));13201321p_theme->set_color(SceneStringName(font_color), "FoldableContainer", p_config.font_color);1322p_theme->set_color("hover_font_color", "FoldableContainer", p_config.font_hover_color);1323p_theme->set_color("collapsed_font_color", "FoldableContainer", p_config.font_pressed_color);1324p_theme->set_color("font_outline_color", "FoldableContainer", p_config.font_outline_color);13251326p_theme->set_icon("expanded_arrow", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowDown"), EditorStringName(EditorIcons)));1327p_theme->set_icon("expanded_arrow_mirrored", "FoldableContainer", p_theme->get_icon(SNAME("GuiArrowUp"), EditorStringName(EditorIcons)));1328p_theme->set_icon("folded_arrow", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowRight"), EditorStringName(EditorIcons)));1329p_theme->set_icon("folded_arrow_mirrored", "FoldableContainer", p_theme->get_icon(SNAME("GuiTreeArrowLeft"), EditorStringName(EditorIcons)));13301331p_theme->set_constant("outline_size", "FoldableContainer", 0);1332p_theme->set_constant("h_separation", "FoldableContainer", p_config.separation_margin);1333}13341335// Window and dialogs.1336{1337// Window.13381339p_theme->set_stylebox("embedded_border", "Window", p_config.window_style);1340p_theme->set_stylebox("embedded_unfocused_border", "Window", p_config.window_style);13411342p_theme->set_color("title_color", "Window", p_config.font_color);1343p_theme->set_icon("close", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));1344p_theme->set_icon("close_pressed", "Window", p_theme->get_icon(SNAME("GuiClose"), EditorStringName(EditorIcons)));1345p_theme->set_constant("close_h_offset", "Window", 22 * EDSCALE);1346p_theme->set_constant("close_v_offset", "Window", 20 * EDSCALE);1347p_theme->set_constant("title_height", "Window", 24 * EDSCALE);1348p_theme->set_constant("resize_margin", "Window", 4 * EDSCALE);1349p_theme->set_font("title_font", "Window", p_theme->get_font(SNAME("title"), EditorStringName(EditorFonts)));1350p_theme->set_font_size("title_font_size", "Window", p_theme->get_font_size(SNAME("title_size"), EditorStringName(EditorFonts)));13511352// AcceptDialog.1353p_theme->set_stylebox(SceneStringName(panel), "AcceptDialog", p_config.dialog_style);1354p_theme->set_constant("buttons_separation", "AcceptDialog", 8 * EDSCALE);1355// Make buttons with short texts such as "OK" easier to click/tap.1356p_theme->set_constant("buttons_min_width", "AcceptDialog", p_config.dialogs_buttons_min_size.x * EDSCALE);1357p_theme->set_constant("buttons_min_height", "AcceptDialog", p_config.dialogs_buttons_min_size.y * EDSCALE);13581359// FileDialog.1360p_theme->set_icon("folder", "FileDialog", p_theme->get_icon(SNAME("Folder"), EditorStringName(EditorIcons)));1361p_theme->set_icon("parent_folder", "FileDialog", p_theme->get_icon(SNAME("ArrowUp"), EditorStringName(EditorIcons)));1362p_theme->set_icon("back_folder", "FileDialog", p_theme->get_icon(SNAME("Back"), EditorStringName(EditorIcons)));1363p_theme->set_icon("forward_folder", "FileDialog", p_theme->get_icon(SNAME("Forward"), EditorStringName(EditorIcons)));1364p_theme->set_icon("reload", "FileDialog", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));1365p_theme->set_icon("toggle_hidden", "FileDialog", p_theme->get_icon(SNAME("GuiVisibilityVisible"), EditorStringName(EditorIcons)));1366p_theme->set_icon("create_folder", "FileDialog", p_theme->get_icon(SNAME("FolderCreate"), EditorStringName(EditorIcons)));1367// Use a different color for folder icons to make them easier to distinguish from files.1368// On a light theme, the icon will be dark, so we need to lighten it before blending it with the accent color.1369p_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));1370p_theme->set_color("file_disabled_color", "FileDialog", p_config.font_disabled_color);13711372// PopupDialog.1373p_theme->set_stylebox(SceneStringName(panel), "PopupDialog", p_config.popup_style);13741375// PopupMenu.1376{1377Ref<StyleBoxFlat> style_popup_menu = p_config.popup_border_style->duplicate();1378// Use 1 pixel for the sides, since if 0 is used, the highlight of hovered items is drawn1379// on top of the popup border. This causes a 'gap' in the panel border when an item is highlighted,1380// and it looks weird. 1px solves this.1381style_popup_menu->set_content_margin_individual(Math::round(EDSCALE), 2 * EDSCALE, Math::round(EDSCALE), 2 * EDSCALE);1382p_theme->set_stylebox(SceneStringName(panel), "PopupMenu", style_popup_menu);13831384Ref<StyleBoxFlat> style_menu_hover = p_config.button_style_hover->duplicate();1385// Don't use rounded corners for hover highlights since the StyleBox touches the PopupMenu's edges.1386style_menu_hover->set_corner_radius_all(0);1387p_theme->set_stylebox(SceneStringName(hover), "PopupMenu", style_menu_hover);13881389Ref<StyleBoxLine> style_popup_separator(memnew(StyleBoxLine));1390style_popup_separator->set_color(p_config.separator_color);1391style_popup_separator->set_grow_begin(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));1392style_popup_separator->set_grow_end(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));1393style_popup_separator->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));13941395Ref<StyleBoxLine> style_popup_labeled_separator_left(memnew(StyleBoxLine));1396style_popup_labeled_separator_left->set_grow_begin(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));1397style_popup_labeled_separator_left->set_color(p_config.separator_color);1398style_popup_labeled_separator_left->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));13991400Ref<StyleBoxLine> style_popup_labeled_separator_right(memnew(StyleBoxLine));1401style_popup_labeled_separator_right->set_grow_end(Math::round(EDSCALE) - MAX(Math::round(EDSCALE), p_config.border_width));1402style_popup_labeled_separator_right->set_color(p_config.separator_color);1403style_popup_labeled_separator_right->set_thickness(MAX(Math::round(EDSCALE), p_config.border_width));14041405p_theme->set_stylebox("separator", "PopupMenu", style_popup_separator);1406p_theme->set_stylebox("labeled_separator_left", "PopupMenu", style_popup_labeled_separator_left);1407p_theme->set_stylebox("labeled_separator_right", "PopupMenu", style_popup_labeled_separator_right);14081409p_theme->set_color(SceneStringName(font_color), "PopupMenu", p_config.font_color);1410p_theme->set_color("font_hover_color", "PopupMenu", p_config.font_hover_color);1411p_theme->set_color("font_accelerator_color", "PopupMenu", p_config.font_disabled_color);1412p_theme->set_color("font_disabled_color", "PopupMenu", p_config.font_disabled_color);1413p_theme->set_color("font_separator_color", "PopupMenu", p_config.font_disabled_color);1414p_theme->set_color("font_outline_color", "PopupMenu", p_config.font_outline_color);14151416p_theme->set_icon("checked", "PopupMenu", p_theme->get_icon(SNAME("GuiChecked"), EditorStringName(EditorIcons)));1417p_theme->set_icon("unchecked", "PopupMenu", p_theme->get_icon(SNAME("GuiUnchecked"), EditorStringName(EditorIcons)));1418p_theme->set_icon("radio_checked", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioChecked"), EditorStringName(EditorIcons)));1419p_theme->set_icon("radio_unchecked", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioUnchecked"), EditorStringName(EditorIcons)));1420p_theme->set_icon("checked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiCheckedDisabled"), EditorStringName(EditorIcons)));1421p_theme->set_icon("unchecked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiUncheckedDisabled"), EditorStringName(EditorIcons)));1422p_theme->set_icon("radio_checked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioCheckedDisabled"), EditorStringName(EditorIcons)));1423p_theme->set_icon("radio_unchecked_disabled", "PopupMenu", p_theme->get_icon(SNAME("GuiRadioUncheckedDisabled"), EditorStringName(EditorIcons)));1424p_theme->set_icon("submenu", "PopupMenu", p_theme->get_icon(SNAME("ArrowRight"), EditorStringName(EditorIcons)));1425p_theme->set_icon("submenu_mirrored", "PopupMenu", p_theme->get_icon(SNAME("ArrowLeft"), EditorStringName(EditorIcons)));14261427p_theme->set_constant("v_separation", "PopupMenu", p_config.forced_even_separation * EDSCALE);1428p_theme->set_constant("outline_size", "PopupMenu", 0);1429p_theme->set_constant("item_start_padding", "PopupMenu", p_config.separation_margin);1430p_theme->set_constant("item_end_padding", "PopupMenu", p_config.separation_margin);1431}1432}14331434// Sliders and scrollbars.1435{1436Ref<Texture2D> empty_icon = memnew(ImageTexture);14371438// HScrollBar.14391440if (p_config.enable_touch_optimizations) {1441p_theme->set_stylebox("scroll", "HScrollBar", make_line_stylebox(p_config.separator_color, 50));1442} else {1443p_theme->set_stylebox("scroll", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, -5, 1, -5, 1));1444}1445p_theme->set_stylebox("scroll_focus", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));1446p_theme->set_stylebox("grabber", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));1447p_theme->set_stylebox("grabber_highlight", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));1448p_theme->set_stylebox("grabber_pressed", "HScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));14491450p_theme->set_icon("increment", "HScrollBar", empty_icon);1451p_theme->set_icon("increment_highlight", "HScrollBar", empty_icon);1452p_theme->set_icon("increment_pressed", "HScrollBar", empty_icon);1453p_theme->set_icon("decrement", "HScrollBar", empty_icon);1454p_theme->set_icon("decrement_highlight", "HScrollBar", empty_icon);1455p_theme->set_icon("decrement_pressed", "HScrollBar", empty_icon);14561457// VScrollBar.14581459if (p_config.enable_touch_optimizations) {1460p_theme->set_stylebox("scroll", "VScrollBar", make_line_stylebox(p_config.separator_color, 50, 1, 1, true));1461} else {1462p_theme->set_stylebox("scroll", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, -5, 1, -5));1463}1464p_theme->set_stylebox("scroll_focus", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollBg"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));1465p_theme->set_stylebox("grabber", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabber"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));1466p_theme->set_stylebox("grabber_highlight", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberHl"), EditorStringName(EditorIcons)), 5, 5, 5, 5, 1, 1, 1, 1));1467p_theme->set_stylebox("grabber_pressed", "VScrollBar", make_stylebox(p_theme->get_icon(SNAME("GuiScrollGrabberPressed"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 1, 1, 1, 1));14681469p_theme->set_icon("increment", "VScrollBar", empty_icon);1470p_theme->set_icon("increment_highlight", "VScrollBar", empty_icon);1471p_theme->set_icon("increment_pressed", "VScrollBar", empty_icon);1472p_theme->set_icon("decrement", "VScrollBar", empty_icon);1473p_theme->set_icon("decrement_highlight", "VScrollBar", empty_icon);1474p_theme->set_icon("decrement_pressed", "VScrollBar", empty_icon);14751476// Slider1477const int background_margin = MAX(2, p_config.base_margin / 2);14781479// HSlider.1480p_theme->set_icon("grabber_highlight", "HSlider", p_theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons)));1481p_theme->set_icon("grabber", "HSlider", p_theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons)));1482p_theme->set_stylebox("slider", "HSlider", make_flat_stylebox(p_config.dark_color_3, 0, background_margin, 0, background_margin, p_config.corner_radius));1483p_theme->set_stylebox("grabber_area", "HSlider", make_flat_stylebox(p_config.contrast_color_1, 0, background_margin, 0, background_margin, p_config.corner_radius));1484p_theme->set_stylebox("grabber_area_highlight", "HSlider", make_flat_stylebox(p_config.contrast_color_1, 0, background_margin, 0, background_margin));1485p_theme->set_constant("center_grabber", "HSlider", 0);1486p_theme->set_constant("grabber_offset", "HSlider", 0);14871488// VSlider.1489p_theme->set_icon("grabber", "VSlider", p_theme->get_icon(SNAME("GuiSliderGrabber"), EditorStringName(EditorIcons)));1490p_theme->set_icon("grabber_highlight", "VSlider", p_theme->get_icon(SNAME("GuiSliderGrabberHl"), EditorStringName(EditorIcons)));1491p_theme->set_stylebox("slider", "VSlider", make_flat_stylebox(p_config.dark_color_3, background_margin, 0, background_margin, 0, p_config.corner_radius));1492p_theme->set_stylebox("grabber_area", "VSlider", make_flat_stylebox(p_config.contrast_color_1, background_margin, 0, background_margin, 0, p_config.corner_radius));1493p_theme->set_stylebox("grabber_area_highlight", "VSlider", make_flat_stylebox(p_config.contrast_color_1, background_margin, 0, background_margin, 0));1494p_theme->set_constant("center_grabber", "VSlider", 0);1495p_theme->set_constant("grabber_offset", "VSlider", 0);1496}14971498// Labels.1499{1500// RichTextLabel.15011502p_theme->set_stylebox(CoreStringName(normal), "RichTextLabel", p_config.tree_panel_style);1503p_theme->set_stylebox("focus", "RichTextLabel", make_empty_stylebox());15041505p_theme->set_color("default_color", "RichTextLabel", p_config.font_color);1506p_theme->set_color("font_shadow_color", "RichTextLabel", Color(0, 0, 0, 0));1507p_theme->set_color("font_outline_color", "RichTextLabel", p_config.font_outline_color);1508p_theme->set_color("selection_color", "RichTextLabel", p_config.selection_color);15091510p_theme->set_constant("shadow_offset_x", "RichTextLabel", 1 * EDSCALE);1511p_theme->set_constant("shadow_offset_y", "RichTextLabel", 1 * EDSCALE);1512p_theme->set_constant("shadow_outline_size", "RichTextLabel", 1 * EDSCALE);1513p_theme->set_constant("outline_size", "RichTextLabel", 0);15141515// Label.15161517p_theme->set_stylebox(CoreStringName(normal), "Label", p_config.base_empty_style);1518p_theme->set_stylebox("focus", "Label", p_config.button_style_focus);15191520p_theme->set_color(SceneStringName(font_color), "Label", p_config.font_color);1521p_theme->set_color("font_shadow_color", "Label", Color(0, 0, 0, 0));1522p_theme->set_color("font_outline_color", "Label", p_config.font_outline_color);15231524p_theme->set_constant("shadow_offset_x", "Label", 1 * EDSCALE);1525p_theme->set_constant("shadow_offset_y", "Label", 1 * EDSCALE);1526p_theme->set_constant("shadow_outline_size", "Label", 1 * EDSCALE);1527p_theme->set_constant("line_spacing", "Label", 3 * EDSCALE);1528p_theme->set_constant("outline_size", "Label", 0);1529}15301531// SpinBox.1532{1533Ref<Texture2D> empty_icon = memnew(ImageTexture);1534p_theme->set_icon("updown", "SpinBox", empty_icon);1535p_theme->set_icon("up", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));1536p_theme->set_icon("up_hover", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));1537p_theme->set_icon("up_pressed", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));1538p_theme->set_icon("up_disabled", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxUp"), EditorStringName(EditorIcons)));1539p_theme->set_icon("down", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));1540p_theme->set_icon("down_hover", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));1541p_theme->set_icon("down_pressed", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));1542p_theme->set_icon("down_disabled", "SpinBox", p_theme->get_icon(SNAME("GuiSpinboxDown"), EditorStringName(EditorIcons)));15431544p_theme->set_stylebox("up_background", "SpinBox", make_empty_stylebox());1545p_theme->set_stylebox("up_background_hovered", "SpinBox", p_config.button_style_hover);1546p_theme->set_stylebox("up_background_pressed", "SpinBox", p_config.button_style_pressed);1547p_theme->set_stylebox("up_background_disabled", "SpinBox", make_empty_stylebox());1548p_theme->set_stylebox("down_background", "SpinBox", make_empty_stylebox());1549p_theme->set_stylebox("down_background_hovered", "SpinBox", p_config.button_style_hover);1550p_theme->set_stylebox("down_background_pressed", "SpinBox", p_config.button_style_pressed);1551p_theme->set_stylebox("down_background_disabled", "SpinBox", make_empty_stylebox());15521553p_theme->set_color("up_icon_modulate", "SpinBox", p_config.font_color);1554p_theme->set_color("up_hover_icon_modulate", "SpinBox", p_config.font_hover_color);1555p_theme->set_color("up_pressed_icon_modulate", "SpinBox", p_config.font_pressed_color);1556p_theme->set_color("up_disabled_icon_modulate", "SpinBox", p_config.font_disabled_color);1557p_theme->set_color("down_icon_modulate", "SpinBox", p_config.font_color);1558p_theme->set_color("down_hover_icon_modulate", "SpinBox", p_config.font_hover_color);1559p_theme->set_color("down_pressed_icon_modulate", "SpinBox", p_config.font_pressed_color);1560p_theme->set_color("down_disabled_icon_modulate", "SpinBox", p_config.font_disabled_color);15611562p_theme->set_stylebox("field_and_buttons_separator", "SpinBox", make_empty_stylebox());1563p_theme->set_stylebox("up_down_buttons_separator", "SpinBox", make_empty_stylebox());15641565p_theme->set_constant("buttons_vertical_separation", "SpinBox", 0);1566p_theme->set_constant("field_and_buttons_separation", "SpinBox", 2);1567p_theme->set_constant("buttons_width", "SpinBox", 16);1568#ifndef DISABLE_DEPRECATED1569p_theme->set_constant("set_min_buttons_width_from_icons", "SpinBox", 1);1570#endif1571}15721573// ProgressBar.1574p_theme->set_stylebox("background", "ProgressBar", make_stylebox(p_theme->get_icon(SNAME("GuiProgressBar"), EditorStringName(EditorIcons)), 4, 4, 4, 4, 0, 0, 0, 0));1575p_theme->set_stylebox("fill", "ProgressBar", make_stylebox(p_theme->get_icon(SNAME("GuiProgressFill"), EditorStringName(EditorIcons)), 6, 6, 6, 6, 2, 1, 2, 1));1576p_theme->set_color(SceneStringName(font_color), "ProgressBar", p_config.font_color);1577p_theme->set_color("font_outline_color", "ProgressBar", p_config.font_outline_color);1578p_theme->set_constant("outline_size", "ProgressBar", 0);15791580// GraphEdit and related nodes.1581{1582// GraphEdit.15831584p_theme->set_stylebox(SceneStringName(panel), "GraphEdit", p_config.tree_panel_style);1585p_theme->set_stylebox("panel_focus", "GraphEdit", p_config.button_style_focus);1586p_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));15871588float grid_base_brightness = p_config.dark_theme ? 1.0 : 0.0;1589GraphEdit::GridPattern grid_pattern = (GraphEdit::GridPattern) int(EDITOR_GET("editors/visual_editors/grid_pattern"));1590switch (grid_pattern) {1591case GraphEdit::GRID_PATTERN_LINES:1592p_theme->set_color("grid_major", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.10));1593p_theme->set_color("grid_minor", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.05));1594break;1595case GraphEdit::GRID_PATTERN_DOTS:1596p_theme->set_color("grid_major", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.07));1597p_theme->set_color("grid_minor", "GraphEdit", Color(grid_base_brightness, grid_base_brightness, grid_base_brightness, 0.07));1598break;1599default:1600WARN_PRINT("Unknown grid pattern.");1601break;1602}16031604p_theme->set_color("selection_fill", "GraphEdit", p_theme->get_color(SNAME("box_selection_fill_color"), EditorStringName(Editor)));1605p_theme->set_color("selection_stroke", "GraphEdit", p_theme->get_color(SNAME("box_selection_stroke_color"), EditorStringName(Editor)));1606p_theme->set_color("activity", "GraphEdit", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));16071608p_theme->set_color("connection_hover_tint_color", "GraphEdit", p_config.dark_theme ? Color(0, 0, 0, 0.3) : Color(1, 1, 1, 0.3));1609p_theme->set_constant("connection_hover_thickness", "GraphEdit", 0);1610p_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));1611p_theme->set_color("connection_rim_color", "GraphEdit", p_config.tree_panel_style->get_bg_color());16121613p_theme->set_icon("zoom_out", "GraphEdit", p_theme->get_icon(SNAME("ZoomLess"), EditorStringName(EditorIcons)));1614p_theme->set_icon("zoom_in", "GraphEdit", p_theme->get_icon(SNAME("ZoomMore"), EditorStringName(EditorIcons)));1615p_theme->set_icon("zoom_reset", "GraphEdit", p_theme->get_icon(SNAME("ZoomReset"), EditorStringName(EditorIcons)));1616p_theme->set_icon("grid_toggle", "GraphEdit", p_theme->get_icon(SNAME("GridToggle"), EditorStringName(EditorIcons)));1617p_theme->set_icon("minimap_toggle", "GraphEdit", p_theme->get_icon(SNAME("GridMinimap"), EditorStringName(EditorIcons)));1618p_theme->set_icon("snapping_toggle", "GraphEdit", p_theme->get_icon(SNAME("SnapGrid"), EditorStringName(EditorIcons)));1619p_theme->set_icon("layout", "GraphEdit", p_theme->get_icon(SNAME("GridLayout"), EditorStringName(EditorIcons)));16201621// GraphEditMinimap.1622{1623Ref<StyleBoxFlat> style_minimap_bg = make_flat_stylebox(p_config.dark_color_1, 0, 0, 0, 0);1624style_minimap_bg->set_border_color(p_config.dark_color_3);1625style_minimap_bg->set_border_width_all(1);1626p_theme->set_stylebox(SceneStringName(panel), "GraphEditMinimap", style_minimap_bg);16271628Ref<StyleBoxFlat> style_minimap_camera;1629Ref<StyleBoxFlat> style_minimap_node;1630if (p_config.dark_theme) {1631style_minimap_camera = make_flat_stylebox(Color(0.65, 0.65, 0.65, 0.2), 0, 0, 0, 0);1632style_minimap_camera->set_border_color(Color(0.65, 0.65, 0.65, 0.45));1633style_minimap_node = make_flat_stylebox(Color(1, 1, 1), 0, 0, 0, 0);1634} else {1635style_minimap_camera = make_flat_stylebox(Color(0.38, 0.38, 0.38, 0.2), 0, 0, 0, 0);1636style_minimap_camera->set_border_color(Color(0.38, 0.38, 0.38, 0.45));1637style_minimap_node = make_flat_stylebox(Color(0, 0, 0), 0, 0, 0, 0);1638}1639style_minimap_camera->set_border_width_all(1);1640style_minimap_node->set_anti_aliased(false);1641p_theme->set_stylebox("camera", "GraphEditMinimap", style_minimap_camera);1642p_theme->set_stylebox("node", "GraphEditMinimap", style_minimap_node);16431644const Color minimap_resizer_color = p_config.dark_theme ? Color(1, 1, 1, 0.65) : Color(0, 0, 0, 0.65);1645p_theme->set_icon("resizer", "GraphEditMinimap", p_theme->get_icon(SNAME("GuiResizerTopLeft"), EditorStringName(EditorIcons)));1646p_theme->set_color("resizer_color", "GraphEditMinimap", minimap_resizer_color);1647}16481649// GraphElement, GraphNode & GraphFrame.1650{1651const int gn_margin_top = 2;1652const int gn_margin_side = 2;1653const int gn_margin_bottom = 2;16541655const int gn_corner_radius = 3;16561657const 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);1658const Color gn_selected_border_color = p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0);1659const Color gn_frame_bg = gn_bg_color.lerp(p_config.tree_panel_style->get_bg_color(), 0.3);16601661const bool high_contrast_borders = p_config.draw_extra_borders && p_config.dark_theme;16621663Ref<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);1664gn_panel_style->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);1665gn_panel_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);1666gn_panel_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);1667gn_panel_style->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));1668gn_panel_style->set_corner_radius_individual(0, 0, gn_corner_radius * EDSCALE, gn_corner_radius * EDSCALE);1669gn_panel_style->set_anti_aliased(true);16701671Ref<StyleBoxFlat> gn_panel_selected_style = gn_panel_style->duplicate();1672gn_panel_selected_style->set_bg_color(p_config.dark_theme ? gn_bg_color.lightened(0.15) : gn_bg_color.darkened(0.15));1673gn_panel_selected_style->set_border_width(SIDE_TOP, 0);1674gn_panel_selected_style->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);1675gn_panel_selected_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);1676gn_panel_selected_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);1677gn_panel_selected_style->set_border_color(gn_selected_border_color);16781679const int gn_titlebar_margin_top = 8;1680const int gn_titlebar_margin_side = 12;1681const int gn_titlebar_margin_bottom = 8;16821683Ref<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);1684gn_titlebar_style->set_border_width(SIDE_TOP, 2 * EDSCALE);1685gn_titlebar_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);1686gn_titlebar_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);1687gn_titlebar_style->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));1688gn_titlebar_style->set_expand_margin(SIDE_TOP, 2 * EDSCALE);1689gn_titlebar_style->set_corner_radius_individual(gn_corner_radius * EDSCALE, gn_corner_radius * EDSCALE, 0, 0);1690gn_titlebar_style->set_anti_aliased(true);16911692Ref<StyleBoxFlat> gn_titlebar_selected_style = gn_titlebar_style->duplicate();1693gn_titlebar_selected_style->set_border_color(gn_selected_border_color);1694gn_titlebar_selected_style->set_border_width(SIDE_TOP, 2 * EDSCALE);1695gn_titlebar_selected_style->set_border_width(SIDE_LEFT, 2 * EDSCALE);1696gn_titlebar_selected_style->set_border_width(SIDE_RIGHT, 2 * EDSCALE);1697gn_titlebar_selected_style->set_expand_margin(SIDE_TOP, 2 * EDSCALE);16981699Color gn_decoration_color = p_config.dark_color_1.inverted();17001701// GraphElement.17021703p_theme->set_stylebox(SceneStringName(panel), "GraphElement", gn_panel_style);1704p_theme->set_stylebox("panel_selected", "GraphElement", gn_panel_selected_style);1705p_theme->set_stylebox("titlebar", "GraphElement", gn_titlebar_style);1706p_theme->set_stylebox("titlebar_selected", "GraphElement", gn_titlebar_selected_style);17071708p_theme->set_color("resizer_color", "GraphElement", gn_decoration_color);1709p_theme->set_icon("resizer", "GraphElement", p_theme->get_icon(SNAME("GuiResizer"), EditorStringName(EditorIcons)));17101711// GraphNode.17121713Ref<StyleBoxEmpty> gn_slot_style = make_empty_stylebox(12, 0, 12, 0);17141715p_theme->set_stylebox(SceneStringName(panel), "GraphNode", gn_panel_style);1716p_theme->set_stylebox("panel_selected", "GraphNode", gn_panel_selected_style);1717p_theme->set_stylebox("panel_focus", "GraphNode", p_config.button_style_focus);1718p_theme->set_stylebox("titlebar", "GraphNode", gn_titlebar_style);1719p_theme->set_stylebox("titlebar_selected", "GraphNode", gn_titlebar_selected_style);1720p_theme->set_stylebox("slot", "GraphNode", gn_slot_style);1721p_theme->set_stylebox("slot_selected", "GraphNode", p_config.button_style_focus);17221723p_theme->set_color("resizer_color", "GraphNode", gn_decoration_color);17241725p_theme->set_constant("port_h_offset", "GraphNode", 1);1726p_theme->set_constant("separation", "GraphNode", 1 * EDSCALE);17271728Ref<DPITexture> port_icon = p_theme->get_icon(SNAME("GuiGraphNodePort"), EditorStringName(EditorIcons));1729// The true size is 24x24 This is necessary for sharp port icons at high zoom levels in GraphEdit (up to ~200%).1730port_icon->set_size_override(Size2(12, 12));1731p_theme->set_icon("port", "GraphNode", port_icon);17321733// GraphNode's title Label.1734p_theme->set_type_variation("GraphNodeTitleLabel", "Label");1735p_theme->set_stylebox(CoreStringName(normal), "GraphNodeTitleLabel", make_empty_stylebox(0, 0, 0, 0));1736p_theme->set_color("font_shadow_color", "GraphNodeTitleLabel", p_config.shadow_color);1737p_theme->set_constant("shadow_outline_size", "GraphNodeTitleLabel", 4);1738p_theme->set_constant("shadow_offset_x", "GraphNodeTitleLabel", 0);1739p_theme->set_constant("shadow_offset_y", "GraphNodeTitleLabel", 1);1740p_theme->set_constant("line_spacing", "GraphNodeTitleLabel", 3 * EDSCALE);17411742// GraphFrame.17431744const int gf_corner_width = 7 * EDSCALE;1745const int gf_border_width = 2 * MAX(1, EDSCALE);17461747Ref<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);1748graphframe_sb->set_expand_margin(SIDE_TOP, 38 * EDSCALE);1749graphframe_sb->set_border_width_all(gf_border_width);1750graphframe_sb->set_border_color(high_contrast_borders ? gn_bg_color.lightened(0.2) : gn_bg_color.darkened(0.3));1751graphframe_sb->set_shadow_size(8 * EDSCALE);1752graphframe_sb->set_shadow_color(Color(p_config.shadow_color, p_config.shadow_color.a * 0.25));1753graphframe_sb->set_anti_aliased(true);17541755Ref<StyleBoxFlat> graphframe_sb_selected = graphframe_sb->duplicate();1756graphframe_sb_selected->set_border_color(gn_selected_border_color);17571758p_theme->set_stylebox(SceneStringName(panel), "GraphFrame", graphframe_sb);1759p_theme->set_stylebox("panel_selected", "GraphFrame", graphframe_sb_selected);1760p_theme->set_stylebox("titlebar", "GraphFrame", make_empty_stylebox(4, 4, 4, 4));1761p_theme->set_stylebox("titlebar_selected", "GraphFrame", make_empty_stylebox(4, 4, 4, 4));1762p_theme->set_color("resizer_color", "GraphFrame", gn_decoration_color);17631764// GraphFrame's title Label.1765p_theme->set_type_variation("GraphFrameTitleLabel", "Label");1766p_theme->set_stylebox(CoreStringName(normal), "GraphFrameTitleLabel", memnew(StyleBoxEmpty));1767p_theme->set_font_size(SceneStringName(font_size), "GraphFrameTitleLabel", 22 * EDSCALE);1768p_theme->set_color(SceneStringName(font_color), "GraphFrameTitleLabel", Color(1, 1, 1));1769p_theme->set_color("font_shadow_color", "GraphFrameTitleLabel", Color(0, 0, 0, 0));1770p_theme->set_color("font_outline_color", "GraphFrameTitleLabel", Color(1, 1, 1));1771p_theme->set_constant("shadow_offset_x", "GraphFrameTitleLabel", 1 * EDSCALE);1772p_theme->set_constant("shadow_offset_y", "GraphFrameTitleLabel", 1 * EDSCALE);1773p_theme->set_constant("outline_size", "GraphFrameTitleLabel", 0);1774p_theme->set_constant("shadow_outline_size", "GraphFrameTitleLabel", 1 * EDSCALE);1775p_theme->set_constant("line_spacing", "GraphFrameTitleLabel", 3 * EDSCALE);1776}17771778// VisualShader reroute node.1779{1780Ref<StyleBox> vs_reroute_panel_style = make_empty_stylebox();1781Ref<StyleBox> vs_reroute_titlebar_style = vs_reroute_panel_style->duplicate();1782vs_reroute_titlebar_style->set_content_margin_all(16 * EDSCALE);1783p_theme->set_stylebox(SceneStringName(panel), "VSRerouteNode", vs_reroute_panel_style);1784p_theme->set_stylebox("panel_selected", "VSRerouteNode", vs_reroute_panel_style);1785p_theme->set_stylebox("titlebar", "VSRerouteNode", vs_reroute_titlebar_style);1786p_theme->set_stylebox("titlebar_selected", "VSRerouteNode", vs_reroute_titlebar_style);1787p_theme->set_stylebox("slot", "VSRerouteNode", make_empty_stylebox());17881789p_theme->set_color("drag_background", "VSRerouteNode", p_config.dark_theme ? Color(0.19, 0.21, 0.24) : Color(0.8, 0.8, 0.8));1790p_theme->set_color("selected_rim_color", "VSRerouteNode", p_config.dark_theme ? Color(1, 1, 1) : Color(0, 0, 0));1791}1792}17931794// ColorPicker and related nodes.1795{1796// ColorPicker.1797p_config.circle_style_focus = p_config.button_style_focus->duplicate();1798p_config.circle_style_focus->set_corner_radius_all(256 * EDSCALE);1799p_config.circle_style_focus->set_corner_detail(32 * EDSCALE);18001801p_theme->set_constant("margin", "ColorPicker", p_config.base_margin);1802p_theme->set_constant("sv_width", "ColorPicker", 256 * EDSCALE);1803p_theme->set_constant("sv_height", "ColorPicker", 256 * EDSCALE);1804p_theme->set_constant("h_width", "ColorPicker", 30 * EDSCALE);1805p_theme->set_constant("label_width", "ColorPicker", 10 * EDSCALE);1806p_theme->set_constant("center_slider_grabbers", "ColorPicker", 1);18071808p_theme->set_stylebox("sample_focus", "ColorPicker", p_config.button_style_focus);1809p_theme->set_stylebox("picker_focus_rectangle", "ColorPicker", p_config.button_style_focus);1810p_theme->set_stylebox("picker_focus_circle", "ColorPicker", p_config.circle_style_focus);1811p_theme->set_color("focused_not_editing_cursor_color", "ColorPicker", p_config.highlight_color);18121813p_theme->set_icon("screen_picker", "ColorPicker", p_theme->get_icon(SNAME("ColorPick"), EditorStringName(EditorIcons)));1814p_theme->set_icon("shape_circle", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeCircle"), EditorStringName(EditorIcons)));1815p_theme->set_icon("shape_rect", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangle"), EditorStringName(EditorIcons)));1816p_theme->set_icon("shape_rect_wheel", "ColorPicker", p_theme->get_icon(SNAME("PickerShapeRectangleWheel"), EditorStringName(EditorIcons)));1817p_theme->set_icon("add_preset", "ColorPicker", p_theme->get_icon(SNAME("Add"), EditorStringName(EditorIcons)));1818p_theme->set_icon("sample_bg", "ColorPicker", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));1819p_theme->set_icon("sample_revert", "ColorPicker", p_theme->get_icon(SNAME("Reload"), EditorStringName(EditorIcons)));1820p_theme->set_icon("overbright_indicator", "ColorPicker", p_theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons)));1821p_theme->set_icon("bar_arrow", "ColorPicker", p_theme->get_icon(SNAME("ColorPickerBarArrow"), EditorStringName(EditorIcons)));1822p_theme->set_icon("picker_cursor", "ColorPicker", p_theme->get_icon(SNAME("PickerCursor"), EditorStringName(EditorIcons)));1823p_theme->set_icon("picker_cursor_bg", "ColorPicker", p_theme->get_icon(SNAME("PickerCursorBg"), EditorStringName(EditorIcons)));1824p_theme->set_icon("color_script", "ColorPicker", p_theme->get_icon(SNAME("Script"), EditorStringName(EditorIcons)));18251826// ColorPickerButton.1827p_theme->set_icon("bg", "ColorPickerButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));18281829// ColorPresetButton.1830p_theme->set_stylebox("preset_fg", "ColorPresetButton", make_flat_stylebox(Color(1, 1, 1), 2, 2, 2, 2, 2));1831p_theme->set_icon("preset_bg", "ColorPresetButton", p_theme->get_icon(SNAME("GuiMiniCheckerboard"), EditorStringName(EditorIcons)));1832p_theme->set_icon("overbright_indicator", "ColorPresetButton", p_theme->get_icon(SNAME("OverbrightIndicator"), EditorStringName(EditorIcons)));1833}1834}18351836void EditorThemeManager::_populate_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {1837// Project manager.1838{1839p_theme->set_stylebox("project_list", "ProjectManager", p_config.tree_panel_style);1840p_theme->set_constant("sidebar_button_icon_separation", "ProjectManager", int(6 * EDSCALE));1841p_theme->set_icon("browse_folder", "ProjectManager", p_theme->get_icon(SNAME("FolderBrowse"), EditorStringName(EditorIcons)));1842p_theme->set_icon("browse_file", "ProjectManager", p_theme->get_icon(SNAME("FileBrowse"), EditorStringName(EditorIcons)));18431844// ProjectTag.1845{1846p_theme->set_type_variation("ProjectTagButton", "Button");18471848Ref<StyleBoxFlat> tag = p_config.button_style->duplicate();1849tag->set_bg_color(p_config.dark_theme ? tag->get_bg_color().lightened(0.2) : tag->get_bg_color().darkened(0.2));1850tag->set_corner_radius(CORNER_TOP_LEFT, 0);1851tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1852tag->set_corner_radius(CORNER_TOP_RIGHT, 4);1853tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);1854p_theme->set_stylebox(CoreStringName(normal), "ProjectTagButton", tag);18551856tag = p_config.button_style_hover->duplicate();1857tag->set_corner_radius(CORNER_TOP_LEFT, 0);1858tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1859tag->set_corner_radius(CORNER_TOP_RIGHT, 4);1860tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);1861p_theme->set_stylebox(SceneStringName(hover), "ProjectTagButton", tag);18621863tag = p_config.button_style_pressed->duplicate();1864tag->set_corner_radius(CORNER_TOP_LEFT, 0);1865tag->set_corner_radius(CORNER_BOTTOM_LEFT, 0);1866tag->set_corner_radius(CORNER_TOP_RIGHT, 4);1867tag->set_corner_radius(CORNER_BOTTOM_RIGHT, 4);1868p_theme->set_stylebox(SceneStringName(pressed), "ProjectTagButton", tag);1869}1870}18711872// Editor and main screen.1873{1874// Editor background.1875Color background_color_opaque = p_config.dark_color_2;1876background_color_opaque.a = 1.0;1877p_theme->set_color("background", EditorStringName(Editor), background_color_opaque);1878p_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));18791880Ref<StyleBoxFlat> editor_panel_foreground = p_config.base_style->duplicate();1881editor_panel_foreground->set_corner_radius_all(0);1882p_theme->set_stylebox("PanelForeground", EditorStringName(EditorStyles), editor_panel_foreground);18831884// Editor focus.1885p_theme->set_stylebox("Focus", EditorStringName(EditorStyles), p_config.button_style_focus);18861887Ref<StyleBoxFlat> style_widget_focus_viewport = p_config.button_style_focus->duplicate();1888// Use a less opaque color to be less distracting for the 2D and 3D editor viewports.1889style_widget_focus_viewport->set_border_color(p_config.accent_color * Color(1, 1, 1, 0.5));1890p_theme->set_stylebox("FocusViewport", EditorStringName(EditorStyles), style_widget_focus_viewport);18911892Ref<StyleBoxFlat> style_widget_scroll_container = p_config.button_style_focus->duplicate();1893p_theme->set_stylebox("focus", "ScrollContainer", style_widget_scroll_container);18941895// This stylebox is used in 3d and 2d viewports (no borders).1896Ref<StyleBoxFlat> style_content_panel_vp = p_config.content_panel_style->duplicate();1897style_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);1898p_theme->set_stylebox("Content", EditorStringName(EditorStyles), style_content_panel_vp);18991900// 3D/Spatial editor.1901Ref<StyleBoxFlat> style_info_3d_viewport = p_config.base_style->duplicate();1902style_info_3d_viewport->set_bg_color(style_info_3d_viewport->get_bg_color() * Color(1, 1, 1, 0.5));1903style_info_3d_viewport->set_border_width_all(0);1904p_theme->set_stylebox("Information3dViewport", EditorStringName(EditorStyles), style_info_3d_viewport);19051906// 2D and 3D contextual toolbar.1907// Use a custom stylebox to make contextual menu items stand out from the rest.1908// This helps with editor usability as contextual menu items change when selecting nodes,1909// even though it may not be immediately obvious at first.1910Ref<StyleBoxFlat> toolbar_stylebox = memnew(StyleBoxFlat);1911toolbar_stylebox->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));1912toolbar_stylebox->set_anti_aliased(false);1913// Add an underline to the StyleBox, but prevent its minimum vertical size from changing.1914toolbar_stylebox->set_border_color(p_config.accent_color);1915toolbar_stylebox->set_border_width(SIDE_BOTTOM, Math::round(2 * EDSCALE));1916toolbar_stylebox->set_content_margin(SIDE_BOTTOM, 0);1917toolbar_stylebox->set_expand_margin_individual(4 * EDSCALE, 2 * EDSCALE, 4 * EDSCALE, 4 * EDSCALE);1918p_theme->set_stylebox("ContextualToolbar", EditorStringName(EditorStyles), toolbar_stylebox);19191920// Script editor.1921p_theme->set_stylebox("ScriptEditorPanel", EditorStringName(EditorStyles), make_empty_stylebox(p_config.base_margin, 0, p_config.base_margin, p_config.base_margin));1922p_theme->set_stylebox("ScriptEditorPanelFloating", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));1923p_theme->set_stylebox("ScriptEditor", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));19241925// Game view.1926p_theme->set_type_variation("GamePanel", "Panel");1927Ref<StyleBoxFlat> game_panel = p_theme->get_stylebox(SceneStringName(panel), SNAME("Panel"))->duplicate();1928game_panel->set_corner_radius_all(0);1929p_theme->set_stylebox(SceneStringName(panel), "GamePanel", game_panel);19301931// Main menu.1932Ref<StyleBoxFlat> menu_transparent_style = p_config.button_style->duplicate();1933menu_transparent_style->set_bg_color(Color(1, 1, 1, 0));1934menu_transparent_style->set_border_width_all(0);1935Ref<StyleBoxFlat> main_screen_button_hover = p_config.button_style_hover->duplicate();1936for (int i = 0; i < 4; i++) {1937menu_transparent_style->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));1938main_screen_button_hover->set_content_margin((Side)i, p_config.button_style_hover->get_content_margin((Side)i));1939}1940p_theme->set_stylebox(CoreStringName(normal), "MainScreenButton", menu_transparent_style);1941p_theme->set_stylebox("normal_mirrored", "MainScreenButton", menu_transparent_style);1942p_theme->set_stylebox(SceneStringName(pressed), "MainScreenButton", menu_transparent_style);1943p_theme->set_stylebox("pressed_mirrored", "MainScreenButton", menu_transparent_style);1944p_theme->set_stylebox(SceneStringName(hover), "MainScreenButton", main_screen_button_hover);1945p_theme->set_stylebox("hover_mirrored", "MainScreenButton", main_screen_button_hover);1946p_theme->set_stylebox("hover_pressed", "MainScreenButton", main_screen_button_hover);1947p_theme->set_stylebox("hover_pressed_mirrored", "MainScreenButton", main_screen_button_hover);19481949p_theme->set_type_variation("MainMenuBar", "FlatMenuButton");1950p_theme->set_stylebox(CoreStringName(normal), "MainMenuBar", menu_transparent_style);1951p_theme->set_stylebox(SceneStringName(pressed), "MainMenuBar", main_screen_button_hover);1952p_theme->set_stylebox(SceneStringName(hover), "MainMenuBar", main_screen_button_hover);1953p_theme->set_stylebox("hover_pressed", "MainMenuBar", main_screen_button_hover);19541955// Run bar.1956p_theme->set_type_variation("RunBarButton", "FlatMenuButton");1957p_theme->set_stylebox("disabled", "RunBarButton", menu_transparent_style);1958p_theme->set_stylebox(SceneStringName(pressed), "RunBarButton", menu_transparent_style);19591960p_theme->set_type_variation("RunBarButtonMovieMakerDisabled", "RunBarButton");1961p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.7));1962p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));1963p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.9));1964p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerDisabled", Color(1, 1, 1, 0.84));19651966p_theme->set_type_variation("RunBarButtonMovieMakerEnabled", "RunBarButton");1967p_theme->set_color("icon_normal_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.7));1968p_theme->set_color("icon_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));1969p_theme->set_color("icon_hover_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.9));1970p_theme->set_color("icon_hover_pressed_color", "RunBarButtonMovieMakerEnabled", Color(0, 0, 0, 0.84));19711972// Bottom panel.1973Ref<StyleBoxFlat> style_bottom_panel = p_config.content_panel_style->duplicate();1974style_bottom_panel->set_corner_radius_all(p_config.corner_radius * EDSCALE);1975p_theme->set_stylebox("BottomPanel", EditorStringName(EditorStyles), style_bottom_panel);1976p_theme->set_type_variation("BottomPanelButton", "FlatMenuButton");1977p_theme->set_stylebox(CoreStringName(normal), "BottomPanelButton", menu_transparent_style);1978p_theme->set_stylebox(SceneStringName(pressed), "BottomPanelButton", menu_transparent_style);1979p_theme->set_stylebox("hover_pressed", "BottomPanelButton", main_screen_button_hover);1980p_theme->set_stylebox(SceneStringName(hover), "BottomPanelButton", main_screen_button_hover);1981// Don't tint the icon even when in "pressed" state.1982p_theme->set_color("icon_pressed_color", "BottomPanelButton", Color(1, 1, 1, 1));1983Color icon_hover_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.0);1984icon_hover_color.a = 1.0;1985p_theme->set_color("icon_hover_color", "BottomPanelButton", icon_hover_color);1986p_theme->set_color("icon_hover_pressed_color", "BottomPanelButton", icon_hover_color);19871988// Audio bus.1989p_theme->set_stylebox("normal", "EditorAudioBus", style_bottom_panel);1990p_theme->set_stylebox("master", "EditorAudioBus", p_config.button_style_disabled);1991p_theme->set_stylebox("focus", "EditorAudioBus", p_config.button_style_focus);1992}19931994// Editor GUI widgets.1995{1996// EditorSpinSlider.1997p_theme->set_color("label_color", "EditorSpinSlider", p_config.font_color);1998p_theme->set_color("read_only_label_color", "EditorSpinSlider", p_config.font_readonly_color);19992000Ref<StyleBoxFlat> editor_spin_label_bg = p_config.base_style->duplicate();2001editor_spin_label_bg->set_bg_color(p_config.dark_color_3);2002editor_spin_label_bg->set_border_width_all(0);2003p_theme->set_stylebox("label_bg", "EditorSpinSlider", editor_spin_label_bg);20042005// TODO Use separate arrows instead like on SpinBox. Planned for a different PR.2006p_theme->set_icon("updown", "EditorSpinSlider", p_theme->get_icon(SNAME("GuiSpinboxUpdown"), EditorStringName(EditorIcons)));2007p_theme->set_icon("updown_disabled", "EditorSpinSlider", p_theme->get_icon(SNAME("GuiSpinboxUpdownDisabled"), EditorStringName(EditorIcons)));20082009// Launch Pad and Play buttons.2010Ref<StyleBoxFlat> style_launch_pad = make_flat_stylebox(p_config.dark_color_1, 2 * EDSCALE, 0, 2 * EDSCALE, 0, p_config.corner_radius);2011style_launch_pad->set_corner_radius_all(p_config.corner_radius * EDSCALE);2012p_theme->set_stylebox("LaunchPadNormal", EditorStringName(EditorStyles), style_launch_pad);2013Ref<StyleBoxFlat> style_launch_pad_movie = style_launch_pad->duplicate();2014style_launch_pad_movie->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));2015style_launch_pad_movie->set_border_color(p_config.accent_color);2016style_launch_pad_movie->set_border_width_all(Math::round(2 * EDSCALE));2017p_theme->set_stylebox("LaunchPadMovieMode", EditorStringName(EditorStyles), style_launch_pad_movie);2018Ref<StyleBoxFlat> style_launch_pad_recovery_mode = style_launch_pad->duplicate();2019style_launch_pad_recovery_mode->set_bg_color(p_config.accent_color * Color(1, 1, 1, 0.1));2020style_launch_pad_recovery_mode->set_border_color(p_config.warning_color);2021style_launch_pad_recovery_mode->set_border_width_all(Math::round(2 * EDSCALE));2022p_theme->set_stylebox("LaunchPadRecoveryMode", EditorStringName(EditorStyles), style_launch_pad_recovery_mode);20232024p_theme->set_stylebox("MovieWriterButtonNormal", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));2025Ref<StyleBoxFlat> style_write_movie_button = p_config.button_style_pressed->duplicate();2026style_write_movie_button->set_bg_color(p_config.accent_color);2027style_write_movie_button->set_corner_radius_all(p_config.corner_radius * EDSCALE);2028style_write_movie_button->set_content_margin(SIDE_TOP, 0);2029style_write_movie_button->set_content_margin(SIDE_BOTTOM, 0);2030style_write_movie_button->set_content_margin(SIDE_LEFT, 0);2031style_write_movie_button->set_content_margin(SIDE_RIGHT, 0);2032style_write_movie_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);2033p_theme->set_stylebox("MovieWriterButtonPressed", EditorStringName(EditorStyles), style_write_movie_button);20342035// Profiler autostart indicator panel.2036Ref<StyleBoxFlat> style_profiler_autostart = style_launch_pad->duplicate();2037style_profiler_autostart->set_bg_color(Color(1, 0.867, 0.396));2038p_theme->set_type_variation("ProfilerAutostartIndicator", "Button");2039p_theme->set_stylebox(CoreStringName(normal), "ProfilerAutostartIndicator", style_profiler_autostart);2040p_theme->set_stylebox(SceneStringName(pressed), "ProfilerAutostartIndicator", style_profiler_autostart);2041p_theme->set_stylebox("hover", "ProfilerAutostartIndicator", style_profiler_autostart);20422043// Recovery mode button style2044Ref<StyleBoxFlat> style_recovery_mode_button = p_config.button_style_pressed->duplicate();2045style_recovery_mode_button->set_bg_color(p_config.warning_color);2046style_recovery_mode_button->set_corner_radius_all(p_config.corner_radius * EDSCALE);2047style_recovery_mode_button->set_content_margin_all(0);2048// Recovery mode button is implicitly styled from the panel's background.2049// So, remove any existing borders. (e.g. from draw_extra_borders config)2050style_recovery_mode_button->set_border_width_all(0);2051style_recovery_mode_button->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);2052p_theme->set_stylebox("RecoveryModeButton", EditorStringName(EditorStyles), style_recovery_mode_button);2053}20542055// Standard GUI variations.2056{2057// Custom theme type for MarginContainer with 4px margins.2058p_theme->set_type_variation("MarginContainer4px", "MarginContainer");2059p_theme->set_constant("margin_left", "MarginContainer4px", 4 * EDSCALE);2060p_theme->set_constant("margin_top", "MarginContainer4px", 4 * EDSCALE);2061p_theme->set_constant("margin_right", "MarginContainer4px", 4 * EDSCALE);2062p_theme->set_constant("margin_bottom", "MarginContainer4px", 4 * EDSCALE);20632064// Header LinkButton variation.2065p_theme->set_type_variation("HeaderSmallLink", "LinkButton");2066p_theme->set_font(SceneStringName(font), "HeaderSmallLink", p_theme->get_font(SceneStringName(font), SNAME("HeaderSmall")));2067p_theme->set_font_size(SceneStringName(font_size), "HeaderSmallLink", p_theme->get_font_size(SceneStringName(font_size), SNAME("HeaderSmall")));20682069// Flat button variations.2070{2071Ref<StyleBoxEmpty> style_flat_button = make_empty_stylebox();2072Ref<StyleBoxFlat> style_flat_button_hover = p_config.button_style_hover->duplicate();2073Ref<StyleBoxFlat> style_flat_button_pressed = p_config.button_style_pressed->duplicate();20742075for (int i = 0; i < 4; i++) {2076style_flat_button->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));2077style_flat_button_hover->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));2078style_flat_button_pressed->set_content_margin((Side)i, p_config.button_style->get_content_margin((Side)i));2079}2080Color 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);2081if (p_config.dark_theme) {2082flat_pressed_color = p_config.dark_color_1.lerp(p_config.accent_color, 0.12) * Color(0.6, 0.6, 0.6, 0.85);2083}2084style_flat_button_pressed->set_bg_color(flat_pressed_color);20852086p_theme->set_stylebox(CoreStringName(normal), SceneStringName(FlatButton), style_flat_button);2087p_theme->set_stylebox(SceneStringName(hover), SceneStringName(FlatButton), style_flat_button_hover);2088p_theme->set_stylebox(SceneStringName(pressed), SceneStringName(FlatButton), style_flat_button_pressed);2089p_theme->set_stylebox("disabled", SceneStringName(FlatButton), style_flat_button);20902091p_theme->set_stylebox(CoreStringName(normal), "FlatMenuButton", style_flat_button);2092p_theme->set_stylebox(SceneStringName(hover), "FlatMenuButton", style_flat_button_hover);2093p_theme->set_stylebox(SceneStringName(pressed), "FlatMenuButton", style_flat_button_pressed);2094p_theme->set_stylebox("disabled", "FlatMenuButton", style_flat_button);20952096// Variation for Editor Log filter buttons.20972098p_theme->set_type_variation("EditorLogFilterButton", "Button");2099// When pressed, don't tint the icons with the accent color, just leave them normal.2100p_theme->set_color("icon_pressed_color", "EditorLogFilterButton", p_config.icon_normal_color);2101// When unpressed, dim the icons.2102Color icon_normal_color = Color(p_config.icon_normal_color, (p_config.dark_theme ? 0.4 : 0.8));2103p_theme->set_color("icon_normal_color", "EditorLogFilterButton", icon_normal_color);2104Color icon_hover_color = p_config.icon_normal_color * (p_config.dark_theme ? 1.15 : 1.0);2105icon_hover_color.a = 1.0;2106p_theme->set_color("icon_hover_color", "EditorLogFilterButton", icon_hover_color);2107p_theme->set_color("icon_hover_pressed_color", "EditorLogFilterButton", icon_hover_color);21082109// When pressed, add a small bottom border to the buttons to better show their active state,2110// similar to active tabs.2111Ref<StyleBoxFlat> editor_log_button_pressed = style_flat_button_pressed->duplicate();2112editor_log_button_pressed->set_border_width(SIDE_BOTTOM, 2 * EDSCALE);2113editor_log_button_pressed->set_border_color(p_config.accent_color);2114if (!p_config.dark_theme) {2115editor_log_button_pressed->set_bg_color(flat_pressed_color.lightened(0.5));2116}2117p_theme->set_stylebox(CoreStringName(normal), "EditorLogFilterButton", style_flat_button);2118p_theme->set_stylebox(SceneStringName(hover), "EditorLogFilterButton", style_flat_button_hover);2119p_theme->set_stylebox(SceneStringName(pressed), "EditorLogFilterButton", editor_log_button_pressed);2120}21212122// Buttons styles that stand out against the panel background (e.g. AssetLib).2123{2124p_theme->set_type_variation("PanelBackgroundButton", "Button");21252126Ref<StyleBoxFlat> panel_button_style = p_config.button_style->duplicate();2127panel_button_style->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.08));21282129Ref<StyleBoxFlat> panel_button_style_hover = p_config.button_style_hover->duplicate();2130panel_button_style_hover->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.16));21312132Ref<StyleBoxFlat> panel_button_style_pressed = p_config.button_style_pressed->duplicate();2133panel_button_style_pressed->set_bg_color(p_config.base_color.lerp(p_config.mono_color, 0.20));21342135Ref<StyleBoxFlat> panel_button_style_disabled = p_config.button_style_disabled->duplicate();2136panel_button_style_disabled->set_bg_color(p_config.disabled_bg_color);21372138p_theme->set_stylebox(CoreStringName(normal), "PanelBackgroundButton", panel_button_style);2139p_theme->set_stylebox(SceneStringName(hover), "PanelBackgroundButton", panel_button_style_hover);2140p_theme->set_stylebox(SceneStringName(pressed), "PanelBackgroundButton", panel_button_style_pressed);2141p_theme->set_stylebox("disabled", "PanelBackgroundButton", panel_button_style_disabled);2142}21432144// Top bar selectors.2145{2146p_theme->set_type_variation("TopBarOptionButton", "OptionButton");2147p_theme->set_font(SceneStringName(font), "TopBarOptionButton", p_theme->get_font(SNAME("bold"), EditorStringName(EditorFonts)));2148p_theme->set_font_size(SceneStringName(font_size), "TopBarOptionButton", p_theme->get_font_size(SNAME("bold_size"), EditorStringName(EditorFonts)));2149}21502151// Complex editor windows.2152{2153Ref<StyleBoxFlat> style_complex_window = p_config.window_style->duplicate();2154style_complex_window->set_bg_color(p_config.dark_color_2);2155style_complex_window->set_border_color(p_config.dark_color_2);2156p_theme->set_stylebox(SceneStringName(panel), "EditorSettingsDialog", style_complex_window);2157p_theme->set_stylebox(SceneStringName(panel), "ProjectSettingsEditor", style_complex_window);2158p_theme->set_stylebox(SceneStringName(panel), "EditorAbout", style_complex_window);2159}21602161// InspectorActionButton.2162{2163p_theme->set_type_variation("InspectorActionButton", "Button");21642165const float action_extra_margin = 32 * EDSCALE;2166p_theme->set_constant("h_separation", "InspectorActionButton", action_extra_margin);21672168Color color_inspector_action = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);2169color_inspector_action.a = 0.5;2170Ref<StyleBoxFlat> style_inspector_action = p_config.button_style->duplicate();2171style_inspector_action->set_bg_color(color_inspector_action);2172style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);2173p_theme->set_stylebox(CoreStringName(normal), "InspectorActionButton", style_inspector_action);21742175style_inspector_action = p_config.button_style->duplicate();2176style_inspector_action->set_bg_color(color_inspector_action);2177style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);2178p_theme->set_stylebox("normal_mirrored", "InspectorActionButton", style_inspector_action);21792180style_inspector_action = p_config.button_style_hover->duplicate();2181style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);2182p_theme->set_stylebox(SceneStringName(hover), "InspectorActionButton", style_inspector_action);21832184style_inspector_action = p_config.button_style_hover->duplicate();2185style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);2186p_theme->set_stylebox("hover_mirrored", "InspectorActionButton", style_inspector_action);21872188style_inspector_action = p_config.button_style_pressed->duplicate();2189style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);2190p_theme->set_stylebox(SceneStringName(pressed), "InspectorActionButton", style_inspector_action);21912192style_inspector_action = p_config.button_style_pressed->duplicate();2193style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);2194p_theme->set_stylebox("pressed_mirrored", "InspectorActionButton", style_inspector_action);21952196style_inspector_action = p_config.button_style_disabled->duplicate();2197style_inspector_action->set_content_margin(SIDE_RIGHT, action_extra_margin);2198p_theme->set_stylebox("disabled", "InspectorActionButton", style_inspector_action);21992200style_inspector_action = p_config.button_style_disabled->duplicate();2201style_inspector_action->set_content_margin(SIDE_LEFT, action_extra_margin);2202p_theme->set_stylebox("disabled_mirrored", "InspectorActionButton", style_inspector_action);2203}22042205// Buttons in material previews.2206{2207const Color dim_light_color = p_config.icon_normal_color.darkened(0.24);2208const Color dim_light_highlighted_color = p_config.icon_normal_color.darkened(0.18);2209Ref<StyleBox> sb_empty_borderless = make_empty_stylebox();22102211p_theme->set_type_variation("PreviewLightButton", "Button");2212// When pressed, don't use the accent color tint. When unpressed, dim the icon.2213p_theme->set_color("icon_normal_color", "PreviewLightButton", dim_light_color);2214p_theme->set_color("icon_focus_color", "PreviewLightButton", dim_light_color);2215p_theme->set_color("icon_pressed_color", "PreviewLightButton", p_config.icon_normal_color);2216p_theme->set_color("icon_hover_pressed_color", "PreviewLightButton", p_config.icon_normal_color);2217// Unpressed icon is dim, so use a dim highlight.2218p_theme->set_color("icon_hover_color", "PreviewLightButton", dim_light_highlighted_color);22192220p_theme->set_stylebox(CoreStringName(normal), "PreviewLightButton", sb_empty_borderless);2221p_theme->set_stylebox(SceneStringName(hover), "PreviewLightButton", sb_empty_borderless);2222p_theme->set_stylebox("focus", "PreviewLightButton", sb_empty_borderless);2223p_theme->set_stylebox(SceneStringName(pressed), "PreviewLightButton", sb_empty_borderless);2224}22252226// TabContainerOdd variation.2227{2228// Can be used on tabs against the base color background (e.g. nested tabs).2229p_theme->set_type_variation("TabContainerOdd", "TabContainer");22302231Ref<StyleBoxFlat> style_tab_selected_odd = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->duplicate();2232style_tab_selected_odd->set_bg_color(p_config.disabled_bg_color);2233p_theme->set_stylebox("tab_selected", "TabContainerOdd", style_tab_selected_odd);22342235Ref<StyleBoxFlat> style_content_panel_odd = p_config.content_panel_style->duplicate();2236style_content_panel_odd->set_bg_color(p_config.disabled_bg_color);2237p_theme->set_stylebox(SceneStringName(panel), "TabContainerOdd", style_content_panel_odd);2238}22392240// EditorValidationPanel.2241p_theme->set_stylebox(SceneStringName(panel), "EditorValidationPanel", p_config.tree_panel_style);22422243// Secondary trees and item lists.2244p_theme->set_type_variation("TreeSecondary", "Tree");2245p_theme->set_type_variation("ItemListSecondary", "ItemList");2246}22472248// Editor inspector.2249{2250// Panel.2251Ref<StyleBoxFlat> editor_inspector_panel = p_config.tree_panel_style->duplicate();2252editor_inspector_panel->set_border_width_all(0);2253editor_inspector_panel->set_content_margin_all(0);2254p_theme->set_stylebox(SceneStringName(panel), "EditorInspector", editor_inspector_panel);22552256// Vertical separation between inspector categories and sections.2257p_theme->set_constant("v_separation", "EditorInspector", 0);22582259// EditorProperty.22602261Ref<StyleBoxFlat> style_property_bg = p_config.base_style->duplicate();2262style_property_bg->set_bg_color(p_config.highlight_color);2263style_property_bg->set_border_width_all(0);22642265Ref<StyleBoxFlat> style_property_child_bg = p_config.base_style->duplicate();2266style_property_child_bg->set_bg_color(p_config.dark_color_2);2267style_property_child_bg->set_border_width_all(0);22682269p_theme->set_stylebox("bg", "EditorProperty", memnew(StyleBoxEmpty));2270p_theme->set_stylebox("bg_selected", "EditorProperty", style_property_bg);2271p_theme->set_stylebox("child_bg", "EditorProperty", style_property_child_bg);2272p_theme->set_constant("font_offset", "EditorProperty", 8 * EDSCALE);2273p_theme->set_constant("v_separation", "EditorProperty", p_config.increased_margin * EDSCALE);22742275const Color property_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5);2276const Color readonly_color = property_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.25);2277const Color readonly_warning_color = p_config.error_color.lerp(p_config.dark_theme ? Color(0, 0, 0) : Color(1, 1, 1), 0.25);22782279p_theme->set_color("property_color", "EditorProperty", property_color);2280p_theme->set_color("readonly_color", "EditorProperty", readonly_color);2281p_theme->set_color("warning_color", "EditorProperty", p_config.warning_color);2282p_theme->set_color("readonly_warning_color", "EditorProperty", readonly_warning_color);22832284Ref<StyleBoxFlat> style_property_group_note = p_config.base_style->duplicate();2285Color property_group_note_color = p_config.accent_color;2286property_group_note_color.a = 0.1;2287style_property_group_note->set_bg_color(property_group_note_color);2288p_theme->set_stylebox("bg_group_note", "EditorProperty", style_property_group_note);22892290// EditorInspectorSection.22912292Color inspector_section_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.35);2293p_theme->set_color(SceneStringName(font_color), "EditorInspectorSection", inspector_section_color);22942295Color inspector_indent_color = p_config.accent_color;2296inspector_indent_color.a = 0.2;2297Ref<StyleBoxFlat> inspector_indent_style = make_flat_stylebox(inspector_indent_color, 2.0 * EDSCALE, 0, 2.0 * EDSCALE, 0);2298p_theme->set_stylebox("indent_box", "EditorInspectorSection", inspector_indent_style);2299p_theme->set_constant("indent_size", "EditorInspectorSection", 6.0 * EDSCALE);2300p_theme->set_constant("h_separation", "EditorInspectorSection", 2.0 * EDSCALE);23012302Color prop_category_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.12);2303Color prop_section_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.09);2304Color prop_subsection_color = p_config.dark_color_1.lerp(p_config.mono_color, 0.06);23052306p_theme->set_color("prop_category", EditorStringName(Editor), prop_category_color);2307p_theme->set_color("prop_section", EditorStringName(Editor), prop_section_color);2308p_theme->set_color("prop_subsection", EditorStringName(Editor), prop_subsection_color);2309#ifndef DISABLE_DEPRECATED // Used before 4.3.2310p_theme->set_color("property_color", EditorStringName(Editor), prop_category_color);2311#endif23122313// EditorInspectorCategory.23142315Ref<StyleBoxFlat> category_bg = p_config.base_style->duplicate();2316category_bg->set_bg_color(prop_category_color);2317category_bg->set_border_color(prop_category_color);2318category_bg->set_content_margin_all(0);2319p_theme->set_stylebox("bg", "EditorInspectorCategory", category_bg);23202321p_theme->set_constant("inspector_margin", EditorStringName(Editor), 12 * EDSCALE);23222323// Colored EditorProperty.2324for (int i = 0; i < 16; i++) {2325Color si_base_color = p_config.accent_color;23262327float hue_rotate = (i * 2 % 16) / 16.0;2328si_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());2329si_base_color = p_config.accent_color.lerp(si_base_color, p_config.subresource_hue_tint);23302331// Sub-inspector background.2332Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();2333sub_inspector_bg->set_bg_color(p_config.dark_color_1.lerp(si_base_color, 0.08));2334sub_inspector_bg->set_border_width_all(2 * EDSCALE);2335sub_inspector_bg->set_border_color(si_base_color * Color(0.7, 0.7, 0.7, 0.8));2336sub_inspector_bg->set_content_margin_all(4 * EDSCALE);2337sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);2338sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);23392340p_theme->set_stylebox("sub_inspector_bg" + itos(i + 1), EditorStringName(EditorStyles), sub_inspector_bg);23412342// EditorProperty background while it has a sub-inspector open.2343Ref<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);2344bg_color->set_anti_aliased(false);2345bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);2346bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);23472348p_theme->set_stylebox("sub_inspector_property_bg" + itos(i + 1), EditorStringName(EditorStyles), bg_color);23492350// Dictionary editor add item.2351// Expand to the left and right by 4px to compensate for the dictionary editor margins.23522353Color style_dictionary_bg_color = p_config.dark_color_3.lerp(si_base_color, 0.08);2354Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(style_dictionary_bg_color, 0, 4, 0, 4, p_config.corner_radius);2355style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);2356style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);2357p_theme->set_stylebox("DictionaryAddItem" + itos(i + 1), EditorStringName(EditorStyles), style_dictionary_add_item);2358}2359Color si_base_color = p_config.accent_color;23602361// Sub-inspector background.2362Ref<StyleBoxFlat> sub_inspector_bg = p_config.base_style->duplicate();2363sub_inspector_bg->set_bg_color(Color(1, 1, 1, 0));2364sub_inspector_bg->set_border_width_all(2 * EDSCALE);2365sub_inspector_bg->set_border_color(p_config.dark_color_1.lerp(si_base_color, 0.15));2366sub_inspector_bg->set_content_margin_all(4 * EDSCALE);2367sub_inspector_bg->set_corner_radius(CORNER_TOP_LEFT, 0);2368sub_inspector_bg->set_corner_radius(CORNER_TOP_RIGHT, 0);23692370p_theme->set_stylebox("sub_inspector_bg0", EditorStringName(EditorStyles), sub_inspector_bg);23712372// Sub-inspector background no border.23732374Ref<StyleBoxFlat> sub_inspector_bg_no_border = p_config.base_style->duplicate();2375sub_inspector_bg_no_border->set_content_margin_all(2 * EDSCALE);2376sub_inspector_bg_no_border->set_bg_color(p_config.dark_color_2.lerp(p_config.dark_color_3, 0.15));2377p_theme->set_stylebox("sub_inspector_bg_no_border", EditorStringName(EditorStyles), sub_inspector_bg_no_border);23782379// EditorProperty background while it has a sub-inspector open.2380Ref<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);2381bg_color->set_anti_aliased(false);2382bg_color->set_corner_radius(CORNER_BOTTOM_LEFT, 0);2383bg_color->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);23842385p_theme->set_stylebox("sub_inspector_property_bg0", EditorStringName(EditorStyles), bg_color);23862387p_theme->set_color("sub_inspector_property_color", EditorStringName(EditorStyles), p_config.dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1));23882389// Dictionary editor.23902391// Expand to the left and right by 4px to compensate for the dictionary editor margins.2392Ref<StyleBoxFlat> style_dictionary_add_item = make_flat_stylebox(prop_subsection_color, 0, 4, 0, 4, p_config.corner_radius);2393style_dictionary_add_item->set_expand_margin(SIDE_LEFT, 2 * EDSCALE);2394style_dictionary_add_item->set_expand_margin(SIDE_RIGHT, 2 * EDSCALE);2395p_theme->set_stylebox("DictionaryAddItem0", EditorStringName(EditorStyles), style_dictionary_add_item);2396}23972398// Animation Editor.2399{2400// Timeline general.2401p_theme->set_constant("timeline_v_separation", "AnimationTrackEditor", 0);2402p_theme->set_constant("track_v_separation", "AnimationTrackEditor", 0);24032404// AnimationTimelineEdit.2405// "primary" is used for integer timeline values, "secondary" for decimals.24062407Ref<StyleBoxFlat> style_time_unavailable = make_flat_stylebox(p_config.dark_color_2, 0, 0, 0, 0, 0);2408Ref<StyleBoxFlat> style_time_available = make_flat_stylebox(p_config.font_color * Color(1, 1, 1, 0.2), 0, 0, 0, 0, 0);24092410p_theme->set_stylebox("time_unavailable", "AnimationTimelineEdit", style_time_unavailable);2411p_theme->set_stylebox("time_available", "AnimationTimelineEdit", style_time_available);24122413p_theme->set_color("v_line_primary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));2414p_theme->set_color("v_line_secondary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));2415p_theme->set_color("h_line_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.2));2416p_theme->set_color("font_primary_color", "AnimationTimelineEdit", p_config.font_color);2417p_theme->set_color("font_secondary_color", "AnimationTimelineEdit", p_config.font_color * Color(1, 1, 1, 0.5));24182419p_theme->set_constant("v_line_primary_margin", "AnimationTimelineEdit", 0);2420p_theme->set_constant("v_line_secondary_margin", "AnimationTimelineEdit", 0);2421p_theme->set_constant("v_line_primary_width", "AnimationTimelineEdit", 1 * EDSCALE);2422p_theme->set_constant("v_line_secondary_width", "AnimationTimelineEdit", 1 * EDSCALE);2423p_theme->set_constant("text_primary_margin", "AnimationTimelineEdit", 3 * EDSCALE);2424p_theme->set_constant("text_secondary_margin", "AnimationTimelineEdit", 3 * EDSCALE);24252426// AnimationTrackEdit.24272428Ref<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);2429Ref<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);24302431p_theme->set_stylebox("odd", "AnimationTrackEdit", style_animation_track_odd);2432p_theme->set_stylebox(SceneStringName(hover), "AnimationTrackEdit", style_animation_track_hover);2433p_theme->set_stylebox("focus", "AnimationTrackEdit", p_config.button_style_focus);24342435p_theme->set_color("h_line_color", "AnimationTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));24362437p_theme->set_constant("h_separation", "AnimationTrackEdit", (p_config.increased_margin + 2) * EDSCALE);2438p_theme->set_constant("outer_margin", "AnimationTrackEdit", p_config.increased_margin * 6 * EDSCALE);24392440// AnimationTrackEditGroup.24412442Ref<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);24432444p_theme->set_stylebox("header", "AnimationTrackEditGroup", style_animation_track_header);24452446p_theme->set_color("h_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));2447p_theme->set_color("v_line_color", "AnimationTrackEditGroup", p_config.font_color * Color(1, 1, 1, 0.2));24482449p_theme->set_constant("h_separation", "AnimationTrackEditGroup", (p_config.increased_margin + 2) * EDSCALE);2450p_theme->set_constant("v_separation", "AnimationTrackEditGroup", 0);24512452// AnimationBezierTrackEdit.24532454p_theme->set_color("focus_color", "AnimationBezierTrackEdit", p_config.accent_color * Color(1, 1, 1, 0.7));2455p_theme->set_color("track_focus_color", "AnimationBezierTrackEdit", p_config.accent_color * Color(1, 1, 1, 0.5));2456p_theme->set_color("h_line_color", "AnimationBezierTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));2457p_theme->set_color("v_line_color", "AnimationBezierTrackEdit", p_config.font_color * Color(1, 1, 1, 0.2));24582459p_theme->set_constant("h_separation", "AnimationBezierTrackEdit", (p_config.increased_margin + 2) * EDSCALE);2460p_theme->set_constant("v_separation", "AnimationBezierTrackEdit", p_config.forced_even_separation * EDSCALE);2461}24622463// Editor help.2464{2465Ref<StyleBoxFlat> style_editor_help = p_config.base_style->duplicate();2466style_editor_help->set_bg_color(p_config.dark_color_2);2467style_editor_help->set_border_color(p_config.dark_color_3);2468p_theme->set_stylebox("background", "EditorHelp", style_editor_help);24692470const Color kbd_color = p_config.font_color.lerp(Color(0.5, 0.5, 0.5), 0.5);24712472p_theme->set_color("title_color", "EditorHelp", p_config.accent_color);2473p_theme->set_color("headline_color", "EditorHelp", p_config.mono_color);2474p_theme->set_color("text_color", "EditorHelp", p_config.font_color);2475p_theme->set_color("comment_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));2476p_theme->set_color("symbol_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));2477p_theme->set_color("value_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.6));2478p_theme->set_color("qualifier_color", "EditorHelp", p_config.font_color * Color(1, 1, 1, 0.8));2479p_theme->set_color("type_color", "EditorHelp", p_config.accent_color.lerp(p_config.font_color, 0.5));2480p_theme->set_color("override_color", "EditorHelp", p_config.warning_color);2481p_theme->set_color("selection_color", "EditorHelp", p_config.selection_color);2482p_theme->set_color("link_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.8));2483p_theme->set_color("code_color", "EditorHelp", p_config.accent_color.lerp(p_config.mono_color, 0.6));2484p_theme->set_color("kbd_color", "EditorHelp", p_config.accent_color.lerp(kbd_color, 0.6));2485p_theme->set_color("code_bg_color", "EditorHelp", p_config.dark_color_3);2486p_theme->set_color("kbd_bg_color", "EditorHelp", p_config.dark_color_1);2487p_theme->set_color("param_bg_color", "EditorHelp", p_config.dark_color_1);2488p_theme->set_constant(SceneStringName(line_separation), "EditorHelp", Math::round(6 * EDSCALE));2489p_theme->set_constant("table_h_separation", "EditorHelp", 16 * EDSCALE);2490p_theme->set_constant("table_v_separation", "EditorHelp", 6 * EDSCALE);2491p_theme->set_constant("text_highlight_h_padding", "EditorHelp", 1 * EDSCALE);2492p_theme->set_constant("text_highlight_v_padding", "EditorHelp", 2 * EDSCALE);2493}24942495// EditorHelpBitTitle.2496{2497Ref<StyleBoxFlat> style = p_config.tree_panel_style->duplicate();2498style->set_bg_color(p_config.dark_theme ? style->get_bg_color().lightened(0.04) : style->get_bg_color().darkened(0.04));2499style->set_border_color(p_config.dark_theme ? style->get_border_color().lightened(0.04) : style->get_border_color().darkened(0.04));2500style->set_corner_radius(CORNER_BOTTOM_LEFT, 0);2501style->set_corner_radius(CORNER_BOTTOM_RIGHT, 0);25022503p_theme->set_type_variation("EditorHelpBitTitle", "RichTextLabel");2504p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitTitle", style);2505}25062507// EditorHelpBitContent.2508{2509Ref<StyleBoxFlat> style = p_config.tree_panel_style->duplicate();2510style->set_corner_radius(CORNER_TOP_LEFT, 0);2511style->set_corner_radius(CORNER_TOP_RIGHT, 0);25122513p_theme->set_type_variation("EditorHelpBitContent", "RichTextLabel");2514p_theme->set_stylebox(CoreStringName(normal), "EditorHelpBitContent", style);2515}25162517// Asset Library.2518p_theme->set_stylebox("bg", "AssetLib", p_config.base_empty_style);2519p_theme->set_stylebox(SceneStringName(panel), "AssetLib", p_config.content_panel_style);2520p_theme->set_color("status_color", "AssetLib", Color(0.5, 0.5, 0.5)); // FIXME: Use a defined color instead.2521p_theme->set_icon("dismiss", "AssetLib", p_theme->get_icon(SNAME("Close"), EditorStringName(EditorIcons)));25222523// Debugger.2524{2525Ref<StyleBoxFlat> debugger_panel_style = p_config.content_panel_style->duplicate();2526debugger_panel_style->set_border_width(SIDE_BOTTOM, 0);2527p_theme->set_stylebox("DebuggerPanel", EditorStringName(EditorStyles), debugger_panel_style);25282529// This pattern of get_font()->get_height(get_font_size()) is used quite a lot and is very verbose.2530// FIXME: Introduce Theme::get_font_height() / Control::get_theme_font_height() / Window::get_theme_font_height().2531const int offset_i1 = p_theme->get_font(SNAME("tab_selected"), SNAME("TabContainer"))->get_height(p_theme->get_font_size(SNAME("tab_selected"), SNAME("TabContainer")));2532const int offset_i2 = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainer"))->get_minimum_size().height;2533const int offset_i3 = p_theme->get_stylebox(SceneStringName(panel), SNAME("TabContainer"))->get_content_margin(SIDE_TOP);2534const int invisible_top_offset = offset_i1 + offset_i2 + offset_i3;25352536Ref<StyleBoxFlat> invisible_top_panel_style = p_config.content_panel_style->duplicate();2537invisible_top_panel_style->set_expand_margin(SIDE_TOP, -invisible_top_offset);2538invisible_top_panel_style->set_content_margin(SIDE_TOP, 0);2539p_theme->set_stylebox("BottomPanelDebuggerOverride", EditorStringName(EditorStyles), invisible_top_panel_style);2540}25412542// Resource and node editors.2543{2544// TextureRegion editor.2545Ref<StyleBoxFlat> style_texture_region_bg = p_config.tree_panel_style->duplicate();2546style_texture_region_bg->set_content_margin_all(0);2547p_theme->set_stylebox("TextureRegionPreviewBG", EditorStringName(EditorStyles), style_texture_region_bg);2548p_theme->set_stylebox("TextureRegionPreviewFG", EditorStringName(EditorStyles), make_empty_stylebox(0, 0, 0, 0));25492550// Theme editor.2551{2552p_theme->set_color("preview_picker_overlay_color", "ThemeEditor", Color(0.1, 0.1, 0.1, 0.25));25532554Color theme_preview_picker_bg_color = p_config.accent_color;2555theme_preview_picker_bg_color.a = 0.2;2556Ref<StyleBoxFlat> theme_preview_picker_sb = make_flat_stylebox(theme_preview_picker_bg_color, 0, 0, 0, 0);2557theme_preview_picker_sb->set_border_color(p_config.accent_color);2558theme_preview_picker_sb->set_border_width_all(1.0 * EDSCALE);2559p_theme->set_stylebox("preview_picker_overlay", "ThemeEditor", theme_preview_picker_sb);25602561Color theme_preview_picker_label_bg_color = p_config.accent_color;2562theme_preview_picker_label_bg_color.set_v(0.5);2563Ref<StyleBoxFlat> theme_preview_picker_label_sb = make_flat_stylebox(theme_preview_picker_label_bg_color, 4.0, 1.0, 4.0, 3.0);2564p_theme->set_stylebox("preview_picker_label", "ThemeEditor", theme_preview_picker_label_sb);25652566Ref<StyleBoxFlat> style_theme_preview_tab = p_theme->get_stylebox(SNAME("tab_selected"), SNAME("TabContainerOdd"))->duplicate();2567style_theme_preview_tab->set_expand_margin(SIDE_BOTTOM, 5 * EDSCALE);2568p_theme->set_stylebox("ThemeEditorPreviewFG", EditorStringName(EditorStyles), style_theme_preview_tab);25692570Ref<StyleBoxFlat> style_theme_preview_bg_tab = p_theme->get_stylebox(SNAME("tab_unselected"), SNAME("TabContainer"))->duplicate();2571style_theme_preview_bg_tab->set_expand_margin(SIDE_BOTTOM, 2 * EDSCALE);2572p_theme->set_stylebox("ThemeEditorPreviewBG", EditorStringName(EditorStyles), style_theme_preview_bg_tab);2573}25742575// VisualShader editor.2576p_theme->set_stylebox("label_style", "VShaderEditor", make_empty_stylebox(4, 6, 4, 6));25772578// StateMachine graph.2579{2580p_theme->set_stylebox(SceneStringName(panel), "GraphStateMachine", p_config.tree_panel_style);2581p_theme->set_stylebox("error_panel", "GraphStateMachine", p_config.tree_panel_style);2582p_theme->set_color("error_color", "GraphStateMachine", p_config.error_color);25832584const int sm_margin_side = 10 * EDSCALE;2585const int sm_margin_bottom = 2;2586const 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);25872588Ref<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);2589sm_node_style->set_border_width_all(p_config.border_width);2590sm_node_style->set_border_color(sm_bg_color);25912592Ref<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);2593sm_node_selected_style->set_border_width_all(2 * EDSCALE + p_config.border_width);2594sm_node_selected_style->set_border_color(p_config.accent_color * Color(1, 1, 1, 0.9));2595sm_node_selected_style->set_shadow_size(8 * EDSCALE);2596sm_node_selected_style->set_shadow_color(p_config.shadow_color);25972598Ref<StyleBoxFlat> sm_node_playing_style = sm_node_selected_style->duplicate();2599sm_node_playing_style->set_border_color(p_config.warning_color);2600sm_node_playing_style->set_shadow_color(p_config.warning_color * Color(1, 1, 1, 0.2));2601sm_node_playing_style->set_draw_center(false);26022603p_theme->set_stylebox("node_frame", "GraphStateMachine", sm_node_style);2604p_theme->set_stylebox("node_frame_selected", "GraphStateMachine", sm_node_selected_style);2605p_theme->set_stylebox("node_frame_playing", "GraphStateMachine", sm_node_playing_style);26062607Ref<StyleBoxFlat> sm_node_start_style = sm_node_style->duplicate();2608sm_node_start_style->set_border_width_all(1 * EDSCALE);2609sm_node_start_style->set_border_color(p_config.success_color.lightened(0.24));2610p_theme->set_stylebox("node_frame_start", "GraphStateMachine", sm_node_start_style);26112612Ref<StyleBoxFlat> sm_node_end_style = sm_node_style->duplicate();2613sm_node_end_style->set_border_width_all(1 * EDSCALE);2614sm_node_end_style->set_border_color(p_config.error_color);2615p_theme->set_stylebox("node_frame_end", "GraphStateMachine", sm_node_end_style);26162617p_theme->set_font("node_title_font", "GraphStateMachine", p_theme->get_font(SceneStringName(font), SNAME("Label")));2618p_theme->set_font_size("node_title_font_size", "GraphStateMachine", p_theme->get_font_size(SceneStringName(font_size), SNAME("Label")));2619p_theme->set_color("node_title_font_color", "GraphStateMachine", p_config.font_color);26202621p_theme->set_color("transition_color", "GraphStateMachine", p_config.font_color);2622p_theme->set_color("transition_disabled_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.2));2623p_theme->set_color("transition_icon_color", "GraphStateMachine", Color(1, 1, 1));2624p_theme->set_color("transition_icon_disabled_color", "GraphStateMachine", Color(1, 1, 1, 0.2));2625p_theme->set_color("highlight_color", "GraphStateMachine", p_config.accent_color);2626p_theme->set_color("highlight_disabled_color", "GraphStateMachine", p_config.accent_color * Color(1, 1, 1, 0.6));2627p_theme->set_color("focus_color", "GraphStateMachine", p_config.accent_color);2628p_theme->set_color("guideline_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3));26292630p_theme->set_color("playback_color", "GraphStateMachine", p_config.font_color);2631p_theme->set_color("playback_background_color", "GraphStateMachine", p_config.font_color * Color(1, 1, 1, 0.3));2632}2633}2634}26352636void _load_text_editor_theme() {2637EditorSettings *settings = EditorSettings::get_singleton();2638const String theme_name = settings->get_setting("text_editor/theme/color_theme");26392640ERR_FAIL_COND(EditorSettings::is_default_text_editor_theme(theme_name.get_file().to_lower()));26412642const String theme_path = EditorPaths::get_singleton()->get_text_editor_themes_dir().path_join(theme_name + ".tet");26432644Ref<ConfigFile> cf;2645cf.instantiate();2646Error err = cf->load(theme_path);2647ERR_FAIL_COND_MSG(err != OK, vformat("Failed to load text editor theme file '%s': %s", theme_name, error_names[err]));26482649const PackedStringArray keys = cf->get_section_keys("color_theme");26502651for (const String &key : keys) {2652const String setting_key = "text_editor/theme/highlighting/" + key;2653// Don't load if it's not an actual setting, or if it isn't a color setting.2654if (!settings->has_setting(setting_key) || !key.contains("color")) {2655continue;2656}2657const String val = cf->get_value("color_theme", key);2658// Make sure it is actually a color.2659if (val.is_valid_html_color()) {2660const Color color_value = Color::html(val);2661// Change manually to prevent settings_changed spam.2662settings->set_initial_value(setting_key, color_value);2663settings->set_manually(setting_key, color_value);2664}2665}2666// If it doesn't load a setting just use what is currently loaded.2667}26682669void EditorThemeManager::_populate_text_editor_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {2670const String text_editor_color_theme = EDITOR_GET("text_editor/theme/color_theme");2671const bool is_default_theme = text_editor_color_theme == "Default";2672const bool is_godot2_theme = text_editor_color_theme == "Godot 2";2673const bool is_custom_theme = text_editor_color_theme == "Custom";2674if (is_default_theme || is_godot2_theme || is_custom_theme) {2675HashMap<StringName, Color> colors;2676if (is_default_theme || is_custom_theme) {2677// Adaptive colors for comments and elements with lower relevance.2678const Color dim_color = Color(p_config.font_color, 0.5);2679const float mono_value = p_config.mono_color.r;2680const Color alpha1 = Color(mono_value, mono_value, mono_value, 0.07);2681const Color alpha2 = Color(mono_value, mono_value, mono_value, 0.14);2682const Color alpha3 = Color(mono_value, mono_value, mono_value, 0.27);26832684// Syntax highlight token colors.2685colors["text_editor/theme/highlighting/symbol_color"] = p_config.dark_theme ? Color(0.67, 0.79, 1) : Color(0, 0, 0.61);2686colors["text_editor/theme/highlighting/keyword_color"] = p_config.dark_theme ? Color(1.0, 0.44, 0.52) : Color(0.9, 0.135, 0.51);2687colors["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);2688colors["text_editor/theme/highlighting/base_type_color"] = p_config.dark_theme ? Color(0.26, 1.0, 0.76) : Color(0, 0.6, 0.2);2689colors["text_editor/theme/highlighting/engine_type_color"] = p_config.dark_theme ? Color(0.56, 1, 0.86) : Color(0.11, 0.55, 0.4);2690colors["text_editor/theme/highlighting/user_type_color"] = p_config.dark_theme ? Color(0.78, 1, 0.93) : Color(0.18, 0.45, 0.4);2691colors["text_editor/theme/highlighting/comment_color"] = p_config.dark_theme ? dim_color : Color(0.08, 0.08, 0.08, 0.5);2692colors["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);2693colors["text_editor/theme/highlighting/string_color"] = p_config.dark_theme ? Color(1, 0.93, 0.63) : Color(0.6, 0.42, 0);26942695// Use the brightest background color on a light theme (which generally uses a negative contrast rate).2696colors["text_editor/theme/highlighting/background_color"] = p_config.dark_theme ? p_config.dark_color_2 : p_config.dark_color_3;2697colors["text_editor/theme/highlighting/completion_background_color"] = p_config.dark_theme ? p_config.base_color : p_config.dark_color_2;2698colors["text_editor/theme/highlighting/completion_selected_color"] = alpha1;2699colors["text_editor/theme/highlighting/completion_existing_color"] = alpha2;2700// Same opacity as the scroll grabber editor icon.2701colors["text_editor/theme/highlighting/completion_scroll_color"] = Color(mono_value, mono_value, mono_value, 0.29);2702colors["text_editor/theme/highlighting/completion_scroll_hovered_color"] = Color(mono_value, mono_value, mono_value, 0.4);2703colors["text_editor/theme/highlighting/completion_font_color"] = p_config.font_color;2704colors["text_editor/theme/highlighting/text_color"] = p_config.font_color;2705colors["text_editor/theme/highlighting/line_number_color"] = dim_color;2706colors["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);2707colors["text_editor/theme/highlighting/caret_color"] = p_config.mono_color;2708colors["text_editor/theme/highlighting/caret_background_color"] = p_config.mono_color.inverted();2709colors["text_editor/theme/highlighting/text_selected_color"] = Color(0, 0, 0, 0);2710colors["text_editor/theme/highlighting/selection_color"] = p_config.selection_color;2711colors["text_editor/theme/highlighting/brace_mismatch_color"] = p_config.dark_theme ? p_config.error_color : Color(1, 0.08, 0, 1);2712colors["text_editor/theme/highlighting/current_line_color"] = alpha1;2713colors["text_editor/theme/highlighting/line_length_guideline_color"] = p_config.dark_theme ? p_config.base_color : p_config.dark_color_2;2714colors["text_editor/theme/highlighting/word_highlighted_color"] = alpha1;2715colors["text_editor/theme/highlighting/number_color"] = p_config.dark_theme ? Color(0.63, 1, 0.88) : Color(0, 0.55, 0.28, 1);2716colors["text_editor/theme/highlighting/function_color"] = p_config.dark_theme ? Color(0.34, 0.7, 1.0) : Color(0, 0.225, 0.9, 1);2717colors["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);2718colors["text_editor/theme/highlighting/mark_color"] = Color(p_config.error_color.r, p_config.error_color.g, p_config.error_color.b, 0.3);2719colors["text_editor/theme/highlighting/warning_color"] = Color(p_config.warning_color.r, p_config.warning_color.g, p_config.warning_color.b, 0.15);2720colors["text_editor/theme/highlighting/bookmark_color"] = Color(0.08, 0.49, 0.98);2721colors["text_editor/theme/highlighting/breakpoint_color"] = p_config.dark_theme ? p_config.error_color : Color(1, 0.27, 0.2, 1);2722colors["text_editor/theme/highlighting/executing_line_color"] = Color(0.98, 0.89, 0.27);2723colors["text_editor/theme/highlighting/code_folding_color"] = alpha3;2724colors["text_editor/theme/highlighting/folded_code_region_color"] = Color(0.68, 0.46, 0.77, 0.2);2725colors["text_editor/theme/highlighting/search_result_color"] = alpha1;2726colors["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);27272728if (p_config.dark_theme) {2729colors["text_editor/theme/highlighting/gdscript/function_definition_color"] = Color(0.4, 0.9, 1.0);2730colors["text_editor/theme/highlighting/gdscript/global_function_color"] = Color(0.64, 0.64, 0.96);2731colors["text_editor/theme/highlighting/gdscript/node_path_color"] = Color(0.72, 0.77, 0.49);2732colors["text_editor/theme/highlighting/gdscript/node_reference_color"] = Color(0.39, 0.76, 0.35);2733colors["text_editor/theme/highlighting/gdscript/annotation_color"] = Color(1.0, 0.7, 0.45);2734colors["text_editor/theme/highlighting/gdscript/string_name_color"] = Color(1.0, 0.76, 0.65);2735colors["text_editor/theme/highlighting/comment_markers/critical_color"] = Color(0.77, 0.35, 0.35);2736colors["text_editor/theme/highlighting/comment_markers/warning_color"] = Color(0.72, 0.61, 0.48);2737colors["text_editor/theme/highlighting/comment_markers/notice_color"] = Color(0.56, 0.67, 0.51);2738} else {2739colors["text_editor/theme/highlighting/gdscript/function_definition_color"] = Color(0, 0.6, 0.6);2740colors["text_editor/theme/highlighting/gdscript/global_function_color"] = Color(0.36, 0.18, 0.72);2741colors["text_editor/theme/highlighting/gdscript/node_path_color"] = Color(0.18, 0.55, 0);2742colors["text_editor/theme/highlighting/gdscript/node_reference_color"] = Color(0.0, 0.5, 0);2743colors["text_editor/theme/highlighting/gdscript/annotation_color"] = Color(0.8, 0.37, 0);2744colors["text_editor/theme/highlighting/gdscript/string_name_color"] = Color(0.8, 0.56, 0.45);2745colors["text_editor/theme/highlighting/comment_markers/critical_color"] = Color(0.8, 0.14, 0.14);2746colors["text_editor/theme/highlighting/comment_markers/warning_color"] = Color(0.75, 0.39, 0.03);2747colors["text_editor/theme/highlighting/comment_markers/notice_color"] = Color(0.24, 0.54, 0.09);2748}2749} else if (is_godot2_theme) {2750colors = EditorSettings::get_godot2_text_editor_theme();2751}2752EditorSettings *settings = EditorSettings::get_singleton();2753for (const KeyValue<StringName, Color> &setting : colors) {2754settings->set_initial_value(setting.key, setting.value);2755if (is_default_theme || is_godot2_theme) {2756settings->set_manually(setting.key, setting.value);2757}2758}2759} else {2760// Custom user theme.2761_load_text_editor_theme();2762}27632764// Now theme is loaded, apply it to CodeEdit.2765p_theme->set_font(SceneStringName(font), "CodeEdit", p_theme->get_font(SNAME("source"), EditorStringName(EditorFonts)));2766p_theme->set_font_size(SceneStringName(font_size), "CodeEdit", p_theme->get_font_size(SNAME("source_size"), EditorStringName(EditorFonts)));27672768/* clang-format off */2769p_theme->set_icon("tab", "CodeEdit", p_theme->get_icon(SNAME("GuiTab"), EditorStringName(EditorIcons)));2770p_theme->set_icon("space", "CodeEdit", p_theme->get_icon(SNAME("GuiSpace"), EditorStringName(EditorIcons)));2771p_theme->set_icon("folded", "CodeEdit", p_theme->get_icon(SNAME("CodeFoldedRightArrow"), EditorStringName(EditorIcons)));2772p_theme->set_icon("can_fold", "CodeEdit", p_theme->get_icon(SNAME("CodeFoldDownArrow"), EditorStringName(EditorIcons)));2773p_theme->set_icon("folded_code_region", "CodeEdit", p_theme->get_icon(SNAME("CodeRegionFoldedRightArrow"), EditorStringName(EditorIcons)));2774p_theme->set_icon("can_fold_code_region", "CodeEdit", p_theme->get_icon(SNAME("CodeRegionFoldDownArrow"), EditorStringName(EditorIcons)));2775p_theme->set_icon("executing_line", "CodeEdit", p_theme->get_icon(SNAME("TextEditorPlay"), EditorStringName(EditorIcons)));2776p_theme->set_icon("breakpoint", "CodeEdit", p_theme->get_icon(SNAME("Breakpoint"), EditorStringName(EditorIcons)));2777/* clang-format on */27782779p_theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing"));27802781const Color background_color = EDITOR_GET("text_editor/theme/highlighting/background_color");2782Ref<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);2783p_theme->set_stylebox(CoreStringName(normal), "CodeEdit", code_edit_stylebox);2784p_theme->set_stylebox("read_only", "CodeEdit", code_edit_stylebox);2785p_theme->set_stylebox("focus", "CodeEdit", memnew(StyleBoxEmpty));27862787p_theme->set_color("background_color", "CodeEdit", Color(0, 0, 0, 0)); // Unset any color, we use a stylebox.27882789/* clang-format off */2790p_theme->set_color("completion_background_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_background_color"));2791p_theme->set_color("completion_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_selected_color"));2792p_theme->set_color("completion_existing_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_existing_color"));2793p_theme->set_color("completion_scroll_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_color"));2794p_theme->set_color("completion_scroll_hovered_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/completion_scroll_hovered_color"));2795p_theme->set_color(SceneStringName(font_color), "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_color"));2796p_theme->set_color("line_number_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_number_color"));2797p_theme->set_color("caret_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/caret_color"));2798p_theme->set_color("font_selected_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/text_selected_color"));2799p_theme->set_color("selection_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/selection_color"));2800p_theme->set_color("brace_mismatch_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/brace_mismatch_color"));2801p_theme->set_color("current_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/current_line_color"));2802p_theme->set_color("line_length_guideline_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/line_length_guideline_color"));2803p_theme->set_color("word_highlighted_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/word_highlighted_color"));2804p_theme->set_color("bookmark_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/bookmark_color"));2805p_theme->set_color("breakpoint_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/breakpoint_color"));2806p_theme->set_color("executing_line_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/executing_line_color"));2807p_theme->set_color("code_folding_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/code_folding_color"));2808p_theme->set_color("folded_code_region_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/folded_code_region_color"));2809p_theme->set_color("search_result_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_color"));2810p_theme->set_color("search_result_border_color", "CodeEdit", EDITOR_GET("text_editor/theme/highlighting/search_result_border_color"));2811/* clang-format on */2812}28132814void EditorThemeManager::_populate_visual_shader_styles(const Ref<EditorTheme> &p_theme, ThemeConfiguration &p_config) {2815EditorSettings *ed_settings = EditorSettings::get_singleton();2816String visual_shader_color_theme = ed_settings->get("editors/visual_editors/color_theme");2817if (visual_shader_color_theme == "Default") {2818// Connection type colors2819ed_settings->set_initial_value("editors/visual_editors/connection_colors/scalar_color", Color(0.55, 0.55, 0.55), true);2820ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector2_color", Color(0.44, 0.43, 0.64), true);2821ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector3_color", Color(0.337, 0.314, 0.71), true);2822ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector4_color", Color(0.7, 0.65, 0.147), true);2823ed_settings->set_initial_value("editors/visual_editors/connection_colors/boolean_color", Color(0.243, 0.612, 0.349), true);2824ed_settings->set_initial_value("editors/visual_editors/connection_colors/transform_color", Color(0.71, 0.357, 0.64), true);2825ed_settings->set_initial_value("editors/visual_editors/connection_colors/sampler_color", Color(0.659, 0.4, 0.137), true);28262827// Node category colors (used for the node headers)2828ed_settings->set_initial_value("editors/visual_editors/category_colors/output_color", Color(0.26, 0.10, 0.15), true);2829ed_settings->set_initial_value("editors/visual_editors/category_colors/color_color", Color(0.5, 0.5, 0.1), true);2830ed_settings->set_initial_value("editors/visual_editors/category_colors/conditional_color", Color(0.208, 0.522, 0.298), true);2831ed_settings->set_initial_value("editors/visual_editors/category_colors/input_color", Color(0.502, 0.2, 0.204), true);2832ed_settings->set_initial_value("editors/visual_editors/category_colors/scalar_color", Color(0.1, 0.5, 0.6), true);2833ed_settings->set_initial_value("editors/visual_editors/category_colors/textures_color", Color(0.5, 0.3, 0.1), true);2834ed_settings->set_initial_value("editors/visual_editors/category_colors/transform_color", Color(0.5, 0.3, 0.5), true);2835ed_settings->set_initial_value("editors/visual_editors/category_colors/utility_color", Color(0.2, 0.2, 0.2), true);2836ed_settings->set_initial_value("editors/visual_editors/category_colors/vector_color", Color(0.2, 0.2, 0.5), true);2837ed_settings->set_initial_value("editors/visual_editors/category_colors/special_color", Color(0.098, 0.361, 0.294), true);2838ed_settings->set_initial_value("editors/visual_editors/category_colors/particle_color", Color(0.12, 0.358, 0.8), true);28392840} else if (visual_shader_color_theme == "Legacy") {2841// Connection type colors2842ed_settings->set_initial_value("editors/visual_editors/connection_colors/scalar_color", Color(0.38, 0.85, 0.96), true);2843ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector2_color", Color(0.74, 0.57, 0.95), true);2844ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector3_color", Color(0.84, 0.49, 0.93), true);2845ed_settings->set_initial_value("editors/visual_editors/connection_colors/vector4_color", Color(1.0, 0.125, 0.95), true);2846ed_settings->set_initial_value("editors/visual_editors/connection_colors/boolean_color", Color(0.55, 0.65, 0.94), true);2847ed_settings->set_initial_value("editors/visual_editors/connection_colors/transform_color", Color(0.96, 0.66, 0.43), true);2848ed_settings->set_initial_value("editors/visual_editors/connection_colors/sampler_color", Color(1.0, 1.0, 0.0), true);28492850// Node category colors (used for the node headers)2851Ref<StyleBoxFlat> gn_panel_style = p_theme->get_stylebox(SceneStringName(panel), "GraphNode");2852Color gn_bg_color = gn_panel_style->get_bg_color();2853ed_settings->set_initial_value("editors/visual_editors/category_colors/output_color", gn_bg_color, true);2854ed_settings->set_initial_value("editors/visual_editors/category_colors/color_color", gn_bg_color, true);2855ed_settings->set_initial_value("editors/visual_editors/category_colors/conditional_color", gn_bg_color, true);2856ed_settings->set_initial_value("editors/visual_editors/category_colors/input_color", gn_bg_color, true);2857ed_settings->set_initial_value("editors/visual_editors/category_colors/scalar_color", gn_bg_color, true);2858ed_settings->set_initial_value("editors/visual_editors/category_colors/textures_color", gn_bg_color, true);2859ed_settings->set_initial_value("editors/visual_editors/category_colors/transform_color", gn_bg_color, true);2860ed_settings->set_initial_value("editors/visual_editors/category_colors/utility_color", gn_bg_color, true);2861ed_settings->set_initial_value("editors/visual_editors/category_colors/vector_color", gn_bg_color, true);2862ed_settings->set_initial_value("editors/visual_editors/category_colors/special_color", gn_bg_color, true);2863ed_settings->set_initial_value("editors/visual_editors/category_colors/particle_color", gn_bg_color, true);2864}2865}28662867void EditorThemeManager::_reset_dirty_flag() {2868outdated_cache_dirty = true;2869}28702871// Public interface for theme generation.28722873Ref<EditorTheme> EditorThemeManager::generate_theme(const Ref<EditorTheme> &p_old_theme) {2874OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Generate Theme");28752876Ref<EditorTheme> theme = _create_base_theme(p_old_theme);28772878OS::get_singleton()->benchmark_begin_measure(get_benchmark_key(), "Merge Custom Theme");28792880const String custom_theme_path = EDITOR_GET("interface/theme/custom_theme");2881if (!custom_theme_path.is_empty()) {2882Ref<Theme> custom_theme = ResourceLoader::load(custom_theme_path);2883if (custom_theme.is_valid()) {2884theme->merge_with(custom_theme);2885}2886}28872888OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Merge Custom Theme");28892890OS::get_singleton()->benchmark_end_measure(get_benchmark_key(), "Generate Theme");2891benchmark_run++;28922893return theme;2894}28952896bool EditorThemeManager::is_generated_theme_outdated() {2897// This list includes settings used by files in the editor/themes folder.2898// Note that the editor scale is purposefully omitted because it cannot be changed2899// without a restart, so there is no point regenerating the theme.29002901if (outdated_cache_dirty) {2902// TODO: We can use this information more intelligently to do partial theme updates and speed things up.2903outdated_cache = EditorSettings::get_singleton()->check_changed_settings_in_group("interface/theme") ||2904EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/font") ||2905EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/main_font") ||2906EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/code_font") ||2907EditorSettings::get_singleton()->check_changed_settings_in_group("editors/visual_editors") ||2908EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/theme") ||2909EditorSettings::get_singleton()->check_changed_settings_in_group("text_editor/help/help") ||2910EditorSettings::get_singleton()->check_changed_settings_in_group("docks/property_editor/subresource_hue_tint") ||2911EditorSettings::get_singleton()->check_changed_settings_in_group("filesystem/file_dialog/thumbnail_size") ||2912EditorSettings::get_singleton()->check_changed_settings_in_group("run/output/font_size");29132914// The outdated flag is relevant at the moment of changing editor settings.2915callable_mp_static(&EditorThemeManager::_reset_dirty_flag).call_deferred();2916outdated_cache_dirty = false;2917}29182919return outdated_cache;2920}29212922bool EditorThemeManager::is_dark_theme() {2923// Light color mode for icons and fonts means it's a dark theme, and vice versa.2924int icon_font_color_setting = EDITOR_GET("interface/theme/icon_and_font_color");29252926if (icon_font_color_setting == ColorMode::AUTO_COLOR) {2927Color base_color = EDITOR_GET("interface/theme/base_color");2928return base_color.get_luminance() < 0.5;2929}29302931return icon_font_color_setting == ColorMode::LIGHT_COLOR;2932}29332934void EditorThemeManager::initialize() {2935EditorColorMap::create();2936EditorTheme::initialize();2937}29382939void EditorThemeManager::finalize() {2940EditorColorMap::finish();2941EditorTheme::finalize();2942}294329442945