From 17c3422431c3312d6e124b0afa871fd166928669 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Tue, 18 Jul 2017 01:09:19 -0500 Subject: [PATCH] Added separators using StyleBoxLine, some theme style fixes, added variant icon --- editor/editor_node.cpp | 4 +- editor/editor_themes.cpp | 22 +++- editor/icons/2x/icon_variant.png | Bin 0 -> 398 bytes editor/icons/icon_variant.png | Bin 240 -> 237 bytes editor/icons/source/icon_variant.svg | 146 +++++++++++++++++++++++++++ editor/script_editor_debugger.cpp | 19 ++-- scene/gui/dialogs.cpp | 1 + scene/gui/option_button.cpp | 17 +++- scene/resources/style_box.cpp | 78 ++++++++++++++ scene/resources/style_box.h | 34 +++++++ 10 files changed, 305 insertions(+), 16 deletions(-) create mode 100644 editor/icons/2x/icon_variant.png create mode 100644 editor/icons/source/icon_variant.svg diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 00609b22d74..8912467b720 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -1628,7 +1628,7 @@ void EditorNode::_edit_current() { p->add_separator(); p->add_shortcut(ED_SHORTCUT("property_editor/make_subresources_unique", TTR("Make Sub-Resources Unique")), OBJECT_UNIQUE_RESOURCES); p->add_separator(); - p->add_icon_shortcut(gui_base->get_icon("Help", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); + p->add_icon_shortcut(gui_base->get_icon("HelpSearch", "EditorIcons"), ED_SHORTCUT("property_editor/open_help", TTR("Open in Help")), OBJECT_REQUEST_HELP); } List methods; @@ -5642,7 +5642,7 @@ EditorNode::EditorNode() { p = help_menu->get_popup(); p->connect("id_pressed", this, "_menu_option"); p->add_icon_item(gui_base->get_icon("ClassList", "EditorIcons"), TTR("Classes"), HELP_CLASSES); - p->add_icon_item(gui_base->get_icon("Help", "EditorIcons"), TTR("Search"), HELP_SEARCH); + p->add_icon_item(gui_base->get_icon("HelpSearch", "EditorIcons"), TTR("Search"), HELP_SEARCH); p->add_separator(); p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Online Docs"), HELP_DOCS); p->add_icon_item(gui_base->get_icon("Instance", "EditorIcons"), TTR("Q&A"), HELP_QA); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index ce9b004ce17..4e8f7029ffc 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -69,6 +69,15 @@ static Ref make_flat_stylebox(Color color, float p_margin_left = - return style; } +static Ref make_line_stylebox(Color color, int thickness = 1, float grow = 1, bool vertical = false) { + Ref style(memnew(StyleBoxLine)); + style->set_color(color); + style->set_grow(grow); + style->set_thickness(thickness); + style->set_vertical(vertical); + return style; +} + static Ref change_border_color(Ref p_style, Color p_color) { Ref style = p_style->duplicate(); style->set_light_color(p_color); @@ -143,6 +152,9 @@ Ref create_editor_theme() { Color title_color_hl_text_color = dark_bg ? Color(1, 1, 1, 0.9) : Color(0, 0, 0, 0.9); Ref title_hl_close_icon = theme->get_icon((dark_bg ? "GuiCloseLight" : "GuiCloseDark"), "EditorIcons"); + bool dark_base = ((base_color.r + base_color.g + base_color.b) / 3.0) < 0.5; + Color separator_color = dark_base ? Color(1, 1, 1, 0.1) : Color(0, 0, 0, 0.1); + theme->set_color("highlight_color", "Editor", highlight_color); theme->set_color("base_color", "Editor", base_color); theme->set_color("dark_color_1", "Editor", dark_color_1); @@ -244,7 +256,7 @@ Ref create_editor_theme() { theme->set_color("icon_color_pressed", "Button", Color(highlight_color.r * 1.15, highlight_color.g * 1.15, highlight_color.b * 1.15, highlight_color.a)); // OptionButton - Ref style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 4, 4); + Ref style_option_button = make_flat_stylebox(dark_color_1, 4, 4, 8, 4); style_option_button->set_border_size(border_width); style_option_button->set_light_color(light_color_1); style_option_button->set_dark_color(light_color_1); @@ -259,6 +271,8 @@ Ref create_editor_theme() { theme->set_color("font_color_pressed", "OptionButton", highlight_color); theme->set_color("icon_color_hover", "OptionButton", HIGHLIGHT_COLOR_LIGHT); theme->set_icon("arrow", "OptionButton", theme->get_icon("GuiOptionArrow", "EditorIcons")); + theme->set_constant("arrow_margin", "OptionButton", 4); + theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons")); @@ -271,7 +285,7 @@ Ref create_editor_theme() { style_popup_menu->set_dark_color(light_color_1); style_popup_menu->set_border_blend(false); theme->set_stylebox("panel", "PopupMenu", style_popup_menu); - theme->set_stylebox("separator", "PopupMenu", make_empty_stylebox()); + theme->set_stylebox("separator", "PopupMenu", make_line_stylebox(separator_color, border_width, 8 - border_width)); // Tree & ItemList background Ref style_tree_bg = make_flat_stylebox(dark_color_1, 2, 4, 2, 4); @@ -362,8 +376,8 @@ Ref create_editor_theme() { theme->set_icon("close", "Tabs", title_hl_close_icon); // Separatos (no separatos) - theme->set_stylebox("separator", "HSeparator", make_empty_stylebox()); - theme->set_stylebox("separator", "VSeparator", make_empty_stylebox()); + theme->set_stylebox("separator", "HSeparator", make_line_stylebox(separator_color, border_width)); + theme->set_stylebox("separator", "VSeparator", make_line_stylebox(separator_color, border_width, 0, true)); // Debugger Ref style_panel_debugger = make_flat_stylebox(dark_color_2, 0, 4, 0, 0); diff --git a/editor/icons/2x/icon_variant.png b/editor/icons/2x/icon_variant.png new file mode 100644 index 0000000000000000000000000000000000000000..bb8075a06940692a750583d886c0c0f264931773 GIT binary patch literal 398 zcmV;90df9`P)d-8J1Y6I5#0g+VW#KR|c7_{J zafPxmAQmr`lHPy}jU1T?R7?YIRm6bb6n*;t=g(23KqL~0{CC9rgE6L?rs>!@cLp2+ zz16|NU?2eI^SSdJ74R&CxU1`WlIQty-CWzg1SpE4uatUp&Rqi||L`B^0VC(!jZ$h> z6h(i7U8FIl+ceD-IND^fh2y4a?u{|s-~wryj(2qUM+v3WMQ{P&+{>m(l4PNRPN$=R z2QT)W?FF23`=0PpYrO~+WLZ{PYsX%E5L_U1@H>XXVc|u4!0T#ImgU;FDuoa)tAVw4 z(l)#apz7&kFZfGhfk-6s23V$kDh;EB!vFvP07*qoM6N<$f;}Cs!2kdN literal 0 HcmV?d00001 diff --git a/editor/icons/icon_variant.png b/editor/icons/icon_variant.png index 1ae2812ff7c9cd25e6bc814c11c99057d83f74d2..af7590345edd8ea1095a21293cab0ebd6fd32d14 100644 GIT binary patch delta 209 zcmV;?051RV0qp^hB!32COGiWi{{a60|De66lK=n!qDe$SR5*?8k-ZJVFcgIEEJX1# z0W|R*z$jS*x)e|`M@E4a+$T*&utarfY=ppsf)c*Q#eIH1dcdErVF+PqW+##jfE56E z@7edgk~2!`VvKE7Rk!DSVP;2?`pa{@5omu?)_s-!GJ!pokt;700000 LNkvXXu0mjf{S#a; delta 212 zcmV;_04x9P0q_BkB!3BTNLh0L01ejw01ejxLMWSf00007bV*G`2jB-B6*Cp_BxO|q z000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0001LNkl_(ne}p}R!xwU0K{4&xkyT`sgkmp znWUreSvb2_C%H + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 9dce48937c3..4b3ebf5643d 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -1849,30 +1849,31 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { } { // misc - VBoxContainer *info_left = memnew(VBoxContainer); - info_left->set_h_size_flags(SIZE_EXPAND_FILL); + GridContainer *info_left = memnew(GridContainer); + info_left->set_columns(2); info_left->set_name(TTR("Misc")); tabs->add_child(info_left); clicked_ctrl = memnew(LineEdit); - info_left->add_margin_child(TTR("Clicked Control:"), clicked_ctrl); + clicked_ctrl->set_h_size_flags(SIZE_EXPAND_FILL); + info_left->add_child(memnew(Label(TTR("Clicked Control:")))); + info_left->add_child(clicked_ctrl); clicked_ctrl_type = memnew(LineEdit); - info_left->add_margin_child(TTR("Clicked Control Type:"), clicked_ctrl_type); + info_left->add_child(memnew(Label(TTR("Clicked Control Type:")))); + info_left->add_child(clicked_ctrl_type); live_edit_root = memnew(LineEdit); + live_edit_root->set_h_size_flags(SIZE_EXPAND_FILL); { HBoxContainer *lehb = memnew(HBoxContainer); Label *l = memnew(Label(TTR("Live Edit Root:"))); - lehb->add_child(l); - l->set_h_size_flags(SIZE_EXPAND_FILL); + info_left->add_child(l); + lehb->add_child(live_edit_root); le_set = memnew(Button(TTR("Set From Tree"))); lehb->add_child(le_set); le_clear = memnew(Button(TTR("Clear"))); lehb->add_child(le_clear); info_left->add_child(lehb); - MarginContainer *mc = memnew(MarginContainer); - mc->add_child(live_edit_root); - info_left->add_child(mc); le_set->set_disabled(true); le_clear->set_disabled(true); } diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index d5e852f8403..8885bec03ce 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -584,5 +584,6 @@ Button *ConfirmationDialog::get_cancel() { ConfirmationDialog::ConfirmationDialog() { set_title(RTR("Please Confirm...")); + set_custom_minimum_size(Size2(200, 70)); cancel = add_cancel(); } diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index f75e0986c11..b842419eabb 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -52,11 +52,26 @@ void OptionButton::_notification(int p_what) { RID ci = get_canvas_item(); Ref arrow = Control::get_icon("arrow"); Ref normal = get_stylebox("normal"); + Color clr = Color(1, 1, 1); + if (get_constant("modulate_arrow")) + switch (get_draw_mode()) { + case DRAW_PRESSED: + clr = get_color("font_color_pressed"); + break; + case DRAW_HOVER: + clr = get_color("font_color_hover"); + break; + case DRAW_DISABLED: + clr = get_color("font_color_disabled"); + break; + default: + clr = get_color("font_color"); + } Size2 size = get_size(); Point2 ofs(size.width - arrow->get_width() - get_constant("arrow_margin"), int(Math::abs((size.height - arrow->get_height()) / 2))); - arrow->draw(ci, ofs); + arrow->draw(ci, ofs, clr); } break; } diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp index 2714ffec105..f108809c83d 100644 --- a/scene/resources/style_box.cpp +++ b/scene/resources/style_box.cpp @@ -437,3 +437,81 @@ StyleBoxFlat::StyleBoxFlat() { } StyleBoxFlat::~StyleBoxFlat() { } + +void StyleBoxLine::set_color(const Color &p_color) { + color = p_color; + emit_changed(); +} +Color StyleBoxLine::get_color() const { + return color; +} + +void StyleBoxLine::set_thickness(int p_thickness) { + thickness = p_thickness; + emit_changed(); +} +int StyleBoxLine::get_thickness() const { + return thickness; +} + +void StyleBoxLine::set_vertical(bool p_vertical) { + vertical = p_vertical; +} +bool StyleBoxLine::is_vertical() const { + return vertical; +} + +void StyleBoxLine::set_grow(float p_grow) { + grow = p_grow; + emit_changed(); +} +float StyleBoxLine::get_grow() const { + return grow; +} + +void StyleBoxLine::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_color", "color"), &StyleBoxLine::set_color); + ClassDB::bind_method(D_METHOD("get_color"), &StyleBoxLine::get_color); + ClassDB::bind_method(D_METHOD("set_thickness", "thickness"), &StyleBoxLine::set_thickness); + ClassDB::bind_method(D_METHOD("get_thickness"), &StyleBoxLine::get_thickness); + ClassDB::bind_method(D_METHOD("set_grow", "grow"), &StyleBoxLine::set_grow); + ClassDB::bind_method(D_METHOD("get_grow"), &StyleBoxLine::get_grow); + ClassDB::bind_method(D_METHOD("set_vertical", "vertical"), &StyleBoxLine::set_vertical); + ClassDB::bind_method(D_METHOD("is_vertical"), &StyleBoxLine::is_vertical); + + ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_color", "get_color"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "thickness", PROPERTY_HINT_RANGE, "0,10"), "set_thickness", "get_thickness"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "vertical"), "set_vertical", "get_vertical"); +} +float StyleBoxLine::get_style_margin(Margin p_margin) const { + return thickness; +} +Size2 StyleBoxLine::get_center_size() const { + return Size2(); +} + +void StyleBoxLine::draw(RID p_canvas_item, const Rect2 &p_rect) const { + VisualServer *vs = VisualServer::get_singleton(); + Rect2i r = p_rect; + + if (vertical) { + r.position.y -= grow; + r.size.y += grow * 2; + r.size.x = thickness; + } else { + r.position.x -= grow; + r.size.x += grow * 2; + r.size.y = thickness; + } + + vs->canvas_item_add_rect(p_canvas_item, r, color); +} + +StyleBoxLine::StyleBoxLine() { + grow = 1.0; + thickness = 1; + color = Color(0.0, 0.0, 0.0); + vertical = false; +} +StyleBoxLine::~StyleBoxLine() {} diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h index 7547c2ea817..64ce3528aa0 100644 --- a/scene/resources/style_box.h +++ b/scene/resources/style_box.h @@ -164,4 +164,38 @@ public: ~StyleBoxFlat(); }; +// just used to draw lines. +class StyleBoxLine : public StyleBox { + + GDCLASS(StyleBoxLine, StyleBox); + Color color; + int thickness; + bool vertical; + float grow; + +protected: + virtual float get_style_margin(Margin p_margin) const; + static void _bind_methods(); + +public: + void set_color(const Color &p_color); + Color get_color() const; + + void set_thickness(int p_thickness); + int get_thickness() const; + + void set_vertical(bool p_vertical); + bool is_vertical() const; + + void set_grow(float p_grow); + float get_grow() const; + + virtual Size2 get_center_size() const; + + virtual void draw(RID p_canvas_item, const Rect2 &p_rect) const; + + StyleBoxLine(); + ~StyleBoxLine(); +}; + #endif