From e06cd2742f8af57b23fa11dec62ba9c4eb544291 Mon Sep 17 00:00:00 2001 From: kobewi Date: Thu, 11 Aug 2022 14:15:04 +0200 Subject: [PATCH] Add missing properties to default theme --- doc/classes/GraphNode.xml | 3 +++ doc/classes/OptionButton.xml | 6 ++++++ doc/classes/PopupMenu.xml | 12 ++++++++++++ editor/editor_themes.cpp | 3 +-- editor/plugins/texture_editor_plugin.cpp | 2 +- scene/gui/option_button.cpp | 3 +++ scene/gui/popup_menu.cpp | 15 ++++++++++----- scene/resources/default_theme/default_theme.cpp | 7 +++++++ 8 files changed, 43 insertions(+), 8 deletions(-) diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index ac14d5d2a84..435c6dae14a 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -321,6 +321,9 @@ The vertical distance between ports. + + Horizontal offset of the title text. + Vertical offset of the title text. diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 9e476bd05b0..8f2660ad613 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -233,6 +233,9 @@ Text [Color] used when the [OptionButton] is being hovered. + + Text [Color] used when the [OptionButton] is being hovered and pressed. + The tint of text outline of the [OptionButton]. @@ -245,6 +248,9 @@ The horizontal space between [OptionButton]'s icon and text. + + If different than [code]0[/code], the arrow icon will be modulated to the font color. + The size of the text outline. diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 410489481e4..284c5a18704 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -594,12 +594,21 @@ [Texture2D] icon for the checked checkbox items. + + [Texture2D] icon for the checked checkbox items when they are disabled. + [Texture2D] icon for the checked radio button items. + + [Texture2D] icon for the checked radio button items when they are disabled. + [Texture2D] icon for the unchecked radio button items. + + [Texture2D] icon for the unchecked radio button items when they are disabled. + [Texture2D] icon for the submenu arrow (for left-to-right layouts). @@ -609,6 +618,9 @@ [Texture2D] icon for the unchecked checkbox items. + + [Texture2D] icon for the unchecked checkbox items when they are disabled. + [StyleBox] displayed when the [PopupMenu] item is hovered. diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index a3086a2ccf4..c58d1263f34 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -1262,7 +1262,6 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_stylebox("focus", "LineEdit", style_widget_focus); theme->set_stylebox("read_only", "LineEdit", style_line_edit_disabled); theme->set_icon("clear", "LineEdit", theme->get_icon(SNAME("GuiClose"), SNAME("EditorIcons"))); - theme->set_color("read_only", "LineEdit", font_disabled_color); theme->set_color("font_color", "LineEdit", font_color); theme->set_color("font_selected_color", "LineEdit", mono_color); theme->set_color("font_uneditable_color", "LineEdit", font_readonly_color); @@ -1455,7 +1454,7 @@ Ref create_editor_theme(const Ref p_theme) { style_tooltip->set_bg_color(dark_color_3 * Color(0.8, 0.8, 0.8, 0.9)); style_tooltip->set_border_width_all(0); theme->set_color("font_color", "TooltipLabel", font_hover_color); - theme->set_color("font_color_shadow", "TooltipLabel", Color(0, 0, 0, 0)); + theme->set_color("font_shadow_color", "TooltipLabel", Color(0, 0, 0, 0)); theme->set_stylebox("panel", "TooltipPanel", style_tooltip); // PopupPanel diff --git a/editor/plugins/texture_editor_plugin.cpp b/editor/plugins/texture_editor_plugin.cpp index f6b02d5f802..be382759f53 100644 --- a/editor/plugins/texture_editor_plugin.cpp +++ b/editor/plugins/texture_editor_plugin.cpp @@ -137,7 +137,7 @@ TexturePreview::TexturePreview(Ref p_texture, bool p_show_metadata) { // It's okay that these colors are static since the grid color is static too. metadata_label->add_theme_color_override("font_color", Color::named("white")); - metadata_label->add_theme_color_override("font_color_shadow", Color::named("black")); + metadata_label->add_theme_color_override("font_shadow_color", Color::named("black")); metadata_label->add_theme_font_size_override("font_size", 14 * EDSCALE); metadata_label->add_theme_color_override("font_outline_color", Color::named("black")); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index c6d011d4ef2..b26410e3185 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -74,6 +74,9 @@ void OptionButton::_notification(int p_what) { case DRAW_HOVER: clr = get_theme_color(SNAME("font_hover_color")); break; + case DRAW_HOVER_PRESSED: + clr = get_theme_color(SNAME("font_hover_pressed_color")); + break; case DRAW_DISABLED: clr = get_theme_color(SNAME("font_disabled_color")); break; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 928bab88427..cd0d4370513 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -513,9 +513,9 @@ void PopupMenu::_draw_items() { bool rtl = control->is_layout_rtl(); Ref style = get_theme_stylebox(SNAME("panel")); Ref hover = get_theme_stylebox(SNAME("hover")); - // In Item::checkable_type enum order (less the non-checkable member). - Ref check[] = { get_theme_icon(SNAME("checked")), get_theme_icon(SNAME("radio_checked")) }; - Ref uncheck[] = { get_theme_icon(SNAME("unchecked")), get_theme_icon(SNAME("radio_unchecked")) }; + // In Item::checkable_type enum order (less the non-checkable member), with disabled repeated at the end. + Ref check[] = { get_theme_icon(SNAME("checked")), get_theme_icon(SNAME("radio_checked")), get_theme_icon(SNAME("checked_disabled")), get_theme_icon(SNAME("radio_checked_disabled")) }; + Ref uncheck[] = { get_theme_icon(SNAME("unchecked")), get_theme_icon(SNAME("radio_unchecked")), get_theme_icon(SNAME("unchecked_disabled")), get_theme_icon(SNAME("radio_unchecked_disabled")) }; Ref submenu; if (rtl) { submenu = get_theme_icon(SNAME("submenu_mirrored")); @@ -558,7 +558,11 @@ void PopupMenu::_draw_items() { float check_ofs = 0.0; if (has_check) { - check_ofs = MAX(get_theme_icon(SNAME("checked"))->get_width(), get_theme_icon(SNAME("radio_checked"))->get_width()) + hseparation; + for (int i = 0; i < 4; i++) { + check_ofs = MAX(check_ofs, check[i]->get_width()); + check_ofs = MAX(check_ofs, uncheck[i]->get_width()); + } + check_ofs += hseparation; } Point2 ofs = Point2(); @@ -620,7 +624,8 @@ void PopupMenu::_draw_items() { // Checkboxes if (items[i].checkable_type && !items[i].separator) { - Texture2D *icon = (items[i].checked ? check[items[i].checkable_type - 1] : uncheck[items[i].checkable_type - 1]).ptr(); + int disabled = int(items[i].disabled) * 2; + Texture2D *icon = (items[i].checked ? check[items[i].checkable_type - 1 + disabled] : uncheck[items[i].checkable_type - 1 + disabled]).ptr(); if (rtl) { icon->draw(ci, Size2(control->get_size().width - item_ofs.x - icon->get_width(), item_ofs.y) + Point2(0, Math::floor((h - icon->get_height()) / 2.0)), icon_color); } else { diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index fa375795c1b..f29cfec92f4 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -224,6 +224,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_color("font_color", "OptionButton", control_font_color); theme->set_color("font_pressed_color", "OptionButton", control_font_pressed_color); theme->set_color("font_hover_color", "OptionButton", control_font_hover_color); + theme->set_color("font_hover_pressed_color", "OptionButton", control_font_pressed_color); theme->set_color("font_focus_color", "OptionButton", control_font_focus_color); theme->set_color("font_disabled_color", "OptionButton", control_font_disabled_color); theme->set_color("font_outline_color", "OptionButton", Color(1, 1, 1)); @@ -231,6 +232,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_constant("h_separation", "OptionButton", 2 * scale); theme->set_constant("arrow_margin", "OptionButton", 4 * scale); theme->set_constant("outline_size", "OptionButton", 0); + theme->set_constant("modulate_arrow", "OptionButton", false); // MenuButton @@ -644,9 +646,13 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_stylebox("labeled_separator_right", "PopupMenu", separator_horizontal); theme->set_icon("checked", "PopupMenu", icons["checked"]); + theme->set_icon("checked_disabled", "PopupMenu", icons["checked"]); theme->set_icon("unchecked", "PopupMenu", icons["unchecked"]); + theme->set_icon("unchecked_disabled", "PopupMenu", icons["unchecked"]); theme->set_icon("radio_checked", "PopupMenu", icons["radio_checked"]); + theme->set_icon("radio_checked_disabled", "PopupMenu", icons["radio_checked"]); theme->set_icon("radio_unchecked", "PopupMenu", icons["radio_unchecked"]); + theme->set_icon("radio_unchecked_disabled", "PopupMenu", icons["radio_unchecked"]); theme->set_icon("submenu", "PopupMenu", icons["popup_menu_arrow_right"]); theme->set_icon("submenu_mirrored", "PopupMenu", icons["popup_menu_arrow_left"]); @@ -703,6 +709,7 @@ void fill_default_theme(Ref &theme, const Ref &default_font, const theme->set_color("resizer_color", "GraphNode", control_font_color); theme->set_constant("separation", "GraphNode", 2 * scale); theme->set_constant("title_offset", "GraphNode", 26 * scale); + theme->set_constant("title_h_offset", "GraphNode", 0); theme->set_constant("close_offset", "GraphNode", 22 * scale); theme->set_constant("close_h_offset", "GraphNode", 22 * scale); theme->set_constant("port_offset", "GraphNode", 0);