diff options
author | kobewi <kobewi4e@gmail.com> | 2023-12-18 15:46:56 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2024-01-09 16:11:47 +0100 |
commit | 0e8f90f4c8b4b353d3ac372e5f00493a2f0bd136 (patch) | |
tree | 9b83683d86b94f9fdf7d6d58594d2b28d88a13ab /scene/gui | |
parent | 8297ec949bad8029372da13e1d4e36599989b5ae (diff) | |
download | redot-engine-0e8f90f4c8b4b353d3ac372e5f00493a2f0bd136.tar.gz |
Update deferred calls to use Callables
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/color_picker.cpp | 2 | ||||
-rw-r--r-- | scene/gui/container.cpp | 3 | ||||
-rw-r--r-- | scene/gui/control.cpp | 3 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 2 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 11 | ||||
-rw-r--r-- | scene/gui/popup.cpp | 2 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 4 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 4 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 4 | ||||
-rw-r--r-- | scene/gui/tab_bar.cpp | 1 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 31 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 4 |
12 files changed, 25 insertions, 46 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 2f4a31130e..9d24595916 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -219,7 +219,7 @@ void ColorPicker::finish_shaders() { } void ColorPicker::set_focus_on_line_edit() { - c_text->call_deferred(SNAME("grab_focus")); + callable_mp((Control *)c_text, &Control::grab_focus).call_deferred(); } void ColorPicker::_update_controls() { diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index 4e23db4cae..c6e66c95c6 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -30,7 +30,6 @@ #include "container.h" -#include "core/object/message_queue.h" #include "scene/scene_string_names.h" void Container::_child_minsize_changed() { @@ -138,7 +137,7 @@ void Container::queue_sort() { return; } - MessageQueue::get_singleton()->push_callable(callable_mp(this, &Container::_sort_children)); + callable_mp(this, &Container::_sort_children).call_deferred(); pending_sort = true; } diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index a211227990..349102fafb 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -33,7 +33,6 @@ #include "container.h" #include "core/config/project_settings.h" #include "core/math/geometry_2d.h" -#include "core/object/message_queue.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/print_string.h" @@ -1631,7 +1630,7 @@ void Control::update_minimum_size() { } data.updating_last_minimum_size = true; - MessageQueue::get_singleton()->push_callable(callable_mp(this, &Control::_update_minimum_size)); + callable_mp(this, &Control::_update_minimum_size).call_deferred(); } void Control::set_block_minimum_size_adjust(bool p_block) { diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 3e827e76dc..8339d34f83 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -129,7 +129,7 @@ void AcceptDialog::_cancel_pressed() { parent_visible = nullptr; } - call_deferred(SNAME("hide")); + callable_mp((Window *)this, &Window::hide).call_deferred(); emit_signal(SNAME("canceled")); diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 7d34358af2..d11c4813b2 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -31,7 +31,6 @@ #include "line_edit.h" #include "core/input/input_map.h" -#include "core/object/message_queue.h" #include "core/os/keyboard.h" #include "core/os/os.h" #include "core/string/print_string.h" @@ -270,7 +269,7 @@ void LineEdit::gui_input(const Ref<InputEvent> &p_event) { if (!text_changed_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_text_changed"); + callable_mp(this, &LineEdit::_text_changed).call_deferred(); } text_changed_dirty = true; } @@ -714,7 +713,7 @@ void LineEdit::drop_data(const Point2 &p_point, const Variant &p_data) { select(caret_column_tmp, caret_column); if (!text_changed_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_text_changed"); + callable_mp(this, &LineEdit::_text_changed).call_deferred(); } text_changed_dirty = true; } @@ -1190,7 +1189,7 @@ void LineEdit::paste_text() { if (!text_changed_dirty) { if (is_inside_tree() && text.length() != prev_len) { - MessageQueue::get_singleton()->push_call(this, "_text_changed"); + callable_mp(this, &LineEdit::_text_changed).call_deferred(); } text_changed_dirty = true; } @@ -1504,7 +1503,7 @@ void LineEdit::delete_text(int p_from_column, int p_to_column) { if (!text_changed_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_text_changed"); + callable_mp(this, &LineEdit::_text_changed).call_deferred(); } text_changed_dirty = true; } @@ -2512,8 +2511,6 @@ void LineEdit::_validate_property(PropertyInfo &p_property) const { } void LineEdit::_bind_methods() { - ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed); - ClassDB::bind_method(D_METHOD("set_horizontal_alignment", "alignment"), &LineEdit::set_horizontal_alignment); ClassDB::bind_method(D_METHOD("get_horizontal_alignment"), &LineEdit::get_horizontal_alignment); diff --git a/scene/gui/popup.cpp b/scene/gui/popup.cpp index 8369bedda9..0c5a882044 100644 --- a/scene/gui/popup.cpp +++ b/scene/gui/popup.cpp @@ -123,7 +123,7 @@ void Popup::_close_pressed() { _deinitialize_visible_parents(); - call_deferred(SNAME("hide")); + callable_mp((Window *)this, &Window::hide).call_deferred(); } void Popup::_post_popup() { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 2d5a32dfdd..c5d1a6cd3c 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -2805,7 +2805,7 @@ void RichTextLabel::_thread_function(void *p_userdata) { set_current_thread_safe_for_nodes(true); _process_line_caches(); updating.store(false); - call_deferred(SNAME("thread_end")); + callable_mp(this, &RichTextLabel::_thread_end).call_deferred(); } void RichTextLabel::_thread_end() { @@ -5945,8 +5945,6 @@ void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("is_menu_visible"), &RichTextLabel::is_menu_visible); ClassDB::bind_method(D_METHOD("menu_option", "option"), &RichTextLabel::menu_option); - ClassDB::bind_method(D_METHOD("_thread_end"), &RichTextLabel::_thread_end); - #ifndef DISABLE_DEPRECATED ClassDB::bind_compatibility_method(D_METHOD("push_font", "font", "font_size"), &RichTextLabel::push_font); ClassDB::bind_compatibility_method(D_METHOD("set_table_column_expand", "column", "expand", "ratio"), &RichTextLabel::set_table_column_expand); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index b4e28a1f1b..89d308de3f 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -346,7 +346,7 @@ void ScrollContainer::_notification(int p_what) { case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: case NOTIFICATION_TRANSLATION_CHANGED: { _updating_scrollbars = true; - call_deferred(SNAME("_update_scrollbar_position")); + callable_mp(this, &ScrollContainer::_update_scrollbar_position).call_deferred(); } break; case NOTIFICATION_READY: { @@ -573,8 +573,6 @@ VScrollBar *ScrollContainer::get_v_scroll_bar() { } void ScrollContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position); - ClassDB::bind_method(D_METHOD("set_h_scroll", "value"), &ScrollContainer::set_h_scroll); ClassDB::bind_method(D_METHOD("get_h_scroll"), &ScrollContainer::get_h_scroll); diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index bd549a6e4a..d482495ca0 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -280,8 +280,8 @@ void SpinBox::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { - call_deferred(SNAME("update_minimum_size")); - get_line_edit()->call_deferred(SNAME("update_minimum_size")); + callable_mp((Control *)this, &Control::update_minimum_size).call_deferred(); + callable_mp((Control *)get_line_edit(), &Control::update_minimum_size).call_deferred(); } break; case NOTIFICATION_LAYOUT_DIRECTION_CHANGED: { diff --git a/scene/gui/tab_bar.cpp b/scene/gui/tab_bar.cpp index 90a6626b74..c153f8bd7d 100644 --- a/scene/gui/tab_bar.cpp +++ b/scene/gui/tab_bar.cpp @@ -30,7 +30,6 @@ #include "tab_bar.h" -#include "core/object/message_queue.h" #include "core/string/translation.h" #include "scene/gui/box_container.h" #include "scene/gui/label.h" diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index fe35669311..540c999131 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -33,7 +33,6 @@ #include "core/config/project_settings.h" #include "core/input/input.h" #include "core/input/input_map.h" -#include "core/object/message_queue.h" #include "core/object/script_language.h" #include "core/os/keyboard.h" #include "core/os/os.h" @@ -428,10 +427,10 @@ void TextEdit::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { _update_caches(); if (caret_pos_dirty) { - MessageQueue::get_singleton()->push_call(this, "_emit_caret_changed"); + callable_mp(this, &TextEdit::_emit_caret_changed).call_deferred(); } if (text_changed_dirty) { - MessageQueue::get_singleton()->push_call(this, "_text_changed_emit"); + callable_mp(this, &TextEdit::_text_changed_emit).call_deferred(); } _update_wrap_at_column(true); } break; @@ -443,8 +442,8 @@ void TextEdit::_notification(int p_what) { case NOTIFICATION_VISIBILITY_CHANGED: { if (is_visible()) { - call_deferred(SNAME("_update_scrollbars")); - call_deferred(SNAME("_update_wrap_at_column")); + callable_mp(this, &TextEdit::_update_scrollbars).call_deferred(); + callable_mp(this, &TextEdit::_update_wrap_at_column).call_deferred(false); } } break; @@ -4008,7 +4007,7 @@ void TextEdit::undo() { if (dirty_carets && !caret_pos_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_emit_caret_changed"); + callable_mp(this, &TextEdit::_emit_caret_changed).call_deferred(); } caret_pos_dirty = true; } @@ -4063,7 +4062,7 @@ void TextEdit::redo() { if (dirty_carets && !caret_pos_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_emit_caret_changed"); + callable_mp(this, &TextEdit::_emit_caret_changed).call_deferred(); } caret_pos_dirty = true; } @@ -4869,7 +4868,7 @@ void TextEdit::set_caret_line(int p_line, bool p_adjust_viewport, bool p_can_be_ if (caret_moved && !caret_pos_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_emit_caret_changed"); + callable_mp(this, &TextEdit::_emit_caret_changed).call_deferred(); } caret_pos_dirty = true; } @@ -4900,7 +4899,7 @@ void TextEdit::set_caret_column(int p_col, bool p_adjust_viewport, int p_caret) if (caret_moved && !caret_pos_dirty) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_emit_caret_changed"); + callable_mp(this, &TextEdit::_emit_caret_changed).call_deferred(); } caret_pos_dirty = true; } @@ -6027,10 +6026,6 @@ Color TextEdit::get_font_color() const { } void TextEdit::_bind_methods() { - /* Internal. */ - - ClassDB::bind_method(D_METHOD("_text_changed_emit"), &TextEdit::_text_changed_emit); - /* Text */ // Text properties ClassDB::bind_method(D_METHOD("has_ime_text"), &TextEdit::has_ime_text); @@ -6201,9 +6196,6 @@ void TextEdit::_bind_methods() { BIND_ENUM_CONSTANT(CARET_TYPE_LINE); BIND_ENUM_CONSTANT(CARET_TYPE_BLOCK); - // Internal. - ClassDB::bind_method(D_METHOD("_emit_caret_changed"), &TextEdit::_emit_caret_changed); - ClassDB::bind_method(D_METHOD("set_caret_type", "type"), &TextEdit::set_caret_type); ClassDB::bind_method(D_METHOD("get_caret_type"), &TextEdit::get_caret_type); @@ -6291,9 +6283,6 @@ void TextEdit::_bind_methods() { BIND_ENUM_CONSTANT(LINE_WRAPPING_NONE); BIND_ENUM_CONSTANT(LINE_WRAPPING_BOUNDARY); - // Internal. - ClassDB::bind_method(D_METHOD("_update_wrap_at_column", "force"), &TextEdit::_update_wrap_at_column, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("set_line_wrapping_mode", "mode"), &TextEdit::set_line_wrapping_mode); ClassDB::bind_method(D_METHOD("get_line_wrapping_mode"), &TextEdit::get_line_wrapping_mode); @@ -7827,7 +7816,7 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i if (!text_changed_dirty && !setting_text) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_text_changed_emit"); + callable_mp(this, &TextEdit::_text_changed_emit).call_deferred(); } text_changed_dirty = true; } @@ -7873,7 +7862,7 @@ void TextEdit::_base_remove_text(int p_from_line, int p_from_column, int p_to_li if (!text_changed_dirty && !setting_text) { if (is_inside_tree()) { - MessageQueue::get_singleton()->push_call(this, "_text_changed_emit"); + callable_mp(this, &TextEdit::_text_changed_emit).call_deferred(); } text_changed_dirty = true; } diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 6936bcb441..c67c3cd98d 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -4784,7 +4784,7 @@ void Tree::ensure_cursor_is_visible() { if (cell_h > screen_h) { // Screen size is too small, maybe it was not resized yet. v_scroll->set_value(y_offset); } else if (y_offset + cell_h > v_scroll->get_value() + screen_h) { - v_scroll->call_deferred(SNAME("set_value"), y_offset - screen_h + cell_h); + callable_mp((Range *)v_scroll, &Range::set_value).call_deferred(y_offset - screen_h + cell_h); } else if (y_offset < v_scroll->get_value()) { v_scroll->set_value(y_offset); } @@ -4802,7 +4802,7 @@ void Tree::ensure_cursor_is_visible() { if (cell_w > screen_w) { h_scroll->set_value(x_offset); } else if (x_offset + cell_w > h_scroll->get_value() + screen_w) { - h_scroll->call_deferred(SNAME("set_value"), x_offset - screen_w + cell_w); + callable_mp((Range *)h_scroll, &Range::set_value).call_deferred(x_offset - screen_w + cell_w); } else if (x_offset < h_scroll->get_value()) { h_scroll->set_value(x_offset); } |