Do not use theme to set LineEdit right_icon
This commit is contained in:
parent
e8a435c8cd
commit
81fb81de9d
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: {
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue