From 95f55c8f0d0e56fd039333b611d12f88b74cde78 Mon Sep 17 00:00:00 2001 From: "Daniel J. Ramirez" Date: Tue, 18 Jul 2017 14:35:37 -0500 Subject: Icons can now be added inside line edits (Search icon). Fixed window title bar margins. fixed compilation error --- editor/editor_help.cpp | 19 +++++++++---------- editor/editor_themes.cpp | 3 ++- editor/filesystem_dock.cpp | 6 +----- editor/scene_tree_dock.cpp | 7 ++----- modules/visual_script/visual_script_editor.cpp | 5 +---- scene/gui/dialogs.cpp | 4 +++- scene/gui/line_edit.cpp | 6 ++++++ 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 952c98d0f6..e890082ee1 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -36,7 +36,8 @@ #include "os/keyboard.h" void EditorHelpSearch::popup() { - popup_centered_ratio(0.6); + + popup_centered(Size2(700, 600) * EDSCALE); if (search_box->get_text() != "") { search_box->select_all(); _update_search(); @@ -46,7 +47,7 @@ void EditorHelpSearch::popup() { void EditorHelpSearch::popup(const String &p_term) { - popup_centered_ratio(0.6); + popup_centered(Size2(700, 600) * EDSCALE); if (p_term != "") { search_box->set_text(p_term); search_box->select_all(); @@ -262,6 +263,8 @@ void EditorHelpSearch::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { + search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); + connect("confirmed", this, "_confirmed"); _update_search(); } @@ -293,12 +296,7 @@ EditorHelpSearch::EditorHelpSearch() { HBoxContainer *sb_hb = memnew(HBoxContainer); search_box = memnew(LineEdit); - sb_hb->add_child(search_box); - search_box->set_h_size_flags(SIZE_EXPAND_FILL); - Button *sb = memnew(Button(TTR("Search"))); - sb->connect("pressed", this, "_update_search"); - sb_hb->add_child(sb); - vbc->add_margin_child(TTR("Search:"), sb_hb); + vbc->add_child(search_box); search_box->connect("text_changed", this, "_text_changed"); search_box->connect("gui_input", this, "_sbox_input"); search_options = memnew(Tree); @@ -378,7 +376,7 @@ void EditorHelpIndex::select_class(const String &p_class) { void EditorHelpIndex::popup() { - popup_centered_ratio(0.6); + popup_centered(Size2(500, 600) * EDSCALE); search_box->set_text(""); _update_class_list(); @@ -388,6 +386,7 @@ void EditorHelpIndex::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { + search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); _update_class_list(); connect("confirmed", this, "_tree_item_selected"); @@ -478,7 +477,7 @@ EditorHelpIndex::EditorHelpIndex() { add_child(vbc); search_box = memnew(LineEdit); - vbc->add_margin_child(TTR("Search:"), search_box); + vbc->add_child(search_box); search_box->set_h_size_flags(SIZE_EXPAND_FILL); register_text_enter(search_box); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 4e8f7029ff..6b985c7b4b 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -434,7 +434,8 @@ Ref create_editor_theme() { theme->set_icon("close", "WindowDialog", title_hl_close_icon); theme->set_icon("close_highlight", "WindowDialog", title_hl_close_icon); theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE); - theme->set_constant("close_v_ofs", "WindowDialog", 18 * EDSCALE); + theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE); + theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE); // HScrollBar Ref empty_icon = memnew(ImageTexture); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index fe66cd7009..c82c599139 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -153,7 +153,7 @@ void FileSystemDock::_notification(int p_what) { files->connect("item_activated", this, "_select_file"); button_hist_next->connect("pressed", this, "_fw_history"); button_hist_prev->connect("pressed", this, "_bw_history"); - search_icon->set_texture(get_icon("Search", "EditorIcons")); + search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); button_hist_next->set_icon(get_icon("Forward", "EditorIcons")); button_hist_prev->set_icon(get_icon("Back", "EditorIcons")); @@ -1749,10 +1749,6 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { path_hb->add_child(search_box); search_box->connect("text_changed", this, "_search_changed"); - search_icon = memnew(TextureRect); - search_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); - path_hb->add_child(search_icon); - button_display_mode = memnew(ToolButton); path_hb->add_child(button_display_mode); button_display_mode->set_toggle_mode(true); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index cdae9baaf2..a9c3fc17f0 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -786,7 +786,7 @@ void SceneTreeDock::_notification(int p_what) { button_create_script->set_icon(get_icon("ScriptCreate", "EditorIcons")); button_clear_script->set_icon(get_icon("ScriptRemove", "EditorIcons")); - filter_icon->set_texture(get_icon("Search", "EditorIcons")); + filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed"); @@ -2021,11 +2021,8 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel vbc->add_child(filter_hbc); filter = memnew(LineEdit); filter->set_h_size_flags(SIZE_EXPAND_FILL); + filter->set_placeholder(TTR("Filter nodes")); filter_hbc->add_child(filter); - filter_icon = memnew(TextureRect); - filter_icon->set_custom_minimum_size(Size2(24 * EDSCALE, 0)); - filter_hbc->add_child(filter_icon); - filter_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); filter->connect("text_changed", this, "_filter_changed"); tb = memnew(ToolButton); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 08757f4c61..ba3463445d 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2746,7 +2746,7 @@ void VisualScriptEditor::_node_filter_changed(const String &p_text) { void VisualScriptEditor::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - node_filter_icon->set_texture(Control::get_icon("Search", "EditorIcons")); + node_filter->add_icon_override("right_icon", Control::get_icon("Search", "EditorIcons")); variable_editor->connect("changed", this, "_update_members"); signal_editor->connect("changed", this, "_update_members"); } @@ -3215,9 +3215,6 @@ VisualScriptEditor::VisualScriptEditor() { node_filter->connect("text_changed", this, "_node_filter_changed"); hbc_nodes->add_child(node_filter); node_filter->set_h_size_flags(SIZE_EXPAND_FILL); - node_filter_icon = memnew(TextureRect); - node_filter_icon->set_stretch_mode(TextureRect::STRETCH_KEEP_CENTERED); - hbc_nodes->add_child(node_filter_icon); vbc_nodes->add_child(hbc_nodes); nodes = memnew(Tree); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 8885bec03c..7d7c636bc2 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -584,6 +584,8 @@ Button *ConfirmationDialog::get_cancel() { ConfirmationDialog::ConfirmationDialog() { set_title(RTR("Please Confirm...")); - set_custom_minimum_size(Size2(200, 70)); +#ifdef TOOLS_ENABLED + set_custom_minimum_size(Size2(200, 70) * EDSCALE); +#endif cancel = add_cancel(); } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index adcf86357d..f4dd3e92cd 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -628,6 +628,12 @@ void LineEdit::_notification(int p_what) { font_color.a *= placeholder_alpha; font_color.a *= disabled_alpha; + if (has_icon("right_icon")) { + Ref r_icon = Control::get_icon("right_icon"); + ofs_max -= r_icon->get_width(); + r_icon->draw(ci, Point2(width - r_icon->get_width() - x_ofs, y_ofs), Color(1, 1, 1, disabled_alpha * .9)); + } + int caret_height = font->get_height() > y_area ? y_area : font->get_height(); while (true) { -- cgit v1.2.3