From 8f460bb73db00216f3b24a528d80314b5d632a16 Mon Sep 17 00:00:00 2001 From: toger5 Date: Tue, 19 Sep 2017 00:20:06 +0200 Subject: [PATCH] added editor spacing --- editor/editor_settings.cpp | 2 ++ editor/editor_themes.cpp | 27 ++++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index d4ee6b2d17b..42890361e96 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -582,6 +582,8 @@ void EditorSettings::_load_defaults(Ref p_extra_config) { set("interface/theme/highlight_tabs", false); set("interface/theme/border_size", 1); hints["interface/theme/border_size"] = PropertyInfo(Variant::INT, "interface/theme/border_size", PROPERTY_HINT_RANGE, "0,2,1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); + set("interface/theme/additional_spacing", 0); + hints["interface/theme/additional_spacing"] = PropertyInfo(Variant::REAL, "interface/theme/additional_spacing", PROPERTY_HINT_RANGE, "0,5,0.1", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); set("interface/theme/custom_theme", ""); hints["interface/theme/custom_theme"] = PropertyInfo(Variant::STRING, "interface/theme/custom_theme", PROPERTY_HINT_GLOBAL_FILE, "*.res,*.tres,*.theme", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 3482261c192..0257ecb19a1 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -332,11 +332,14 @@ Ref create_editor_theme(const Ref p_theme) { style_default->set_draw_center(true); // Button and widgets - Ref style_widget = style_default->duplicate(); + const float extra_spacing = EDITOR_DEF("interface/theme/additional_spacing", 0.0); + Ref style_widget = style_default->duplicate(); + style_widget->set_default_margin(MARGIN_LEFT, (extra_spacing + 6) * EDSCALE); + style_widget->set_default_margin(MARGIN_TOP, (extra_spacing + default_margin_size) * EDSCALE); + style_widget->set_default_margin(MARGIN_RIGHT, (extra_spacing + 6) * EDSCALE); + style_widget->set_default_margin(MARGIN_BOTTOM, (extra_spacing + default_margin_size) * EDSCALE); style_widget->set_bg_color(dark_color_1); - style_widget->set_default_margin(MARGIN_LEFT, 6 * EDSCALE); - style_widget->set_default_margin(MARGIN_RIGHT, 6 * EDSCALE); style_widget->set_border_color_all(dark_color_2); Ref style_widget_disabled = style_widget->duplicate(); @@ -368,7 +371,7 @@ Ref create_editor_theme(const Ref p_theme) { // Tabs const int tab_default_margin_side = 10 * EDSCALE; - Ref style_tab_selected = style_default->duplicate(); + Ref style_tab_selected = style_widget->duplicate(); style_tab_selected->set_border_width_all(border_width); style_tab_selected->set_border_width(MARGIN_BOTTOM, 0); style_tab_selected->set_border_color_all(dark_color_3); @@ -391,7 +394,9 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_stylebox("Focus", "EditorStyles", style_focus); // Menu - Ref style_menu = style_empty; + Ref style_menu = style_widget->duplicate(); + style_menu->set_draw_center(false); + style_menu->set_border_width_all(0); theme->set_stylebox("panel", "PanelContainer", style_menu); theme->set_stylebox("MenuPanel", "EditorStyles", style_menu); @@ -403,13 +408,13 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_stylebox("PlayButtonPanel", "EditorStyles", style_empty); //make_stylebox(theme->get_icon("GuiPlayButtonGroup", "EditorIcons"), 16, 16, 16, 16, 8, 4, 8, 4)); //MenuButton - Ref style_menu_hover_border = style_default->duplicate(); + Ref style_menu_hover_border = style_widget->duplicate(); style_menu_hover_border->set_draw_center(false); style_menu_hover_border->set_border_width_all(0); style_menu_hover_border->set_border_width(MARGIN_BOTTOM, border_width); style_menu_hover_border->set_border_color_all(accent_color); - Ref style_menu_hover_bg = style_default->duplicate(); + Ref style_menu_hover_bg = style_widget->duplicate(); style_menu_hover_bg->set_border_width_all(0); style_menu_hover_bg->set_bg_color(dark_color_1); @@ -504,7 +509,7 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_icon("unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("radio_checked", "PopupMenu", theme->get_icon("GuiChecked", "EditorIcons")); theme->set_icon("radio_unchecked", "PopupMenu", theme->get_icon("GuiUnchecked", "EditorIcons")); - + theme->set_constant("vseparation", "PopupMenu", (extra_spacing + default_margin_size) * EDSCALE); // Tree & ItemList background Ref style_tree_bg = style_default->duplicate(); style_tree_bg->set_bg_color(dark_color_1); @@ -524,6 +529,7 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_color("custom_button_font_highlight", "Tree", font_color_hl); theme->set_color("font_color", "Tree", font_color); theme->set_color("font_color_selected", "Tree", font_color); + theme->set_constant("vseparation", "Tree", (extra_spacing + default_margin_size) * EDSCALE); Ref style_tree_btn = style_default->duplicate(); style_tree_btn->set_bg_color(contrast_color_1); @@ -579,7 +585,7 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_stylebox("selected", "ItemList", style_tree_selected); theme->set_stylebox("bg_focus", "ItemList", style_focus); theme->set_stylebox("bg", "ItemList", style_itemlist_bg); - theme->set_constant("vseparation", "ItemList", 5 * EDSCALE); + theme->set_constant("vseparation", "ItemList", (extra_spacing + default_margin_size) * EDSCALE); theme->set_color("font_color", "ItemList", font_color); // Tabs & TabContainer @@ -803,6 +809,9 @@ Ref create_editor_theme(const Ref p_theme) { theme->set_stylebox("comment", "GraphNode", graphsbcomment); theme->set_stylebox("commentfocus", "GraphNode", graphsbcommentselected); + // GridContainer + theme->set_constant("vseperation", "GridContainer", (extra_spacing + default_margin_size) * EDSCALE); + // FileDialog theme->set_color("files_disabled", "FileDialog", font_color_disabled);