diff options
Diffstat (limited to 'editor/editor_themes.cpp')
-rw-r--r-- | editor/editor_themes.cpp | 46 |
1 files changed, 40 insertions, 6 deletions
diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 05aa638a4b..d21049414c 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -411,9 +411,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // Colors bool dark_theme = EditorSettings::get_singleton()->is_dark_theme(); - const Color dark_color_1 = base_color.lerp(Color(0, 0, 0, 1), contrast); - const Color dark_color_2 = base_color.lerp(Color(0, 0, 0, 1), contrast * 1.5); - const Color dark_color_3 = base_color.lerp(Color(0, 0, 0, 1), contrast * 2); + // Ensure base colors are in the 0..1 luminance range to avoid 8-bit integer overflow or text rendering issues. + // Some places in the editor use 8-bit integer colors. + const Color dark_color_1 = base_color.lerp(Color(0, 0, 0, 1), contrast).clamp(); + const Color dark_color_2 = base_color.lerp(Color(0, 0, 0, 1), contrast * 1.5).clamp(); + const Color dark_color_3 = base_color.lerp(Color(0, 0, 0, 1), contrast * 2).clamp(); const Color background_color = dark_color_2; @@ -433,7 +435,8 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color disabled_color = mono_color.inverted().lerp(base_color, 0.7); const Color disabled_bg_color = mono_color.inverted().lerp(base_color, 0.9); - Color icon_hover_color = Color(1, 1, 1) * (dark_theme ? 1.15 : 1.45); + const Color icon_normal_color = Color(1, 1, 1); + Color icon_hover_color = icon_normal_color * (dark_theme ? 1.15 : 1.45); icon_hover_color.a = 1.0; Color icon_focus_color = icon_hover_color; // Make the pressed icon color overbright because icons are not completely white on a dark theme. @@ -464,6 +467,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("axis_y_color", "Editor", Color(0.53, 0.84, 0.01)); theme->set_color("axis_z_color", "Editor", Color(0.16, 0.55, 0.96)); + const float prop_color_saturation = accent_color.get_s() * 0.75; + const float prop_color_value = accent_color.get_v(); + + theme->set_color("property_color_x", "Editor", Color().from_hsv(0.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_y", "Editor", Color().from_hsv(1.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_z", "Editor", Color().from_hsv(2.0 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("property_color_w", "Editor", Color().from_hsv(1.5 / 3.0 + 0.05, prop_color_saturation, prop_color_value)); + theme->set_color("font_color", "Editor", font_color); theme->set_color("highlighted_font_color", "Editor", font_hover_color); theme->set_color("disabled_font_color", "Editor", font_disabled_color); @@ -686,10 +697,24 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_focus_color", "Button", font_focus_color); theme->set_color("font_pressed_color", "Button", accent_color); theme->set_color("font_disabled_color", "Button", font_disabled_color); + theme->set_color("icon_normal_color", "Button", icon_normal_color); theme->set_color("icon_hover_color", "Button", icon_hover_color); theme->set_color("icon_focus_color", "Button", icon_focus_color); theme->set_color("icon_pressed_color", "Button", icon_pressed_color); + // Variation for Editor Log filter buttons + theme->set_type_variation("EditorLogFilterButton", "Button"); + // When pressed, don't tint the icons with the accent color, just leave them normal. + theme->set_color("icon_pressed_color", "EditorLogFilterButton", icon_normal_color); + // When unpressed, dim the icons. + theme->set_color("icon_normal_color", "EditorLogFilterButton", font_disabled_color); + // When pressed, add a small bottom border to the buttons to better show their active state, + // similar to active tabs. + Ref<StyleBoxFlat> editor_log_button_pressed = style_widget_pressed->duplicate(); + editor_log_button_pressed->set_border_width(SIDE_BOTTOM, 2 * EDSCALE); + editor_log_button_pressed->set_border_color(accent_color); + theme->set_stylebox("pressed", "EditorLogFilterButton", editor_log_button_pressed); + // OptionButton theme->set_stylebox("focus", "OptionButton", style_widget_focus); @@ -819,7 +844,12 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("visibility_visible", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityVisible"), SNAME("EditorIcons"))); theme->set_icon("visibility_xray", "PopupMenu", theme->get_icon(SNAME("GuiVisibilityXray"), SNAME("EditorIcons"))); - theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size + 1) * EDSCALE); + // Force the vseparation to be even so that the spacing on top and bottom is even. + // If the vsep is odd and cannot be split into 2 even groups (of pixels), then it will be lopsided. + // We add 2 to the vsep to give it some extra spacing which looks a bit more modern (see Windows, for example) + int vsep_base = extra_spacing + default_margin_size + 2; + int force_even_vsep = vsep_base + (vsep_base % 2); + theme->set_constant("vseparation", "PopupMenu", force_even_vsep * EDSCALE); theme->set_constant("item_start_padding", "PopupMenu", popup_menu_margin_size * EDSCALE); theme->set_constant("item_end_padding", "PopupMenu", popup_menu_margin_size * EDSCALE); @@ -864,6 +894,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("sub_inspector_property_color", "Editor", dark_theme ? Color(1, 1, 1, 1) : Color(0, 0, 0, 1)); theme->set_constant("sub_inspector_font_offset", "Editor", 4 * EDSCALE); + // EditorSpinSlider. + theme->set_color("label_color", "EditorSpinSlider", font_color); + theme->set_color("read_only_label_color", "EditorSpinSlider", font_readonly_color); + Ref<StyleBoxFlat> style_property_bg = style_default->duplicate(); style_property_bg->set_bg_color(highlight_color); style_property_bg->set_border_width_all(0); @@ -1156,7 +1190,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("can_fold", "CodeEdit", theme->get_icon(SNAME("GuiTreeArrowDown"), SNAME("EditorIcons"))); theme->set_icon("executing_line", "CodeEdit", theme->get_icon(SNAME("MainPlay"), SNAME("EditorIcons"))); theme->set_icon("breakpoint", "CodeEdit", theme->get_icon(SNAME("Breakpoint"), SNAME("EditorIcons"))); - theme->set_constant("line_spacing", "CodeEdit", EDITOR_DEF("text_editor/appearance/whitespace/line_spacing", 6)); + theme->set_constant("line_spacing", "CodeEdit", EDITOR_GET("text_editor/appearance/whitespace/line_spacing")); // H/VSplitContainer theme->set_stylebox("bg", "VSplitContainer", make_stylebox(theme->get_icon(SNAME("GuiVsplitBg"), SNAME("EditorIcons")), 1, 1, 1, 1)); |