summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorŁukasz Rutkowski <lukus178@gmail.com>2018-08-11 12:04:19 +0200
committerŁukasz Rutkowski <lukus178@gmail.com>2018-08-11 12:04:26 +0200
commit81fb81de9d9fe7ae075bd06a3877d6cb452af67f (patch)
treef753bd70228e21956d681d814acb9cfa687f150e
parente8a435c8cdc5778ebae5e66d983a7bc720f81e85 (diff)
Do not use theme to set LineEdit right_icon
-rw-r--r--editor/create_dialog.cpp2
-rw-r--r--editor/editor_help.cpp8
-rw-r--r--editor/filesystem_dock.cpp4
-rw-r--r--editor/groups_editor.cpp4
-rw-r--r--editor/inspector_dock.cpp2
-rw-r--r--editor/plugins/asset_library_editor_plugin.cpp4
-rw-r--r--editor/plugins/script_editor_plugin.cpp2
-rw-r--r--editor/plugins/tile_map_editor_plugin.cpp2
-rw-r--r--editor/project_manager.cpp2
-rw-r--r--editor/project_settings_editor.cpp4
-rw-r--r--editor/quick_open.cpp2
-rw-r--r--editor/scene_tree_dock.cpp4
-rw-r--r--editor/settings_config_dialog.cpp4
-rw-r--r--modules/visual_script/visual_script_editor.cpp2
-rw-r--r--scene/gui/line_edit.cpp17
-rw-r--r--scene/gui/line_edit.h4
16 files changed, 39 insertions, 28 deletions
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 520e72dd5b..f97f1d0871 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -425,7 +425,7 @@ void CreateDialog::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
connect("confirmed", this, "_confirmed");
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
favorite->set_icon(get_icon("Favorites", "EditorIcons"));
} break;
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 1544d74570..0aad361ba0 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -253,7 +253,7 @@ void EditorHelpSearch::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
//_update_icons
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
connect("confirmed", this, "_confirmed");
@@ -268,7 +268,7 @@ void EditorHelpSearch::_notification(int p_what) {
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
//_update_icons
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
} else if (p_what == NOTIFICATION_PROCESS) {
@@ -383,7 +383,7 @@ void EditorHelpIndex::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
//_update_icons
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
_update_class_list();
@@ -395,7 +395,7 @@ void EditorHelpIndex::_notification(int p_what) {
} else if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) {
//_update_icons
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
}
}
diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp
index 2a44616ce3..1c9bcc3360 100644
--- a/editor/filesystem_dock.cpp
+++ b/editor/filesystem_dock.cpp
@@ -196,7 +196,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_box->add_icon_override("right_icon", get_icon("Search", ei));
+ search_box->set_right_icon(get_icon("Search", ei));
search_box->set_clear_button_enabled(true);
button_hist_next->set_icon(get_icon("Forward", ei));
@@ -253,7 +253,7 @@ void FileSystemDock::_notification(int p_what) {
button_hist_next->set_icon(get_icon("Forward", ei));
button_hist_prev->set_icon(get_icon("Back", ei));
- search_box->add_icon_override("right_icon", get_icon("Search", ei));
+ search_box->set_right_icon(get_icon("Search", ei));
search_box->set_clear_button_enabled(true);
if (new_mode != display_mode) {
diff --git a/editor/groups_editor.cpp b/editor/groups_editor.cpp
index 4c11967429..0efd14e932 100644
--- a/editor/groups_editor.cpp
+++ b/editor/groups_editor.cpp
@@ -287,9 +287,9 @@ void GroupDialog::_notification(int p_what) {
add_button->set_icon(get_icon("Forward", "EditorIcons"));
remove_button->set_icon(get_icon("Back", "EditorIcons"));
- add_filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ add_filter->set_right_icon(get_icon("Search", "EditorIcons"));
add_filter->set_clear_button_enabled(true);
- remove_filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ remove_filter->set_right_icon(get_icon("Search", "EditorIcons"));
remove_filter->set_clear_button_enabled(true);
} break;
}
diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp
index 1cf31511df..615e9df043 100644
--- a/editor/inspector_dock.cpp
+++ b/editor/inspector_dock.cpp
@@ -529,7 +529,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) {
search = memnew(LineEdit);
search->set_h_size_flags(Control::SIZE_EXPAND_FILL);
search->set_placeholder(TTR("Filter properties"));
- search->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search->set_right_icon(get_icon("Search", "EditorIcons"));
search->set_clear_button_enabled(true);
add_child(search);
diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp
index b7dc82bfb0..ddd84aa563 100644
--- a/editor/plugins/asset_library_editor_plugin.cpp
+++ b/editor/plugins/asset_library_editor_plugin.cpp
@@ -554,7 +554,7 @@ void EditorAssetLibrary::_notification(int p_what) {
error_tr->set_texture(get_icon("Error", "EditorIcons"));
reverse->set_icon(get_icon("Sort", "EditorIcons"));
- filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(get_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
error_label->raise();
@@ -606,7 +606,7 @@ void EditorAssetLibrary::_notification(int p_what) {
library_scroll_bg->add_style_override("panel", get_stylebox("bg", "Tree"));
error_tr->set_texture(get_icon("Error", "EditorIcons"));
reverse->set_icon(get_icon("Sort", "EditorIcons"));
- filter->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(get_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
} break;
}
diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp
index 55d2353d39..10d5f5001a 100644
--- a/editor/plugins/script_editor_plugin.cpp
+++ b/editor/plugins/script_editor_plugin.cpp
@@ -220,7 +220,7 @@ void ScriptEditorQuickOpen::_notification(int p_what) {
connect("confirmed", this, "_confirmed");
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
} break;
}
diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp
index 78f73bbdba..101dc3037f 100644
--- a/editor/plugins/tile_map_editor_plugin.cpp
+++ b/editor/plugins/tile_map_editor_plugin.cpp
@@ -73,7 +73,7 @@ void TileMapEditor::_notification(int p_what) {
rotate_180->set_icon(get_icon("Rotate180", "EditorIcons"));
rotate_270->set_icon(get_icon("Rotate270", "EditorIcons"));
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
PopupMenu *p = options->get_popup();
diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp
index c7abd5e161..dc5d1e1473 100644
--- a/editor/project_manager.cpp
+++ b/editor/project_manager.cpp
@@ -2046,7 +2046,7 @@ void ProjectListFilter::_filter_option_selected(int p_idx) {
void ProjectListFilter::_notification(int p_what) {
if (p_what == NOTIFICATION_ENTER_TREE) {
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
}
}
diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp
index e88fcce0bf..d52538f67b 100644
--- a/editor/project_settings_editor.cpp
+++ b/editor/project_settings_editor.cpp
@@ -81,7 +81,7 @@ void ProjectSettingsEditor::_notification(int p_what) {
globals_editor->edit(ProjectSettings::get_singleton());
search_button->set_icon(get_icon("Search", "EditorIcons"));
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
@@ -120,7 +120,7 @@ void ProjectSettingsEditor::_notification(int p_what) {
case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: {
search_button->set_icon(get_icon("Search", "EditorIcons"));
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
action_add_error->add_color_override("font_color", get_color("error_color", "Editor"));
popup_add->set_item_icon(popup_add->get_item_index(INPUT_KEY), get_icon("Keyboard", "EditorIcons"));
diff --git a/editor/quick_open.cpp b/editor/quick_open.cpp
index 0f373f1999..d2101f1e00 100644
--- a/editor/quick_open.cpp
+++ b/editor/quick_open.cpp
@@ -259,7 +259,7 @@ void EditorQuickOpen::_notification(int p_what) {
connect("confirmed", this, "_confirmed");
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
}
}
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index ae135465fb..e1bb622ea4 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -862,7 +862,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->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(get_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
EditorNode::get_singleton()->get_editor_selection()->connect("selection_changed", this, "_selection_changed");
@@ -911,7 +911,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->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ filter->set_right_icon(get_icon("Search", "EditorIcons"));
filter->set_clear_button_enabled(true);
} break;
case NOTIFICATION_PROCESS: {
diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp
index 67bd074f0f..4ebba73cb3 100644
--- a/editor/settings_config_dialog.cpp
+++ b/editor/settings_config_dialog.cpp
@@ -182,9 +182,9 @@ void EditorSettingsDialog::_unhandled_input(const Ref<InputEvent> &p_event) {
void EditorSettingsDialog::_update_icons() {
- search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ search_box->set_right_icon(get_icon("Search", "EditorIcons"));
search_box->set_clear_button_enabled(true);
- shortcut_search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons"));
+ shortcut_search_box->set_right_icon(get_icon("Search", "EditorIcons"));
shortcut_search_box->set_clear_button_enabled(true);
restart_close_button->set_icon(get_icon("Close", "EditorIcons"));
diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp
index da4a969dcd..45a27d1e79 100644
--- a/modules/visual_script/visual_script_editor.cpp
+++ b/modules/visual_script/visual_script_editor.cpp
@@ -3032,7 +3032,7 @@ void VisualScriptEditor::_node_filter_changed(const String &p_text) {
void VisualScriptEditor::_notification(int p_what) {
if (p_what == NOTIFICATION_READY) {
- node_filter->add_icon_override("right_icon", Control::get_icon("Search", "EditorIcons"));
+ node_filter->set_right_icon(Control::get_icon("Search", "EditorIcons"));
node_filter->set_clear_button_enabled(true);
variable_editor->connect("changed", this, "_update_members");
signal_editor->connect("changed", this, "_update_members");
diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp
index e723262c85..549daecdae 100644
--- a/scene/gui/line_edit.cpp
+++ b/scene/gui/line_edit.cpp
@@ -700,8 +700,8 @@ void LineEdit::_notification(int p_what) {
font_color.a *= disabled_alpha;
bool display_clear_icon = !using_placeholder && is_editable() && clear_button_enabled;
- if (has_icon("right_icon") || display_clear_icon) {
- Ref<Texture> r_icon = Control::get_icon(display_clear_icon ? "clear" : "right_icon");
+ if (right_icon.is_valid() || display_clear_icon) {
+ Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon;
Color color_icon(1, 1, 1, disabled_alpha * .9);
if (display_clear_icon) {
if (clear_button_status.press_attempt && clear_button_status.pressing_inside) {
@@ -1154,9 +1154,8 @@ void LineEdit::set_cursor_position(int p_pos) {
} else if (cursor_pos > window_pos) {
/* Adjust window if cursor goes too much to the right */
int window_width = get_size().width - style->get_minimum_size().width;
- if (has_icon("right_icon")) {
- Ref<Texture> r_icon = Control::get_icon("right_icon");
- window_width -= r_icon->get_width();
+ if (right_icon.is_valid()) {
+ window_width -= right_icon->get_width();
}
if (window_width < 0)
@@ -1455,6 +1454,14 @@ bool LineEdit::is_clear_button_enabled() const {
return clear_button_enabled;
}
+void LineEdit::set_right_icon(const Ref<Texture> &p_icon) {
+ if (right_icon == p_icon) {
+ return;
+ }
+ right_icon = p_icon;
+ update();
+}
+
void LineEdit::_ime_text_callback(void *p_self, String p_text, Point2 p_selection) {
LineEdit *self = (LineEdit *)p_self;
self->ime_text = p_text;
diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h
index d3cdb41903..5294d99da0 100644
--- a/scene/gui/line_edit.h
+++ b/scene/gui/line_edit.h
@@ -89,6 +89,8 @@ private:
bool clear_button_enabled;
+ Ref<Texture> right_icon;
+
struct Selection {
int begin;
@@ -215,6 +217,8 @@ public:
void set_clear_button_enabled(bool p_enabled);
bool is_clear_button_enabled() const;
+ void set_right_icon(const Ref<Texture> &p_icon);
+
virtual bool is_text_field() const;
LineEdit();
~LineEdit();