diff options
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/color_picker.cpp | 67 | ||||
-rw-r--r-- | scene/gui/container.cpp | 13 | ||||
-rw-r--r-- | scene/gui/control.cpp | 41 | ||||
-rw-r--r-- | scene/gui/dialogs.cpp | 27 | ||||
-rw-r--r-- | scene/gui/dialogs.h | 11 | ||||
-rw-r--r-- | scene/gui/file_dialog.cpp | 75 | ||||
-rw-r--r-- | scene/gui/file_dialog.h | 2 | ||||
-rw-r--r-- | scene/gui/gradient_edit.cpp | 7 | ||||
-rw-r--r-- | scene/gui/graph_edit.cpp | 51 | ||||
-rw-r--r-- | scene/gui/item_list.cpp | 3 | ||||
-rw-r--r-- | scene/gui/line_edit.cpp | 19 | ||||
-rw-r--r-- | scene/gui/menu_button.cpp | 5 | ||||
-rw-r--r-- | scene/gui/option_button.cpp | 10 | ||||
-rw-r--r-- | scene/gui/popup_menu.cpp | 11 | ||||
-rw-r--r-- | scene/gui/rich_text_label.cpp | 5 | ||||
-rw-r--r-- | scene/gui/scroll_bar.cpp | 20 | ||||
-rw-r--r-- | scene/gui/scroll_container.cpp | 8 | ||||
-rw-r--r-- | scene/gui/spin_box.cpp | 12 | ||||
-rw-r--r-- | scene/gui/tab_container.cpp | 10 | ||||
-rw-r--r-- | scene/gui/tabs.cpp | 3 | ||||
-rw-r--r-- | scene/gui/text_edit.cpp | 187 | ||||
-rw-r--r-- | scene/gui/text_edit.h | 11 | ||||
-rw-r--r-- | scene/gui/texture_rect.cpp | 5 | ||||
-rw-r--r-- | scene/gui/tree.cpp | 22 |
24 files changed, 299 insertions, 326 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index cb71128424..cbbad79811 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -615,7 +615,7 @@ void ColorPicker::_screen_pick_pressed() { screen->set_as_toplevel(true); screen->set_anchors_and_margins_preset(Control::PRESET_WIDE); screen->set_default_cursor_shape(CURSOR_POINTING_HAND); - screen->connect_compat("gui_input", this, "_screen_input"); + screen->connect("gui_input", callable_mp(this, &ColorPicker::_screen_input)); // It immediately toggles off in the first press otherwise. screen->call_deferred("connect", "hide", Callable(btn_pick, "set_pressed"), varray(false)); } @@ -678,9 +678,9 @@ void ColorPicker::_bind_methods() { ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPicker::set_pick_color); ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPicker::get_pick_color); - ClassDB::bind_method(D_METHOD("set_hsv_mode", "mode"), &ColorPicker::set_hsv_mode); + ClassDB::bind_method(D_METHOD("set_hsv_mode"), &ColorPicker::set_hsv_mode); ClassDB::bind_method(D_METHOD("is_hsv_mode"), &ColorPicker::is_hsv_mode); - ClassDB::bind_method(D_METHOD("set_raw_mode", "mode"), &ColorPicker::set_raw_mode); + ClassDB::bind_method(D_METHOD("set_raw_mode"), &ColorPicker::set_raw_mode); ClassDB::bind_method(D_METHOD("is_raw_mode"), &ColorPicker::is_raw_mode); ClassDB::bind_method(D_METHOD("set_deferred_mode", "mode"), &ColorPicker::set_deferred_mode); ClassDB::bind_method(D_METHOD("is_deferred_mode"), &ColorPicker::is_deferred_mode); @@ -693,21 +693,6 @@ void ColorPicker::_bind_methods() { ClassDB::bind_method(D_METHOD("add_preset", "color"), &ColorPicker::add_preset); ClassDB::bind_method(D_METHOD("erase_preset", "color"), &ColorPicker::erase_preset); ClassDB::bind_method(D_METHOD("get_presets"), &ColorPicker::get_presets); - ClassDB::bind_method(D_METHOD("_value_changed"), &ColorPicker::_value_changed); - ClassDB::bind_method(D_METHOD("_html_entered"), &ColorPicker::_html_entered); - ClassDB::bind_method(D_METHOD("_text_type_toggled"), &ColorPicker::_text_type_toggled); - ClassDB::bind_method(D_METHOD("_add_preset_pressed"), &ColorPicker::_add_preset_pressed); - ClassDB::bind_method(D_METHOD("_screen_pick_pressed"), &ColorPicker::_screen_pick_pressed); - ClassDB::bind_method(D_METHOD("_sample_draw"), &ColorPicker::_sample_draw); - ClassDB::bind_method(D_METHOD("_update_presets"), &ColorPicker::_update_presets); - ClassDB::bind_method(D_METHOD("_hsv_draw"), &ColorPicker::_hsv_draw); - ClassDB::bind_method(D_METHOD("_uv_input"), &ColorPicker::_uv_input); - ClassDB::bind_method(D_METHOD("_w_input"), &ColorPicker::_w_input); - ClassDB::bind_method(D_METHOD("_preset_input"), &ColorPicker::_preset_input); - ClassDB::bind_method(D_METHOD("_screen_input"), &ColorPicker::_screen_input); - ClassDB::bind_method(D_METHOD("_focus_enter"), &ColorPicker::_focus_enter); - ClassDB::bind_method(D_METHOD("_focus_exit"), &ColorPicker::_focus_exit); - ClassDB::bind_method(D_METHOD("_html_focus_exit"), &ColorPicker::_html_focus_exit); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "color"), "set_pick_color", "get_pick_color"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "edit_alpha"), "set_edit_alpha", "is_editing_alpha"); @@ -742,20 +727,20 @@ ColorPicker::ColorPicker() : uv_edit = memnew(Control); hb_edit->add_child(uv_edit); - uv_edit->connect_compat("gui_input", this, "_uv_input"); + uv_edit->connect("gui_input", callable_mp(this, &ColorPicker::_uv_input)); uv_edit->set_mouse_filter(MOUSE_FILTER_PASS); uv_edit->set_h_size_flags(SIZE_EXPAND_FILL); uv_edit->set_v_size_flags(SIZE_EXPAND_FILL); uv_edit->set_custom_minimum_size(Size2(get_constant("sv_width"), get_constant("sv_height"))); - uv_edit->connect_compat("draw", this, "_hsv_draw", make_binds(0, uv_edit)); + uv_edit->connect("draw", callable_mp(this, &ColorPicker::_hsv_draw), make_binds(0, uv_edit)); w_edit = memnew(Control); hb_edit->add_child(w_edit); w_edit->set_custom_minimum_size(Size2(get_constant("h_width"), 0)); w_edit->set_h_size_flags(SIZE_FILL); w_edit->set_v_size_flags(SIZE_EXPAND_FILL); - w_edit->connect_compat("gui_input", this, "_w_input"); - w_edit->connect_compat("draw", this, "_hsv_draw", make_binds(1, w_edit)); + w_edit->connect("gui_input", callable_mp(this, &ColorPicker::_w_input)); + w_edit->connect("draw", callable_mp(this, &ColorPicker::_hsv_draw), make_binds(1, w_edit)); HBoxContainer *hb_smpl = memnew(HBoxContainer); add_child(hb_smpl); @@ -763,13 +748,13 @@ ColorPicker::ColorPicker() : sample = memnew(TextureRect); hb_smpl->add_child(sample); sample->set_h_size_flags(SIZE_EXPAND_FILL); - sample->connect_compat("draw", this, "_sample_draw"); + sample->connect("draw", callable_mp(this, &ColorPicker::_sample_draw)); btn_pick = memnew(ToolButton); hb_smpl->add_child(btn_pick); btn_pick->set_toggle_mode(true); btn_pick->set_tooltip(TTR("Pick a color from the editor window.")); - btn_pick->connect_compat("pressed", this, "_screen_pick_pressed"); + btn_pick->connect("pressed", callable_mp(this, &ColorPicker::_screen_pick_pressed)); VBoxContainer *vbl = memnew(VBoxContainer); add_child(vbl); @@ -797,14 +782,14 @@ ColorPicker::ColorPicker() : values[i] = memnew(SpinBox); scroll[i]->share(values[i]); hbc->add_child(values[i]); - values[i]->get_line_edit()->connect_compat("focus_entered", this, "_focus_enter"); - values[i]->get_line_edit()->connect_compat("focus_exited", this, "_focus_exit"); + values[i]->get_line_edit()->connect("focus_entered", callable_mp(this, &ColorPicker::_focus_enter)); + values[i]->get_line_edit()->connect("focus_exited", callable_mp(this, &ColorPicker::_focus_exit)); scroll[i]->set_min(0); scroll[i]->set_page(0); scroll[i]->set_h_size_flags(SIZE_EXPAND_FILL); - scroll[i]->connect_compat("value_changed", this, "_value_changed"); + scroll[i]->connect("value_changed", callable_mp(this, &ColorPicker::_value_changed)); vbr->add_child(hbc); } @@ -816,12 +801,12 @@ ColorPicker::ColorPicker() : btn_hsv = memnew(CheckButton); hhb->add_child(btn_hsv); btn_hsv->set_text(TTR("HSV")); - btn_hsv->connect_compat("toggled", this, "set_hsv_mode"); + btn_hsv->connect("toggled", callable_mp(this, &ColorPicker::set_hsv_mode)); btn_raw = memnew(CheckButton); hhb->add_child(btn_raw); btn_raw->set_text(TTR("Raw")); - btn_raw->connect_compat("toggled", this, "set_raw_mode"); + btn_raw->connect("toggled", callable_mp(this, &ColorPicker::set_raw_mode)); text_type = memnew(Button); hhb->add_child(text_type); @@ -832,7 +817,7 @@ ColorPicker::ColorPicker() : #ifdef TOOLS_ENABLED text_type->set_custom_minimum_size(Size2(28 * EDSCALE, 0)); // Adjust for the width of the "Script" icon. #endif - text_type->connect_compat("pressed", this, "_text_type_toggled"); + text_type->connect("pressed", callable_mp(this, &ColorPicker::_text_type_toggled)); } else { text_type->set_flat(true); @@ -842,9 +827,9 @@ ColorPicker::ColorPicker() : c_text = memnew(LineEdit); hhb->add_child(c_text); c_text->set_h_size_flags(SIZE_EXPAND_FILL); - c_text->connect_compat("text_entered", this, "_html_entered"); - c_text->connect_compat("focus_entered", this, "_focus_enter"); - c_text->connect_compat("focus_exited", this, "_html_focus_exit"); + c_text->connect("text_entered", callable_mp(this, &ColorPicker::_html_entered)); + c_text->connect("focus_entered", callable_mp(this, &ColorPicker::_focus_enter)); + c_text->connect("focus_exited", callable_mp(this, &ColorPicker::_html_focus_exit)); _update_controls(); updating = false; @@ -860,8 +845,8 @@ ColorPicker::ColorPicker() : preset = memnew(TextureRect); preset_container->add_child(preset); - preset->connect_compat("gui_input", this, "_preset_input"); - preset->connect_compat("draw", this, "_update_presets"); + preset->connect("gui_input", callable_mp(this, &ColorPicker::_preset_input)); + preset->connect("draw", callable_mp(this, &ColorPicker::_update_presets)); preset_container2 = memnew(HBoxContainer); preset_container2->set_h_size_flags(SIZE_EXPAND_FILL); @@ -869,7 +854,7 @@ ColorPicker::ColorPicker() : bt_add_preset = memnew(Button); preset_container2->add_child(bt_add_preset); bt_add_preset->set_tooltip(TTR("Add current color as a preset.")); - bt_add_preset->connect_compat("pressed", this, "_add_preset_pressed"); + bt_add_preset->connect("pressed", callable_mp(this, &ColorPicker::_add_preset_pressed)); } ///////////////// @@ -969,10 +954,10 @@ void ColorPickerButton::_update_picker() { picker = memnew(ColorPicker); popup->add_child(picker); add_child(popup); - picker->connect_compat("color_changed", this, "_color_changed"); - popup->connect_compat("modal_closed", this, "_modal_closed"); - popup->connect_compat("about_to_show", this, "set_pressed", varray(true)); - popup->connect_compat("popup_hide", this, "set_pressed", varray(false)); + picker->connect("color_changed", callable_mp(this, &ColorPickerButton::_color_changed)); + popup->connect("modal_closed", callable_mp(this, &ColorPickerButton::_modal_closed)); + popup->connect("about_to_show", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true)); + popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false)); picker->set_pick_color(color); picker->set_edit_alpha(edit_alpha); emit_signal("picker_created"); @@ -987,8 +972,6 @@ void ColorPickerButton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_popup"), &ColorPickerButton::get_popup); ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPickerButton::set_edit_alpha); ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPickerButton::is_editing_alpha); - ClassDB::bind_method(D_METHOD("_color_changed"), &ColorPickerButton::_color_changed); - ClassDB::bind_method(D_METHOD("_modal_closed"), &ColorPickerButton::_modal_closed); ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color"))); ADD_SIGNAL(MethodInfo("popup_closed")); diff --git a/scene/gui/container.cpp b/scene/gui/container.cpp index f6ce0c9a60..41f33bb719 100644 --- a/scene/gui/container.cpp +++ b/scene/gui/container.cpp @@ -48,9 +48,9 @@ void Container::add_child_notify(Node *p_child) { if (!control) return; - control->connect_compat("size_flags_changed", this, "queue_sort"); - control->connect_compat("minimum_size_changed", this, "_child_minsize_changed"); - control->connect_compat("visibility_changed", this, "_child_minsize_changed"); + control->connect("size_flags_changed", callable_mp(this, &Container::queue_sort)); + control->connect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed)); + control->connect("visibility_changed", callable_mp(this, &Container::_child_minsize_changed)); minimum_size_changed(); queue_sort(); @@ -75,9 +75,9 @@ void Container::remove_child_notify(Node *p_child) { if (!control) return; - control->disconnect_compat("size_flags_changed", this, "queue_sort"); - control->disconnect_compat("minimum_size_changed", this, "_child_minsize_changed"); - control->disconnect_compat("visibility_changed", this, "_child_minsize_changed"); + control->disconnect("size_flags_changed", callable_mp(this, &Container::queue_sort)); + control->disconnect("minimum_size_changed", callable_mp(this, &Container::_child_minsize_changed)); + control->disconnect("visibility_changed", callable_mp(this, &Container::_child_minsize_changed)); minimum_size_changed(); queue_sort(); @@ -185,7 +185,6 @@ String Container::get_configuration_warning() const { void Container::_bind_methods() { ClassDB::bind_method(D_METHOD("_sort_children"), &Container::_sort_children); - ClassDB::bind_method(D_METHOD("_child_minsize_changed"), &Container::_child_minsize_changed); ClassDB::bind_method(D_METHOD("queue_sort"), &Container::queue_sort); ClassDB::bind_method(D_METHOD("fit_child_in_rect", "child", "rect"), &Container::fit_child_in_rect); diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index d3027b606d..1a231e368b 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -221,28 +221,28 @@ bool Control::_set(const StringName &p_name, const Variant &p_value) { if (name.begins_with("custom_icons/")) { String dname = name.get_slicec('/', 1); if (data.icon_override.has(dname)) { - data.icon_override[dname]->disconnect_compat("changed", this, "_override_changed"); + data.icon_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.icon_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_shaders/")) { String dname = name.get_slicec('/', 1); if (data.shader_override.has(dname)) { - data.shader_override[dname]->disconnect_compat("changed", this, "_override_changed"); + data.shader_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.shader_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_styles/")) { String dname = name.get_slicec('/', 1); if (data.style_override.has(dname)) { - data.style_override[dname]->disconnect_compat("changed", this, "_override_changed"); + data.style_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.style_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); } else if (name.begins_with("custom_fonts/")) { String dname = name.get_slicec('/', 1); if (data.font_override.has(dname)) { - data.font_override[dname]->disconnect_compat("changed", this, "_override_changed"); + data.font_override[dname]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } data.font_override.erase(dname); notification(NOTIFICATION_THEME_CHANGED); @@ -542,10 +542,10 @@ void Control::_notification(int p_notification) { if (data.parent_canvas_item) { - data.parent_canvas_item->connect_compat("item_rect_changed", this, "_size_changed"); + data.parent_canvas_item->connect("item_rect_changed", callable_mp(this, &Control::_size_changed)); } else { //connect viewport - get_viewport()->connect_compat("size_changed", this, "_size_changed"); + get_viewport()->connect("size_changed", callable_mp(this, &Control::_size_changed)); } } @@ -561,11 +561,11 @@ void Control::_notification(int p_notification) { if (data.parent_canvas_item) { - data.parent_canvas_item->disconnect_compat("item_rect_changed", this, "_size_changed"); + data.parent_canvas_item->disconnect("item_rect_changed", callable_mp(this, &Control::_size_changed)); data.parent_canvas_item = NULL; } else if (!is_set_as_toplevel()) { //disconnect viewport - get_viewport()->disconnect_compat("size_changed", this, "_size_changed"); + get_viewport()->disconnect("size_changed", callable_mp(this, &Control::_size_changed)); } if (data.MI) { @@ -1883,7 +1883,7 @@ Rect2 Control::get_anchorable_rect() const { void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> &p_icon) { if (data.icon_override.has(p_name)) { - data.icon_override[p_name]->disconnect_compat("changed", this, "_override_changed"); + data.icon_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } // clear if "null" is passed instead of a icon @@ -1892,7 +1892,7 @@ void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> & } else { data.icon_override[p_name] = p_icon; if (data.icon_override[p_name].is_valid()) { - data.icon_override[p_name]->connect_compat("changed", this, "_override_changed", Vector<Variant>(), CONNECT_REFERENCE_COUNTED); + data.icon_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED); } } notification(NOTIFICATION_THEME_CHANGED); @@ -1901,7 +1901,7 @@ void Control::add_icon_override(const StringName &p_name, const Ref<Texture2D> & void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p_shader) { if (data.shader_override.has(p_name)) { - data.shader_override[p_name]->disconnect_compat("changed", this, "_override_changed"); + data.shader_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } // clear if "null" is passed instead of a shader @@ -1910,7 +1910,7 @@ void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p } else { data.shader_override[p_name] = p_shader; if (data.shader_override[p_name].is_valid()) { - data.shader_override[p_name]->connect_compat("changed", this, "_override_changed", Vector<Variant>(), CONNECT_REFERENCE_COUNTED); + data.shader_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED); } } notification(NOTIFICATION_THEME_CHANGED); @@ -1918,7 +1918,7 @@ void Control::add_shader_override(const StringName &p_name, const Ref<Shader> &p void Control::add_style_override(const StringName &p_name, const Ref<StyleBox> &p_style) { if (data.style_override.has(p_name)) { - data.style_override[p_name]->disconnect_compat("changed", this, "_override_changed"); + data.style_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } // clear if "null" is passed instead of a style @@ -1927,7 +1927,7 @@ void Control::add_style_override(const StringName &p_name, const Ref<StyleBox> & } else { data.style_override[p_name] = p_style; if (data.style_override[p_name].is_valid()) { - data.style_override[p_name]->connect_compat("changed", this, "_override_changed", Vector<Variant>(), CONNECT_REFERENCE_COUNTED); + data.style_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED); } } notification(NOTIFICATION_THEME_CHANGED); @@ -1936,7 +1936,7 @@ void Control::add_style_override(const StringName &p_name, const Ref<StyleBox> & void Control::add_font_override(const StringName &p_name, const Ref<Font> &p_font) { if (data.font_override.has(p_name)) { - data.font_override[p_name]->disconnect_compat("changed", this, "_override_changed"); + data.font_override[p_name]->disconnect("changed", callable_mp(this, &Control::_override_changed)); } // clear if "null" is passed instead of a font @@ -1945,7 +1945,7 @@ void Control::add_font_override(const StringName &p_name, const Ref<Font> &p_fon } else { data.font_override[p_name] = p_font; if (data.font_override[p_name].is_valid()) { - data.font_override[p_name]->connect_compat("changed", this, "_override_changed", Vector<Variant>(), CONNECT_REFERENCE_COUNTED); + data.font_override[p_name]->connect("changed", callable_mp(this, &Control::_override_changed), Vector<Variant>(), CONNECT_REFERENCE_COUNTED); } } notification(NOTIFICATION_THEME_CHANGED); @@ -2262,7 +2262,7 @@ void Control::set_theme(const Ref<Theme> &p_theme) { return; if (data.theme.is_valid()) { - data.theme->disconnect_compat("changed", this, "_theme_changed"); + data.theme->disconnect("changed", callable_mp(this, &Control::_theme_changed)); } data.theme = p_theme; @@ -2282,7 +2282,7 @@ void Control::set_theme(const Ref<Theme> &p_theme) { } if (data.theme.is_valid()) { - data.theme->connect_compat("changed", this, "_theme_changed", varray(), CONNECT_DEFERRED); + data.theme->connect("changed", callable_mp(this, &Control::_theme_changed), varray(), CONNECT_DEFERRED); } } @@ -2813,7 +2813,6 @@ Control::GrowDirection Control::get_v_grow_direction() const { void Control::_bind_methods() { //ClassDB::bind_method(D_METHOD("_window_resize_event"),&Control::_window_resize_event); - ClassDB::bind_method(D_METHOD("_size_changed"), &Control::_size_changed); ClassDB::bind_method(D_METHOD("_update_minimum_size"), &Control::_update_minimum_size); ClassDB::bind_method(D_METHOD("accept_event"), &Control::accept_event); @@ -2942,10 +2941,6 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("minimum_size_changed"), &Control::minimum_size_changed); - ClassDB::bind_method(D_METHOD("_theme_changed"), &Control::_theme_changed); - - ClassDB::bind_method(D_METHOD("_override_changed"), &Control::_override_changed); - BIND_VMETHOD(MethodInfo("_gui_input", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent"))); BIND_VMETHOD(MethodInfo(Variant::VECTOR2, "_get_minimum_size")); diff --git a/scene/gui/dialogs.cpp b/scene/gui/dialogs.cpp index 152738420a..6cadd0a63e 100644 --- a/scene/gui/dialogs.cpp +++ b/scene/gui/dialogs.cpp @@ -247,8 +247,10 @@ void WindowDialog::_notification(int p_what) { } break; case NOTIFICATION_POPUP_HIDE: { - if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton() && !was_editor_dimmed) + if (get_tree() && Engine::get_singleton()->is_editor_hint() && EditorNode::get_singleton() && !was_editor_dimmed) { EditorNode::get_singleton()->dim_editor(false); + set_pass_on_modal_close_click(false); + } } break; #endif } @@ -334,7 +336,6 @@ void WindowDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("get_title"), &WindowDialog::get_title); ClassDB::bind_method(D_METHOD("set_resizable", "resizable"), &WindowDialog::set_resizable); ClassDB::bind_method(D_METHOD("get_resizable"), &WindowDialog::get_resizable); - ClassDB::bind_method(D_METHOD("_closed"), &WindowDialog::_closed); ClassDB::bind_method(D_METHOD("get_close_button"), &WindowDialog::get_close_button); ADD_PROPERTY(PropertyInfo(Variant::STRING, "window_title", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT_INTL), "set_title", "get_title"); @@ -347,7 +348,7 @@ WindowDialog::WindowDialog() { resizable = false; close_button = memnew(TextureButton); add_child(close_button); - close_button->connect_compat("pressed", this, "_closed"); + close_button->connect("pressed", callable_mp(this, &WindowDialog::_closed)); #ifdef TOOLS_ENABLED was_editor_dimmed = false; @@ -395,7 +396,7 @@ void AcceptDialog::_notification(int p_what) { } } -void AcceptDialog::_builtin_text_entered(const String &p_text) { +void AcceptDialog::_text_entered(const String &p_text) { _ok_pressed(); } @@ -407,11 +408,18 @@ void AcceptDialog::_ok_pressed() { ok_pressed(); emit_signal("confirmed"); } + void AcceptDialog::_close_pressed() { cancel_pressed(); } +// FIXME: This is redundant with _closed_pressed, but there's a slight behavior +// change (WindowDialog's _closed() also calls hide()) which should be assessed. +void AcceptDialog::_on_close_pressed() { + _closed(); // From WindowDialog. +} + String AcceptDialog::get_text() const { return label->get_text(); @@ -446,7 +454,7 @@ void AcceptDialog::register_text_enter(Node *p_line_edit) { ERR_FAIL_NULL(p_line_edit); LineEdit *line_edit = Object::cast_to<LineEdit>(p_line_edit); if (line_edit) - line_edit->connect_compat("text_entered", this, "_builtin_text_entered"); + line_edit->connect("text_entered", callable_mp(this, &AcceptDialog::_text_entered)); } void AcceptDialog::_update_child_rects() { @@ -531,7 +539,7 @@ Button *AcceptDialog::add_button(const String &p_text, bool p_right, const Strin } if (p_action != "") { - button->connect_compat("pressed", this, "_custom_action", varray(p_action)); + button->connect("pressed", callable_mp(this, &AcceptDialog::_custom_action), varray(p_action)); } return button; @@ -543,22 +551,19 @@ Button *AcceptDialog::add_cancel(const String &p_cancel) { if (p_cancel == "") c = RTR("Cancel"); Button *b = swap_ok_cancel ? add_button(c, true) : add_button(c); - b->connect_compat("pressed", this, "_closed"); + b->connect("pressed", callable_mp(this, &AcceptDialog::_on_close_pressed)); return b; } void AcceptDialog::_bind_methods() { - ClassDB::bind_method(D_METHOD("_ok"), &AcceptDialog::_ok_pressed); ClassDB::bind_method(D_METHOD("get_ok"), &AcceptDialog::get_ok); ClassDB::bind_method(D_METHOD("get_label"), &AcceptDialog::get_label); ClassDB::bind_method(D_METHOD("set_hide_on_ok", "enabled"), &AcceptDialog::set_hide_on_ok); ClassDB::bind_method(D_METHOD("get_hide_on_ok"), &AcceptDialog::get_hide_on_ok); ClassDB::bind_method(D_METHOD("add_button", "text", "right", "action"), &AcceptDialog::add_button, DEFVAL(false), DEFVAL("")); ClassDB::bind_method(D_METHOD("add_cancel", "name"), &AcceptDialog::add_cancel); - ClassDB::bind_method(D_METHOD("_builtin_text_entered"), &AcceptDialog::_builtin_text_entered); ClassDB::bind_method(D_METHOD("register_text_enter", "line_edit"), &AcceptDialog::register_text_enter); - ClassDB::bind_method(D_METHOD("_custom_action"), &AcceptDialog::_custom_action); ClassDB::bind_method(D_METHOD("set_text", "text"), &AcceptDialog::set_text); ClassDB::bind_method(D_METHOD("get_text"), &AcceptDialog::get_text); ClassDB::bind_method(D_METHOD("set_autowrap", "autowrap"), &AcceptDialog::set_autowrap); @@ -600,7 +605,7 @@ AcceptDialog::AcceptDialog() { hbc->add_child(ok); hbc->add_spacer(); - ok->connect_compat("pressed", this, "_ok"); + ok->connect("pressed", callable_mp(this, &AcceptDialog::_ok_pressed)); set_as_toplevel(true); hide_on_ok = true; diff --git a/scene/gui/dialogs.h b/scene/gui/dialogs.h index b6381e98b4..c474f7849d 100644 --- a/scene/gui/dialogs.h +++ b/scene/gui/dialogs.h @@ -64,7 +64,6 @@ class WindowDialog : public Popup { #endif void _gui_input(const Ref<InputEvent> &p_event); - void _closed(); int _drag_hit_test(const Point2 &pos) const; protected: @@ -75,6 +74,9 @@ protected: void _notification(int p_what); static void _bind_methods(); + // Not private since used by derived classes signal. + void _closed(); + public: TextureButton *get_close_button(); @@ -113,9 +115,7 @@ class AcceptDialog : public WindowDialog { bool hide_on_ok; void _custom_action(const String &p_action); - void _ok_pressed(); void _close_pressed(); - void _builtin_text_entered(const String &p_text); void _update_child_rects(); static bool swap_ok_cancel; @@ -128,6 +128,11 @@ protected: virtual void cancel_pressed() {} virtual void custom_action(const String &) {} + // Not private since used by derived classes signal. + void _text_entered(const String &p_text); + void _ok_pressed(); + void _on_close_pressed(); + public: Size2 get_minimum_size() const; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index e27e7d1490..3be77ff4b3 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -85,7 +85,7 @@ void FileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { bool handled = true; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_H: { @@ -135,7 +135,8 @@ Vector<String> FileDialog::get_selected_files() const { void FileDialog::update_dir() { - dir->set_text(dir_access->get_current_dir()); + dir->set_text(dir_access->get_current_dir(false)); + if (drives->is_visible()) { drives->select(dir_access->get_current_drive()); } @@ -789,6 +790,12 @@ void FileDialog::_update_drives() { drives->hide(); } else { drives->clear(); + Node *dp = drives->get_parent(); + if (dp) { + dp->remove_child(drives); + } + dp = dir_access->drives_are_shortcuts() ? shortcuts_container : drives_container; + dp->add_child(drives); drives->show(); for (int i = 0; i < dir_access->get_drive_count(); i++) { @@ -805,15 +812,7 @@ void FileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_unhandled_input"), &FileDialog::_unhandled_input); - ClassDB::bind_method(D_METHOD("_tree_multi_selected"), &FileDialog::_tree_multi_selected); - ClassDB::bind_method(D_METHOD("_tree_selected"), &FileDialog::_tree_selected); - ClassDB::bind_method(D_METHOD("_tree_item_activated"), &FileDialog::_tree_item_activated); - ClassDB::bind_method(D_METHOD("_dir_entered"), &FileDialog::_dir_entered); - ClassDB::bind_method(D_METHOD("_file_entered"), &FileDialog::_file_entered); - ClassDB::bind_method(D_METHOD("_action_pressed"), &FileDialog::_action_pressed); ClassDB::bind_method(D_METHOD("_cancel_pressed"), &FileDialog::_cancel_pressed); - ClassDB::bind_method(D_METHOD("_filter_selected"), &FileDialog::_filter_selected); - ClassDB::bind_method(D_METHOD("_save_confirm_pressed"), &FileDialog::_save_confirm_pressed); ClassDB::bind_method(D_METHOD("clear_filters"), &FileDialog::clear_filters); ClassDB::bind_method(D_METHOD("add_filter", "filter"), &FileDialog::add_filter); @@ -835,13 +834,9 @@ void FileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("get_access"), &FileDialog::get_access); ClassDB::bind_method(D_METHOD("set_show_hidden_files", "show"), &FileDialog::set_show_hidden_files); ClassDB::bind_method(D_METHOD("is_showing_hidden_files"), &FileDialog::is_showing_hidden_files); - ClassDB::bind_method(D_METHOD("_select_drive"), &FileDialog::_select_drive); - ClassDB::bind_method(D_METHOD("_make_dir"), &FileDialog::_make_dir); - ClassDB::bind_method(D_METHOD("_make_dir_confirm"), &FileDialog::_make_dir_confirm); ClassDB::bind_method(D_METHOD("_update_file_name"), &FileDialog::update_file_name); - ClassDB::bind_method(D_METHOD("_update_file_list"), &FileDialog::update_file_list); ClassDB::bind_method(D_METHOD("_update_dir"), &FileDialog::update_dir); - ClassDB::bind_method(D_METHOD("_go_up"), &FileDialog::_go_up); + ClassDB::bind_method(D_METHOD("_update_file_list"), &FileDialog::update_file_list); ClassDB::bind_method(D_METHOD("deselect_items"), &FileDialog::deselect_items); ClassDB::bind_method(D_METHOD("invalidate"), &FileDialog::invalidate); @@ -900,32 +895,38 @@ FileDialog::FileDialog() { dir_up = memnew(ToolButton); dir_up->set_tooltip(RTR("Go to parent folder.")); hbc->add_child(dir_up); - dir_up->connect_compat("pressed", this, "_go_up"); + dir_up->connect("pressed", callable_mp(this, &FileDialog::_go_up)); + + hbc->add_child(memnew(Label(RTR("Path:")))); + + drives_container = memnew(HBoxContainer); + hbc->add_child(drives_container); drives = memnew(OptionButton); - hbc->add_child(drives); - drives->connect_compat("item_selected", this, "_select_drive"); + drives->connect("item_selected", callable_mp(this, &FileDialog::_select_drive)); - hbc->add_child(memnew(Label(RTR("Path:")))); dir = memnew(LineEdit); hbc->add_child(dir); dir->set_h_size_flags(SIZE_EXPAND_FILL); refresh = memnew(ToolButton); refresh->set_tooltip(RTR("Refresh files.")); - refresh->connect_compat("pressed", this, "_update_file_list"); + refresh->connect("pressed", callable_mp(this, &FileDialog::update_file_list)); hbc->add_child(refresh); show_hidden = memnew(ToolButton); show_hidden->set_toggle_mode(true); show_hidden->set_pressed(is_showing_hidden_files()); show_hidden->set_tooltip(RTR("Toggle the visibility of hidden files.")); - show_hidden->connect_compat("toggled", this, "set_show_hidden_files"); + show_hidden->connect("toggled", callable_mp(this, &FileDialog::set_show_hidden_files)); hbc->add_child(show_hidden); + shortcuts_container = memnew(HBoxContainer); + hbc->add_child(shortcuts_container); + makedir = memnew(Button); makedir->set_text(RTR("Create Folder")); - makedir->connect_compat("pressed", this, "_make_dir"); + makedir->connect("pressed", callable_mp(this, &FileDialog::_make_dir)); hbc->add_child(makedir); vbc->add_child(hbc); @@ -950,20 +951,20 @@ FileDialog::FileDialog() { access = ACCESS_RESOURCES; _update_drives(); - connect_compat("confirmed", this, "_action_pressed"); - tree->connect_compat("multi_selected", this, "_tree_multi_selected", varray(), CONNECT_DEFERRED); - tree->connect_compat("cell_selected", this, "_tree_selected", varray(), CONNECT_DEFERRED); - tree->connect_compat("item_activated", this, "_tree_item_activated", varray()); - tree->connect_compat("nothing_selected", this, "deselect_items"); - dir->connect_compat("text_entered", this, "_dir_entered"); - file->connect_compat("text_entered", this, "_file_entered"); - filter->connect_compat("item_selected", this, "_filter_selected"); + connect("confirmed", callable_mp(this, &FileDialog::_action_pressed)); + tree->connect("multi_selected", callable_mp(this, &FileDialog::_tree_multi_selected), varray(), CONNECT_DEFERRED); + tree->connect("cell_selected", callable_mp(this, &FileDialog::_tree_selected), varray(), CONNECT_DEFERRED); + tree->connect("item_activated", callable_mp(this, &FileDialog::_tree_item_activated), varray()); + tree->connect("nothing_selected", callable_mp(this, &FileDialog::deselect_items)); + dir->connect("text_entered", callable_mp(this, &FileDialog::_dir_entered)); + file->connect("text_entered", callable_mp(this, &FileDialog::_file_entered)); + filter->connect("item_selected", callable_mp(this, &FileDialog::_filter_selected)); confirm_save = memnew(ConfirmationDialog); confirm_save->set_as_toplevel(true); add_child(confirm_save); - confirm_save->connect_compat("confirmed", this, "_save_confirm_pressed"); + confirm_save->connect("confirmed", callable_mp(this, &FileDialog::_save_confirm_pressed)); makedialog = memnew(ConfirmationDialog); makedialog->set_title(RTR("Create Folder")); @@ -974,7 +975,7 @@ FileDialog::FileDialog() { makevb->add_margin_child(RTR("Name:"), makedirname); add_child(makedialog); makedialog->register_text_enter(makedirname); - makedialog->connect_compat("confirmed", this, "_make_dir_confirm"); + makedialog->connect("confirmed", callable_mp(this, &FileDialog::_make_dir_confirm)); mkdirerr = memnew(AcceptDialog); mkdirerr->set_text(RTR("Could not create folder.")); add_child(mkdirerr); @@ -1003,8 +1004,6 @@ FileDialog::~FileDialog() { void LineEditFileChooser::_bind_methods() { - ClassDB::bind_method(D_METHOD("_browse"), &LineEditFileChooser::_browse); - ClassDB::bind_method(D_METHOD("_chosen"), &LineEditFileChooser::_chosen); ClassDB::bind_method(D_METHOD("get_button"), &LineEditFileChooser::get_button); ClassDB::bind_method(D_METHOD("get_line_edit"), &LineEditFileChooser::get_line_edit); ClassDB::bind_method(D_METHOD("get_file_dialog"), &LineEditFileChooser::get_file_dialog); @@ -1029,10 +1028,10 @@ LineEditFileChooser::LineEditFileChooser() { button = memnew(Button); button->set_text(" .. "); add_child(button); - button->connect_compat("pressed", this, "_browse"); + button->connect("pressed", callable_mp(this, &LineEditFileChooser::_browse)); dialog = memnew(FileDialog); add_child(dialog); - dialog->connect_compat("file_selected", this, "_chosen"); - dialog->connect_compat("dir_selected", this, "_chosen"); - dialog->connect_compat("files_selected", this, "_chosen"); + dialog->connect("file_selected", callable_mp(this, &LineEditFileChooser::_chosen)); + dialog->connect("dir_selected", callable_mp(this, &LineEditFileChooser::_chosen)); + dialog->connect("files_selected", callable_mp(this, &LineEditFileChooser::_chosen)); } diff --git a/scene/gui/file_dialog.h b/scene/gui/file_dialog.h index 9f6650c276..a7dc101d12 100644 --- a/scene/gui/file_dialog.h +++ b/scene/gui/file_dialog.h @@ -76,6 +76,8 @@ private: VBoxContainer *vbox; Mode mode; LineEdit *dir; + HBoxContainer *drives_container; + HBoxContainer *shortcuts_container; OptionButton *drives; Tree *tree; HBoxContainer *file_box; diff --git a/scene/gui/gradient_edit.cpp b/scene/gui/gradient_edit.cpp index 98c2d3a0e9..6345bfe562 100644 --- a/scene/gui/gradient_edit.cpp +++ b/scene/gui/gradient_edit.cpp @@ -96,7 +96,7 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { Ref<InputEventKey> k = p_event; - if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_DELETE && grabbed != -1) { + if (k.is_valid() && k->is_pressed() && k->get_keycode() == KEY_DELETE && grabbed != -1) { points.remove(grabbed); grabbed = -1; @@ -302,8 +302,8 @@ void GradientEdit::_gui_input(const Ref<InputEvent> &p_event) { void GradientEdit::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { - if (!picker->is_connected_compat("color_changed", this, "_color_changed")) { - picker->connect_compat("color_changed", this, "_color_changed"); + if (!picker->is_connected("color_changed", callable_mp(this, &GradientEdit::_color_changed))) { + picker->connect("color_changed", callable_mp(this, &GradientEdit::_color_changed)); } } if (p_what == NOTIFICATION_DRAW) { @@ -490,6 +490,5 @@ Vector<Gradient::Point> &GradientEdit::get_points() { void GradientEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &GradientEdit::_gui_input); - ClassDB::bind_method(D_METHOD("_color_changed"), &GradientEdit::_color_changed); ADD_SIGNAL(MethodInfo("ramp_changed")); } diff --git a/scene/gui/graph_edit.cpp b/scene/gui/graph_edit.cpp index a9bdede852..4bc33b220e 100644 --- a/scene/gui/graph_edit.cpp +++ b/scene/gui/graph_edit.cpp @@ -257,9 +257,9 @@ void GraphEdit::add_child_notify(Node *p_child) { GraphNode *gn = Object::cast_to<GraphNode>(p_child); if (gn) { gn->set_scale(Vector2(zoom, zoom)); - gn->connect_compat("offset_changed", this, "_graph_node_moved", varray(gn)); - gn->connect_compat("raise_request", this, "_graph_node_raised", varray(gn)); - gn->connect_compat("item_rect_changed", connections_layer, "update"); + gn->connect("offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved), varray(gn)); + gn->connect("raise_request", callable_mp(this, &GraphEdit::_graph_node_raised), varray(gn)); + gn->connect("item_rect_changed", callable_mp((CanvasItem *)connections_layer, &CanvasItem::update)); _graph_node_moved(gn); gn->set_mouse_filter(MOUSE_FILTER_PASS); } @@ -273,8 +273,8 @@ void GraphEdit::remove_child_notify(Node *p_child) { } GraphNode *gn = Object::cast_to<GraphNode>(p_child); if (gn) { - gn->disconnect_compat("offset_changed", this, "_graph_node_moved"); - gn->disconnect_compat("raise_request", this, "_graph_node_raised"); + gn->disconnect("offset_changed", callable_mp(this, &GraphEdit::_graph_node_moved)); + gn->disconnect("raise_request", callable_mp(this, &GraphEdit::_graph_node_raised)); } } @@ -1043,22 +1043,22 @@ void GraphEdit::_gui_input(const Ref<InputEvent> &p_ev) { if (k.is_valid()) { - if (k->get_scancode() == KEY_D && k->is_pressed() && k->get_command()) { + if (k->get_keycode() == KEY_D && k->is_pressed() && k->get_command()) { emit_signal("duplicate_nodes_request"); accept_event(); } - if (k->get_scancode() == KEY_C && k->is_pressed() && k->get_command()) { + if (k->get_keycode() == KEY_C && k->is_pressed() && k->get_command()) { emit_signal("copy_nodes_request"); accept_event(); } - if (k->get_scancode() == KEY_V && k->is_pressed() && k->get_command()) { + if (k->get_keycode() == KEY_V && k->is_pressed() && k->get_command()) { emit_signal("paste_nodes_request"); accept_event(); } - if (k->get_scancode() == KEY_DELETE && k->is_pressed()) { + if (k->get_keycode() == KEY_DELETE && k->is_pressed()) { emit_signal("delete_nodes_request"); accept_event(); } @@ -1291,21 +1291,8 @@ void GraphEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_right_disconnects", "enable"), &GraphEdit::set_right_disconnects); ClassDB::bind_method(D_METHOD("is_right_disconnects_enabled"), &GraphEdit::is_right_disconnects_enabled); - ClassDB::bind_method(D_METHOD("_graph_node_moved"), &GraphEdit::_graph_node_moved); - ClassDB::bind_method(D_METHOD("_graph_node_raised"), &GraphEdit::_graph_node_raised); - - ClassDB::bind_method(D_METHOD("_top_layer_input"), &GraphEdit::_top_layer_input); - ClassDB::bind_method(D_METHOD("_top_layer_draw"), &GraphEdit::_top_layer_draw); - ClassDB::bind_method(D_METHOD("_scroll_moved"), &GraphEdit::_scroll_moved); - ClassDB::bind_method(D_METHOD("_zoom_minus"), &GraphEdit::_zoom_minus); - ClassDB::bind_method(D_METHOD("_zoom_reset"), &GraphEdit::_zoom_reset); - ClassDB::bind_method(D_METHOD("_zoom_plus"), &GraphEdit::_zoom_plus); - ClassDB::bind_method(D_METHOD("_snap_toggled"), &GraphEdit::_snap_toggled); - ClassDB::bind_method(D_METHOD("_snap_value_changed"), &GraphEdit::_snap_value_changed); - ClassDB::bind_method(D_METHOD("_gui_input"), &GraphEdit::_gui_input); ClassDB::bind_method(D_METHOD("_update_scroll_offset"), &GraphEdit::_update_scroll_offset); - ClassDB::bind_method(D_METHOD("_connections_layer_draw"), &GraphEdit::_connections_layer_draw); ClassDB::bind_method(D_METHOD("get_zoom_hbox"), &GraphEdit::get_zoom_hbox); @@ -1341,12 +1328,12 @@ GraphEdit::GraphEdit() { add_child(top_layer); top_layer->set_mouse_filter(MOUSE_FILTER_PASS); top_layer->set_anchors_and_margins_preset(Control::PRESET_WIDE); - top_layer->connect_compat("draw", this, "_top_layer_draw"); - top_layer->connect_compat("gui_input", this, "_top_layer_input"); + top_layer->connect("draw", callable_mp(this, &GraphEdit::_top_layer_draw)); + top_layer->connect("gui_input", callable_mp(this, &GraphEdit::_top_layer_input)); connections_layer = memnew(Control); add_child(connections_layer); - connections_layer->connect_compat("draw", this, "_connections_layer_draw"); + connections_layer->connect("draw", callable_mp(this, &GraphEdit::_connections_layer_draw)); connections_layer->set_name("CLAYER"); connections_layer->set_disable_visibility_clip(true); // so it can draw freely and be offset connections_layer->set_mouse_filter(MOUSE_FILTER_IGNORE); @@ -1373,8 +1360,8 @@ GraphEdit::GraphEdit() { v_scroll->set_min(-10000); v_scroll->set_max(10000); - h_scroll->connect_compat("value_changed", this, "_scroll_moved"); - v_scroll->connect_compat("value_changed", this, "_scroll_moved"); + h_scroll->connect("value_changed", callable_mp(this, &GraphEdit::_scroll_moved)); + v_scroll->connect("value_changed", callable_mp(this, &GraphEdit::_scroll_moved)); zoom = 1; @@ -1385,25 +1372,25 @@ GraphEdit::GraphEdit() { zoom_minus = memnew(ToolButton); zoom_hb->add_child(zoom_minus); zoom_minus->set_tooltip(RTR("Zoom Out")); - zoom_minus->connect_compat("pressed", this, "_zoom_minus"); + zoom_minus->connect("pressed", callable_mp(this, &GraphEdit::_zoom_minus)); zoom_minus->set_focus_mode(FOCUS_NONE); zoom_reset = memnew(ToolButton); zoom_hb->add_child(zoom_reset); zoom_reset->set_tooltip(RTR("Zoom Reset")); - zoom_reset->connect_compat("pressed", this, "_zoom_reset"); + zoom_reset->connect("pressed", callable_mp(this, &GraphEdit::_zoom_reset)); zoom_reset->set_focus_mode(FOCUS_NONE); zoom_plus = memnew(ToolButton); zoom_hb->add_child(zoom_plus); zoom_plus->set_tooltip(RTR("Zoom In")); - zoom_plus->connect_compat("pressed", this, "_zoom_plus"); + zoom_plus->connect("pressed", callable_mp(this, &GraphEdit::_zoom_plus)); zoom_plus->set_focus_mode(FOCUS_NONE); snap_button = memnew(ToolButton); snap_button->set_toggle_mode(true); snap_button->set_tooltip(RTR("Enable snap and show grid.")); - snap_button->connect_compat("pressed", this, "_snap_toggled"); + snap_button->connect("pressed", callable_mp(this, &GraphEdit::_snap_toggled)); snap_button->set_pressed(true); snap_button->set_focus_mode(FOCUS_NONE); zoom_hb->add_child(snap_button); @@ -1413,7 +1400,7 @@ GraphEdit::GraphEdit() { snap_amount->set_max(100); snap_amount->set_step(1); snap_amount->set_value(20); - snap_amount->connect_compat("value_changed", this, "_snap_value_changed"); + snap_amount->connect("value_changed", callable_mp(this, &GraphEdit::_snap_value_changed)); zoom_hb->add_child(snap_amount); setting_scroll_ofs = false; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 174dc65e8a..5e662b8df0 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -1542,7 +1542,6 @@ void ItemList::_bind_methods() { ClassDB::bind_method(D_METHOD("get_v_scroll"), &ItemList::get_v_scroll); - ClassDB::bind_method(D_METHOD("_scroll_changed"), &ItemList::_scroll_changed); ClassDB::bind_method(D_METHOD("_gui_input"), &ItemList::_gui_input); ClassDB::bind_method(D_METHOD("_set_items"), &ItemList::_set_items); @@ -1599,7 +1598,7 @@ ItemList::ItemList() { add_child(scroll_bar); shape_changed = true; - scroll_bar->connect_compat("value_changed", this, "_scroll_changed"); + scroll_bar->connect("value_changed", callable_mp(this, &ItemList::_scroll_changed)); set_focus_mode(FOCUS_ALL); current_columns = 1; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index fb8396e4ff..fdddf0b5fa 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -165,7 +165,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { #ifdef APPLE_STYLE_KEYS if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) { uint32_t remap_key = KEY_UNKNOWN; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_F: { remap_key = KEY_RIGHT; } break; @@ -193,13 +193,13 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } if (remap_key != KEY_UNKNOWN) { - k->set_scancode(remap_key); + k->set_keycode(remap_key); k->set_control(false); } } #endif - unsigned int code = k->get_scancode(); + unsigned int code = k->get_keycode(); if (k->get_command() && is_shortcut_keys_enabled()) { @@ -571,7 +571,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (handled) { accept_event(); } else if (!k->get_command()) { - if (k->get_unicode() >= 32 && k->get_scancode() != KEY_DELETE) { + if (k->get_unicode() >= 32 && k->get_keycode() != KEY_DELETE) { if (editable) { selection_delete(); @@ -669,8 +669,8 @@ void LineEdit::_notification(int p_what) { cursor_set_blink_enabled(EDITOR_DEF("text_editor/cursor/caret_blink", false)); cursor_set_blink_speed(EDITOR_DEF("text_editor/cursor/caret_blink_speed", 0.65)); - if (!EditorSettings::get_singleton()->is_connected_compat("settings_changed", this, "_editor_settings_changed")) { - EditorSettings::get_singleton()->connect_compat("settings_changed", this, "_editor_settings_changed"); + if (!EditorSettings::get_singleton()->is_connected("settings_changed", callable_mp(this, &LineEdit::_editor_settings_changed))) { + EditorSettings::get_singleton()->connect("settings_changed", callable_mp(this, &LineEdit::_editor_settings_changed)); } } } break; @@ -1773,9 +1773,6 @@ void LineEdit::_generate_context_menu() { void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("_text_changed"), &LineEdit::_text_changed); - ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &LineEdit::_toggle_draw_caret); - - ClassDB::bind_method("_editor_settings_changed", &LineEdit::_editor_settings_changed); ClassDB::bind_method(D_METHOD("set_align", "align"), &LineEdit::set_align); ClassDB::bind_method(D_METHOD("get_align"), &LineEdit::get_align); @@ -1891,7 +1888,7 @@ LineEdit::LineEdit() { caret_blink_timer = memnew(Timer); add_child(caret_blink_timer); caret_blink_timer->set_wait_time(0.65); - caret_blink_timer->connect_compat("timeout", this, "_toggle_draw_caret"); + caret_blink_timer->connect("timeout", callable_mp(this, &LineEdit::_toggle_draw_caret)); cursor_set_blink_enabled(false); context_menu_enabled = true; @@ -1899,7 +1896,7 @@ LineEdit::LineEdit() { add_child(menu); editable = false; // Initialise to opposite first, so we get past the early-out in set_editable. set_editable(true); - menu->connect_compat("id_pressed", this, "menu_option"); + menu->connect("id_pressed", callable_mp(this, &LineEdit::menu_option)); expand_to_text_length = false; } diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp index a211ee02ed..2b163187c5 100644 --- a/scene/gui/menu_button.cpp +++ b/scene/gui/menu_button.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "menu_button.h" + #include "core/os/keyboard.h" #include "scene/main/viewport.h" @@ -137,8 +138,8 @@ MenuButton::MenuButton() { popup->hide(); add_child(popup); popup->set_pass_on_modal_close_click(false); - popup->connect_compat("about_to_show", this, "set_pressed", varray(true)); // For when switching from another MenuButton. - popup->connect_compat("popup_hide", this, "set_pressed", varray(false)); + popup->connect("about_to_show", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(true)); // For when switching from another MenuButton. + popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false)); } MenuButton::~MenuButton() { diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index 6488d6ce0a..c185761beb 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "option_button.h" + #include "core/print_string.h" Size2 OptionButton::get_minimum_size() const { @@ -309,9 +310,6 @@ void OptionButton::get_translatable_strings(List<String> *p_strings) const { void OptionButton::_bind_methods() { - ClassDB::bind_method(D_METHOD("_selected"), &OptionButton::_selected); - ClassDB::bind_method(D_METHOD("_focused"), &OptionButton::_focused); - ClassDB::bind_method(D_METHOD("add_item", "label", "id"), &OptionButton::add_item, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("add_icon_item", "texture", "label", "id"), &OptionButton::add_icon_item, DEFVAL(-1)); ClassDB::bind_method(D_METHOD("set_item_text", "idx", "text"), &OptionButton::set_item_text); @@ -363,9 +361,9 @@ OptionButton::OptionButton() { popup->set_pass_on_modal_close_click(false); popup->set_notify_transform(true); popup->set_allow_search(true); - popup->connect_compat("index_pressed", this, "_selected"); - popup->connect_compat("id_focused", this, "_focused"); - popup->connect_compat("popup_hide", this, "set_pressed", varray(false)); + popup->connect("index_pressed", callable_mp(this, &OptionButton::_selected)); + popup->connect("id_focused", callable_mp(this, &OptionButton::_focused)); + popup->connect("popup_hide", callable_mp((BaseButton *)this, &BaseButton::set_pressed), varray(false)); } OptionButton::~OptionButton() { diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index 659d8041a2..e75dadd5e0 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "popup_menu.h" + #include "core/os/input.h" #include "core/os/keyboard.h" #include "core/os/os.h" @@ -1074,7 +1075,7 @@ bool PopupMenu::activate_item_by_event(const Ref<InputEvent> &p_event, bool p_fo Ref<InputEventKey> k = p_event; if (k.is_valid()) { - code = k->get_scancode(); + code = k->get_keycode(); if (code == 0) code = k->get_unicode(); if (k->get_control()) @@ -1233,7 +1234,7 @@ void PopupMenu::_ref_shortcut(Ref<ShortCut> p_sc) { if (!shortcut_refcount.has(p_sc)) { shortcut_refcount[p_sc] = 1; - p_sc->connect_compat("changed", this, "update"); + p_sc->connect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); } else { shortcut_refcount[p_sc] += 1; } @@ -1244,7 +1245,7 @@ void PopupMenu::_unref_shortcut(Ref<ShortCut> p_sc) { ERR_FAIL_COND(!shortcut_refcount.has(p_sc)); shortcut_refcount[p_sc]--; if (shortcut_refcount[p_sc] == 0) { - p_sc->disconnect_compat("changed", this, "update"); + p_sc->disconnect("changed", callable_mp((CanvasItem *)this, &CanvasItem::update)); shortcut_refcount.erase(p_sc); } } @@ -1471,8 +1472,6 @@ void PopupMenu::_bind_methods() { ClassDB::bind_method(D_METHOD("set_allow_search", "allow"), &PopupMenu::set_allow_search); ClassDB::bind_method(D_METHOD("get_allow_search"), &PopupMenu::get_allow_search); - ClassDB::bind_method(D_METHOD("_submenu_timeout"), &PopupMenu::_submenu_timeout); - ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "items", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_items", "_get_items"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_on_item_selection"), "set_hide_on_item_selection", "is_hide_on_item_selection"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hide_on_checkable_item_selection"), "set_hide_on_checkable_item_selection", "is_hide_on_checkable_item_selection"); @@ -1514,7 +1513,7 @@ PopupMenu::PopupMenu() { submenu_timer = memnew(Timer); submenu_timer->set_wait_time(0.3); submenu_timer->set_one_shot(true); - submenu_timer->connect_compat("timeout", this, "_submenu_timeout"); + submenu_timer->connect("timeout", callable_mp(this, &PopupMenu::_submenu_timeout)); add_child(submenu_timer); } diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index 6282b26a5a..bc1510d6f6 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1209,7 +1209,7 @@ void RichTextLabel::_gui_input(Ref<InputEvent> p_event) { if (k.is_valid()) { if (k->is_pressed() && !k->get_alt() && !k->get_shift()) { bool handled = false; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_PAGEUP: { if (vscroll->is_visible_in_tree()) { @@ -2699,7 +2699,6 @@ int RichTextLabel::get_content_height() { void RichTextLabel::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &RichTextLabel::_gui_input); - ClassDB::bind_method(D_METHOD("_scroll_changed"), &RichTextLabel::_scroll_changed); ClassDB::bind_method(D_METHOD("get_text"), &RichTextLabel::get_text); ClassDB::bind_method(D_METHOD("add_text", "text"), &RichTextLabel::add_text); ClassDB::bind_method(D_METHOD("set_text", "text"), &RichTextLabel::set_text); @@ -2963,7 +2962,7 @@ RichTextLabel::RichTextLabel() { vscroll->set_anchor_and_margin(MARGIN_TOP, ANCHOR_BEGIN, 0); vscroll->set_anchor_and_margin(MARGIN_BOTTOM, ANCHOR_END, 0); vscroll->set_anchor_and_margin(MARGIN_RIGHT, ANCHOR_END, 0); - vscroll->connect_compat("value_changed", this, "_scroll_changed"); + vscroll->connect("value_changed", callable_mp(this, &RichTextLabel::_scroll_changed)); vscroll->set_step(1); vscroll->hide(); current_idx = 1; diff --git a/scene/gui/scroll_bar.cpp b/scene/gui/scroll_bar.cpp index 3d7b6b05ae..fef5e00984 100644 --- a/scene/gui/scroll_bar.cpp +++ b/scene/gui/scroll_bar.cpp @@ -296,15 +296,15 @@ void ScrollBar::_notification(int p_what) { } if (drag_node) { - drag_node->connect_compat("gui_input", this, "_drag_node_input"); - drag_node->connect_compat("tree_exiting", this, "_drag_node_exit", varray(), CONNECT_ONESHOT); + drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); + drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), varray(), CONNECT_ONESHOT); } } if (p_what == NOTIFICATION_EXIT_TREE) { if (drag_node) { - drag_node->disconnect_compat("gui_input", this, "_drag_node_input"); - drag_node->disconnect_compat("tree_exiting", this, "_drag_node_exit"); + drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); + drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit)); } drag_node = NULL; @@ -539,7 +539,7 @@ float ScrollBar::get_custom_step() const { void ScrollBar::_drag_node_exit() { if (drag_node) { - drag_node->disconnect_compat("gui_input", this, "_drag_node_input"); + drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); } drag_node = NULL; } @@ -611,8 +611,8 @@ void ScrollBar::set_drag_node(const NodePath &p_path) { if (is_inside_tree()) { if (drag_node) { - drag_node->disconnect_compat("gui_input", this, "_drag_node_input"); - drag_node->disconnect_compat("tree_exiting", this, "_drag_node_exit"); + drag_node->disconnect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); + drag_node->disconnect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit)); } } @@ -627,8 +627,8 @@ void ScrollBar::set_drag_node(const NodePath &p_path) { } if (drag_node) { - drag_node->connect_compat("gui_input", this, "_drag_node_input"); - drag_node->connect_compat("tree_exiting", this, "_drag_node_exit", varray(), CONNECT_ONESHOT); + drag_node->connect("gui_input", callable_mp(this, &ScrollBar::_drag_node_input)); + drag_node->connect("tree_exiting", callable_mp(this, &ScrollBar::_drag_node_exit), varray(), CONNECT_ONESHOT); } } } @@ -651,8 +651,6 @@ void ScrollBar::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollBar::_gui_input); ClassDB::bind_method(D_METHOD("set_custom_step", "step"), &ScrollBar::set_custom_step); ClassDB::bind_method(D_METHOD("get_custom_step"), &ScrollBar::get_custom_step); - ClassDB::bind_method(D_METHOD("_drag_node_input"), &ScrollBar::_drag_node_input); - ClassDB::bind_method(D_METHOD("_drag_node_exit"), &ScrollBar::_drag_node_exit); ADD_SIGNAL(MethodInfo("scrolling")); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 5829a86a42..c25a6d5a0c 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -267,7 +267,7 @@ void ScrollContainer::_notification(int p_what) { if (p_what == NOTIFICATION_READY) { - get_viewport()->connect_compat("gui_focus_changed", this, "_ensure_focused_visible"); + get_viewport()->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_ensure_focused_visible)); } if (p_what == NOTIFICATION_SORT_CHILDREN) { @@ -570,14 +570,12 @@ VScrollBar *ScrollContainer::get_v_scrollbar() { void ScrollContainer::_bind_methods() { - ClassDB::bind_method(D_METHOD("_scroll_moved"), &ScrollContainer::_scroll_moved); ClassDB::bind_method(D_METHOD("_gui_input"), &ScrollContainer::_gui_input); ClassDB::bind_method(D_METHOD("set_enable_h_scroll", "enable"), &ScrollContainer::set_enable_h_scroll); ClassDB::bind_method(D_METHOD("is_h_scroll_enabled"), &ScrollContainer::is_h_scroll_enabled); ClassDB::bind_method(D_METHOD("set_enable_v_scroll", "enable"), &ScrollContainer::set_enable_v_scroll); ClassDB::bind_method(D_METHOD("is_v_scroll_enabled"), &ScrollContainer::is_v_scroll_enabled); ClassDB::bind_method(D_METHOD("_update_scrollbar_position"), &ScrollContainer::_update_scrollbar_position); - ClassDB::bind_method(D_METHOD("_ensure_focused_visible"), &ScrollContainer::_ensure_focused_visible); 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); ClassDB::bind_method(D_METHOD("set_v_scroll", "value"), &ScrollContainer::set_v_scroll); @@ -610,12 +608,12 @@ ScrollContainer::ScrollContainer() { h_scroll = memnew(HScrollBar); h_scroll->set_name("_h_scroll"); add_child(h_scroll); - h_scroll->connect_compat("value_changed", this, "_scroll_moved"); + h_scroll->connect("value_changed", callable_mp(this, &ScrollContainer::_scroll_moved)); v_scroll = memnew(VScrollBar); v_scroll->set_name("_v_scroll"); add_child(v_scroll); - v_scroll->connect_compat("value_changed", this, "_scroll_moved"); + v_scroll->connect("value_changed", callable_mp(this, &ScrollContainer::_scroll_moved)); drag_speed = Vector2(); drag_touching = false; diff --git a/scene/gui/spin_box.cpp b/scene/gui/spin_box.cpp index 1200877127..576de98a4f 100644 --- a/scene/gui/spin_box.cpp +++ b/scene/gui/spin_box.cpp @@ -267,7 +267,6 @@ void SpinBox::_bind_methods() { //ClassDB::bind_method(D_METHOD("_value_changed"),&SpinBox::_value_changed); ClassDB::bind_method(D_METHOD("_gui_input"), &SpinBox::_gui_input); - ClassDB::bind_method(D_METHOD("_text_entered"), &SpinBox::_text_entered); ClassDB::bind_method(D_METHOD("set_align", "align"), &SpinBox::set_align); ClassDB::bind_method(D_METHOD("get_align"), &SpinBox::get_align); ClassDB::bind_method(D_METHOD("set_suffix", "suffix"), &SpinBox::set_suffix); @@ -277,10 +276,7 @@ void SpinBox::_bind_methods() { ClassDB::bind_method(D_METHOD("set_editable", "editable"), &SpinBox::set_editable); ClassDB::bind_method(D_METHOD("is_editable"), &SpinBox::is_editable); ClassDB::bind_method(D_METHOD("apply"), &SpinBox::apply); - ClassDB::bind_method(D_METHOD("_line_edit_focus_exit"), &SpinBox::_line_edit_focus_exit); ClassDB::bind_method(D_METHOD("get_line_edit"), &SpinBox::get_line_edit); - ClassDB::bind_method(D_METHOD("_line_edit_input"), &SpinBox::_line_edit_input); - ClassDB::bind_method(D_METHOD("_range_click_timeout"), &SpinBox::_range_click_timeout); ADD_PROPERTY(PropertyInfo(Variant::INT, "align", PROPERTY_HINT_ENUM, "Left,Center,Right,Fill"), "set_align", "get_align"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable"); @@ -297,12 +293,12 @@ SpinBox::SpinBox() { line_edit->set_anchors_and_margins_preset(Control::PRESET_WIDE); line_edit->set_mouse_filter(MOUSE_FILTER_PASS); //connect("value_changed",this,"_value_changed"); - line_edit->connect_compat("text_entered", this, "_text_entered", Vector<Variant>(), CONNECT_DEFERRED); - line_edit->connect_compat("focus_exited", this, "_line_edit_focus_exit", Vector<Variant>(), CONNECT_DEFERRED); - line_edit->connect_compat("gui_input", this, "_line_edit_input"); + line_edit->connect("text_entered", callable_mp(this, &SpinBox::_text_entered), Vector<Variant>(), CONNECT_DEFERRED); + line_edit->connect("focus_exited", callable_mp(this, &SpinBox::_line_edit_focus_exit), Vector<Variant>(), CONNECT_DEFERRED); + line_edit->connect("gui_input", callable_mp(this, &SpinBox::_line_edit_input)); drag.enabled = false; range_click_timer = memnew(Timer); - range_click_timer->connect_compat("timeout", this, "_range_click_timeout"); + range_click_timer->connect("timeout", callable_mp(this, &SpinBox::_range_click_timeout)); add_child(range_click_timer); } diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 66ecbea378..6290d364fc 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -537,8 +537,8 @@ void TabContainer::add_child_notify(Node *p_child) { c->set_margin(Margin(MARGIN_BOTTOM), c->get_margin(Margin(MARGIN_BOTTOM)) - sb->get_margin(Margin(MARGIN_BOTTOM))); update(); - p_child->connect_compat("renamed", this, "_child_renamed_callback"); - if (first) + p_child->connect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback)); + if (first && is_inside_tree()) emit_signal("tab_changed", current); } @@ -620,7 +620,7 @@ void TabContainer::remove_child_notify(Node *p_child) { call_deferred("_update_current_tab"); - p_child->disconnect_compat("renamed", this, "_child_renamed_callback"); + p_child->disconnect("renamed", callable_mp(this, &TabContainer::_child_renamed_callback)); update(); } @@ -1011,9 +1011,7 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_hidden_tabs_for_min_size", "enabled"), &TabContainer::set_use_hidden_tabs_for_min_size); ClassDB::bind_method(D_METHOD("get_use_hidden_tabs_for_min_size"), &TabContainer::get_use_hidden_tabs_for_min_size); - ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback); ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed); - ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &TabContainer::_on_mouse_exited); ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab); ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab"))); @@ -1048,5 +1046,5 @@ TabContainer::TabContainer() { tabs_rearrange_group = -1; use_hidden_tabs_for_min_size = false; - connect_compat("mouse_exited", this, "_on_mouse_exited"); + connect("mouse_exited", callable_mp(this, &TabContainer::_on_mouse_exited)); } diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index ea1e6546e9..901408919a 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -956,7 +956,6 @@ void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &Tabs::_gui_input); ClassDB::bind_method(D_METHOD("_update_hover"), &Tabs::_update_hover); - ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &Tabs::_on_mouse_exited); ClassDB::bind_method(D_METHOD("get_tab_count"), &Tabs::get_tab_count); ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &Tabs::set_current_tab); ClassDB::bind_method(D_METHOD("get_current_tab"), &Tabs::get_current_tab); @@ -1034,5 +1033,5 @@ Tabs::Tabs() { drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; - connect_compat("mouse_exited", this, "_on_mouse_exited"); + connect("mouse_exited", callable_mp(this, &Tabs::_on_mouse_exited)); } diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 2fd1ba5535..06691d09be 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -753,10 +753,18 @@ void TextEdit::_notification(int p_what) { } } - if (line_length_guideline) { - int x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_col - cursor.x_ofs; - if (x > xmargin_beg && x < xmargin_end) { - VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(x, 0), Point2(x, size.height), cache.line_length_guideline_color); + if (line_length_guidelines) { + const int hard_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_hard_col - cursor.x_ofs; + if (hard_x > xmargin_beg && hard_x < xmargin_end) { + VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(hard_x, 0), Point2(hard_x, size.height), cache.line_length_guideline_color); + } + + // Draw a "Soft" line length guideline, less visible than the hard line length guideline. + // It's usually set to a lower column compared to the hard line length guideline. + // Only drawn if its column differs from the hard line length guideline. + const int soft_x = xmargin_beg + (int)cache.font->get_char_size('0').width * line_length_guideline_soft_col - cursor.x_ofs; + if (hard_x != soft_x && soft_x > xmargin_beg && soft_x < xmargin_end) { + VisualServer::get_singleton()->canvas_item_add_line(ci, Point2(soft_x, 0), Point2(soft_x, size.height), cache.line_length_guideline_color * Color(1, 1, 1, 0.5)); } } @@ -1848,6 +1856,7 @@ void TextEdit::_consume_pair_symbol(CharType ch) { bool in_single_quote = false; bool in_double_quote = false; + bool found_comment = false; int c = 0; while (c < line.length()) { @@ -1857,6 +1866,9 @@ void TextEdit::_consume_pair_symbol(CharType ch) { if (cursor.column == c) { break; } + } else if (!in_single_quote && !in_double_quote && line[c] == '#') { + found_comment = true; + break; } else { if (line[c] == '\'' && !in_double_quote) { in_single_quote = !in_single_quote; @@ -1872,7 +1884,15 @@ void TextEdit::_consume_pair_symbol(CharType ch) { } } - // Disallow inserting duplicated quotes while already in string + // Do not need to duplicate quotes while in comments + if (found_comment) { + insert_text_at_cursor(ch_single); + cursor_set_column(cursor_position_to_move); + + return; + } + + // Disallow inserting duplicated quotes while already in string if ((in_single_quote || in_double_quote) && (ch == '"' || ch == '\'')) { insert_text_at_cursor(ch_single); cursor_set_column(cursor_position_to_move); @@ -2509,13 +2529,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { String new_word = get_word_at_pos(mm->get_position()); if (new_word != highlighted_word) { - highlighted_word = new_word; - update(); + emit_signal("symbol_validate", new_word); } } else { if (highlighted_word != String()) { - highlighted_word = String(); - update(); + set_highlighted_word(String()); } } } @@ -2556,21 +2574,17 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { k = k->duplicate(); // It will be modified later on. #ifdef OSX_ENABLED - if (k->get_scancode() == KEY_META) { + if (k->get_keycode() == KEY_META) { #else - if (k->get_scancode() == KEY_CONTROL) { + if (k->get_keycode() == KEY_CONTROL) { #endif if (select_identifiers_enabled) { if (k->is_pressed() && !dragging_minimap && !dragging_selection) { - - highlighted_word = get_word_at_pos(get_local_mouse_position()); - update(); - + emit_signal("symbol_validate", get_word_at_pos(get_local_mouse_position())); } else { - highlighted_word = String(); - update(); + set_highlighted_word(String()); } } } @@ -2589,7 +2603,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (valid) { if (!k->get_alt()) { - if (k->get_scancode() == KEY_UP) { + if (k->get_keycode() == KEY_UP) { if (completion_index > 0) { completion_index--; @@ -2603,7 +2617,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_DOWN) { + if (k->get_keycode() == KEY_DOWN) { if (completion_index < completion_options.size() - 1) { completion_index++; @@ -2617,7 +2631,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_PAGEUP) { + if (k->get_keycode() == KEY_PAGEUP) { completion_index -= get_constant("completion_lines"); if (completion_index < 0) @@ -2628,7 +2642,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_PAGEDOWN) { + if (k->get_keycode() == KEY_PAGEDOWN) { completion_index += get_constant("completion_lines"); if (completion_index >= completion_options.size()) @@ -2639,7 +2653,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_HOME && completion_index > 0) { + if (k->get_keycode() == KEY_HOME && completion_index > 0) { completion_index = 0; completion_current = completion_options[completion_index]; @@ -2648,7 +2662,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_END && completion_index < completion_options.size() - 1) { + if (k->get_keycode() == KEY_END && completion_index < completion_options.size() - 1) { completion_index = completion_options.size() - 1; completion_current = completion_options[completion_index]; @@ -2657,14 +2671,14 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_KP_ENTER || k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_TAB) { + if (k->get_keycode() == KEY_KP_ENTER || k->get_keycode() == KEY_ENTER || k->get_keycode() == KEY_TAB) { _confirm_completion(); accept_event(); return; } - if (k->get_scancode() == KEY_BACKSPACE) { + if (k->get_keycode() == KEY_BACKSPACE) { _reset_caret_blink_timer(); @@ -2674,7 +2688,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_SHIFT) { + if (k->get_keycode() == KEY_SHIFT) { accept_event(); return; } @@ -2718,20 +2732,20 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { /* TEST CONTROL FIRST! */ // Some remaps for duplicate functions. - if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_scancode() == KEY_INSERT) { + if (k->get_command() && !k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) { - k->set_scancode(KEY_C); + k->set_keycode(KEY_C); } - if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_scancode() == KEY_INSERT) { + if (!k->get_command() && k->get_shift() && !k->get_alt() && !k->get_metakey() && k->get_keycode() == KEY_INSERT) { - k->set_scancode(KEY_V); + k->set_keycode(KEY_V); k->set_command(true); k->set_shift(false); } #ifdef APPLE_STYLE_KEYS if (k->get_control() && !k->get_shift() && !k->get_alt() && !k->get_command()) { uint32_t remap_key = KEY_UNKNOWN; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_F: { remap_key = KEY_RIGHT; } break; @@ -2753,7 +2767,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (remap_key != KEY_UNKNOWN) { - k->set_scancode(remap_key); + k->set_keycode(remap_key); k->set_control(false); } } @@ -2771,7 +2785,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { bool unselect = false; bool dobreak = false; - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_TAB: { if (k->get_shift()) { @@ -2845,11 +2859,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { selection.selecting_text = false; - bool scancode_handled = true; + bool keycode_handled = true; - // Special scancode test. + // Special keycode test. - switch (k->get_scancode()) { + switch (k->get_keycode()) { case KEY_KP_ENTER: case KEY_ENTER: { @@ -2971,7 +2985,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { completion_hint = ""; update(); } else { - scancode_handled = false; + keycode_handled = false; } } break; case KEY_TAB: { @@ -3044,7 +3058,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_alt() && cursor.column > 1) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command() && cursor.column > 1) { #endif @@ -3101,7 +3115,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_4: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3137,7 +3151,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else if (k->get_alt()) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command()) { #endif @@ -3177,7 +3191,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_6: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3199,7 +3213,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else if (k->get_alt()) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command()) { #endif @@ -3238,7 +3252,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_8: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3246,7 +3260,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_UP: { if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } #ifndef APPLE_STYLE_KEYS @@ -3291,7 +3305,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_2: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3299,7 +3313,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_DOWN: { if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } #ifndef APPLE_STYLE_KEYS @@ -3359,7 +3373,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_alt() && cursor.column < curline_len - 1) { #else if (k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } else if (k->get_command() && cursor.column < curline_len - 1) { #endif @@ -3414,7 +3428,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_7: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3475,7 +3489,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_1: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3522,7 +3536,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_9: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3545,7 +3559,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; case KEY_KP_3: { if (k->get_unicode() != 0) { - scancode_handled = false; + keycode_handled = false; break; } [[fallthrough]]; @@ -3570,7 +3584,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { #ifndef APPLE_STYLE_KEYS if (!k->get_control() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } if (is_shortcut_keys_enabled()) { @@ -3578,7 +3592,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } #else if ((!k->get_command() && !k->get_control())) { - scancode_handled = false; + keycode_handled = false; break; } if (!k->get_shift() && k->get_command() && is_shortcut_keys_enabled()) @@ -3609,7 +3623,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_E: { if (!k->get_control() || k->get_command() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3634,7 +3648,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { break; } if (!k->get_command() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } if (is_shortcut_keys_enabled()) { @@ -3645,7 +3659,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { case KEY_C: { if (!k->get_command() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3661,7 +3675,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (!k->get_command()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3679,7 +3693,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (!k->get_command()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3692,7 +3706,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { break; } if (!k->get_command() || k->get_shift() || k->get_alt()) { - scancode_handled = false; + keycode_handled = false; break; } @@ -3709,9 +3723,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { #endif query_code_comple(); - scancode_handled = true; + keycode_handled = true; } else { - scancode_handled = false; + keycode_handled = false; } } break; @@ -3728,20 +3742,20 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { default: { - scancode_handled = false; + keycode_handled = false; } break; } - if (scancode_handled) + if (keycode_handled) accept_event(); - if (k->get_scancode() == KEY_INSERT) { + if (k->get_keycode() == KEY_INSERT) { set_insert_mode(!insert_mode); accept_event(); return; } - if (!scancode_handled && !k->get_command()) { // For German keyboards. + if (!keycode_handled && !k->get_command()) { // For German keyboards. if (k->get_unicode() >= 32) { @@ -6834,13 +6848,18 @@ bool TextEdit::is_show_line_numbers_enabled() const { return line_numbers; } -void TextEdit::set_show_line_length_guideline(bool p_show) { - line_length_guideline = p_show; +void TextEdit::set_show_line_length_guidelines(bool p_show) { + line_length_guidelines = p_show; + update(); +} + +void TextEdit::set_line_length_guideline_soft_column(int p_column) { + line_length_guideline_soft_col = p_column; update(); } -void TextEdit::set_line_length_guideline_column(int p_column) { - line_length_guideline_col = p_column; +void TextEdit::set_line_length_guideline_hard_column(int p_column) { + line_length_guideline_hard_col = p_column; update(); } @@ -6983,6 +7002,11 @@ void TextEdit::menu_option(int p_option) { } } +void TextEdit::set_highlighted_word(const String &new_word) { + highlighted_word = new_word; + update(); +} + void TextEdit::set_select_identifiers_on_hover(bool p_enable) { select_identifiers_enabled = p_enable; @@ -7031,13 +7055,8 @@ PopupMenu *TextEdit::get_menu() const { void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &TextEdit::_gui_input); - ClassDB::bind_method(D_METHOD("_scroll_moved"), &TextEdit::_scroll_moved); ClassDB::bind_method(D_METHOD("_cursor_changed_emit"), &TextEdit::_cursor_changed_emit); ClassDB::bind_method(D_METHOD("_text_changed_emit"), &TextEdit::_text_changed_emit); - ClassDB::bind_method(D_METHOD("_push_current_op"), &TextEdit::_push_current_op); - ClassDB::bind_method(D_METHOD("_click_selection_held"), &TextEdit::_click_selection_held); - ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &TextEdit::_toggle_draw_caret); - ClassDB::bind_method(D_METHOD("_v_scroll_input"), &TextEdit::_v_scroll_input); ClassDB::bind_method(D_METHOD("_update_wrap_at"), &TextEdit::_update_wrap_at); BIND_ENUM_CONSTANT(SEARCH_MATCH_CASE); @@ -7205,6 +7224,7 @@ void TextEdit::_bind_methods() { ADD_SIGNAL(MethodInfo("breakpoint_toggled", PropertyInfo(Variant::INT, "row"))); ADD_SIGNAL(MethodInfo("symbol_lookup", PropertyInfo(Variant::STRING, "symbol"), PropertyInfo(Variant::INT, "row"), PropertyInfo(Variant::INT, "column"))); ADD_SIGNAL(MethodInfo("info_clicked", PropertyInfo(Variant::INT, "row"), PropertyInfo(Variant::STRING, "info"))); + ADD_SIGNAL(MethodInfo("symbol_validate", PropertyInfo(Variant::STRING, "symbol"))); BIND_ENUM_CONSTANT(MENU_CUT); BIND_ENUM_CONSTANT(MENU_COPY); @@ -7259,10 +7279,10 @@ TextEdit::TextEdit() { updating_scrolls = false; selection.active = false; - h_scroll->connect_compat("value_changed", this, "_scroll_moved"); - v_scroll->connect_compat("value_changed", this, "_scroll_moved"); + h_scroll->connect("value_changed", callable_mp(this, &TextEdit::_scroll_moved)); + v_scroll->connect("value_changed", callable_mp(this, &TextEdit::_scroll_moved)); - v_scroll->connect_compat("scrolling", this, "_v_scroll_input"); + v_scroll->connect("scrolling", callable_mp(this, &TextEdit::_v_scroll_input)); cursor_changed_dirty = false; text_changed_dirty = false; @@ -7279,7 +7299,7 @@ TextEdit::TextEdit() { caret_blink_timer = memnew(Timer); add_child(caret_blink_timer); caret_blink_timer->set_wait_time(0.65); - caret_blink_timer->connect_compat("timeout", this, "_toggle_draw_caret"); + caret_blink_timer->connect("timeout", callable_mp(this, &TextEdit::_toggle_draw_caret)); cursor_set_blink_enabled(false); right_click_moves_caret = true; @@ -7287,12 +7307,12 @@ TextEdit::TextEdit() { add_child(idle_detect); idle_detect->set_one_shot(true); idle_detect->set_wait_time(GLOBAL_GET("gui/timers/text_edit_idle_detect_sec")); - idle_detect->connect_compat("timeout", this, "_push_current_op"); + idle_detect->connect("timeout", callable_mp(this, &TextEdit::_push_current_op)); click_select_held = memnew(Timer); add_child(click_select_held); click_select_held->set_wait_time(0.05); - click_select_held->connect_compat("timeout", this, "_click_selection_held"); + click_select_held->connect("timeout", callable_mp(this, &TextEdit::_click_selection_held)); current_op.type = TextOperation::TYPE_NONE; undo_enabled = true; @@ -7309,8 +7329,9 @@ TextEdit::TextEdit() { tooltip_obj = NULL; line_numbers = false; line_numbers_zero_padded = false; - line_length_guideline = false; - line_length_guideline_col = 80; + line_length_guidelines = false; + line_length_guideline_soft_col = 80; + line_length_guideline_hard_col = 100; draw_bookmark_gutter = false; draw_breakpoint_gutter = false; draw_fold_gutter = false; @@ -7350,7 +7371,7 @@ TextEdit::TextEdit() { add_child(menu); readonly = true; // Initialise to opposite first, so we get past the early-out in set_readonly. set_readonly(false); - menu->connect_compat("id_pressed", this, "menu_option"); + menu->connect("id_pressed", callable_mp(this, &TextEdit::menu_option)); first_draw = true; executing_line = -1; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 9986b80fd5..3c9d1a5c85 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -369,8 +369,9 @@ private: bool undo_enabled; bool line_numbers; bool line_numbers_zero_padded; - bool line_length_guideline; - int line_length_guideline_col; + bool line_length_guidelines; + int line_length_guideline_soft_col; + int line_length_guideline_hard_col; bool draw_bookmark_gutter; bool draw_breakpoint_gutter; int breakpoint_gutter_width; @@ -584,6 +585,7 @@ public: bool is_insert_text_operation(); + void set_highlighted_word(const String &new_word); void set_text(String p_text); void insert_text_at_cursor(const String &p_text); void insert_at(const String &p_text, int at); @@ -765,8 +767,9 @@ public: void set_line_numbers_zero_padded(bool p_zero_padded); - void set_show_line_length_guideline(bool p_show); - void set_line_length_guideline_column(int p_column); + void set_show_line_length_guidelines(bool p_show); + void set_line_length_guideline_soft_column(int p_column); + void set_line_length_guideline_hard_column(int p_column); void set_bookmark_gutter_enabled(bool p_draw); bool is_bookmark_gutter_enabled() const; diff --git a/scene/gui/texture_rect.cpp b/scene/gui/texture_rect.cpp index 87442f32e8..6dafd3bf4f 100644 --- a/scene/gui/texture_rect.cpp +++ b/scene/gui/texture_rect.cpp @@ -127,7 +127,6 @@ void TextureRect::_bind_methods() { ClassDB::bind_method(D_METHOD("is_flipped_v"), &TextureRect::is_flipped_v); ClassDB::bind_method(D_METHOD("set_stretch_mode", "stretch_mode"), &TextureRect::set_stretch_mode); ClassDB::bind_method(D_METHOD("get_stretch_mode"), &TextureRect::get_stretch_mode); - ClassDB::bind_method(D_METHOD("_texture_changed"), &TextureRect::_texture_changed); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand"); @@ -160,13 +159,13 @@ void TextureRect::set_texture(const Ref<Texture2D> &p_tex) { } if (texture.is_valid()) { - texture->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_texture_changed"); + texture->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureRect::_texture_changed)); } texture = p_tex; if (texture.is_valid()) { - texture->connect_compat(CoreStringNames::get_singleton()->changed, this, "_texture_changed"); + texture->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &TextureRect::_texture_changed)); } update(); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 940692ebd7..12b3d56938 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -2439,7 +2439,7 @@ void Tree::_gui_input(Ref<InputEvent> p_event) { return; } else { - if (k->get_scancode() != KEY_SHIFT) + if (k->get_keycode() != KEY_SHIFT) last_keypress = 0; } } @@ -3914,13 +3914,7 @@ bool Tree::get_allow_reselect() const { void Tree::_bind_methods() { - ClassDB::bind_method(D_METHOD("_range_click_timeout"), &Tree::_range_click_timeout); ClassDB::bind_method(D_METHOD("_gui_input"), &Tree::_gui_input); - ClassDB::bind_method(D_METHOD("_popup_select"), &Tree::popup_select); - ClassDB::bind_method(D_METHOD("_text_editor_enter"), &Tree::text_editor_enter); - ClassDB::bind_method(D_METHOD("_text_editor_modal_close"), &Tree::_text_editor_modal_close); - ClassDB::bind_method(D_METHOD("_value_editor_changed"), &Tree::value_editor_changed); - ClassDB::bind_method(D_METHOD("_scroll_moved"), &Tree::_scroll_moved); ClassDB::bind_method(D_METHOD("clear"), &Tree::clear); ClassDB::bind_method(D_METHOD("create_item", "parent", "idx"), &Tree::_create_item, DEFVAL(Variant()), DEFVAL(-1)); @@ -4043,15 +4037,15 @@ Tree::Tree() { add_child(v_scroll); range_click_timer = memnew(Timer); - range_click_timer->connect_compat("timeout", this, "_range_click_timeout"); + range_click_timer->connect("timeout", callable_mp(this, &Tree::_range_click_timeout)); add_child(range_click_timer); - h_scroll->connect_compat("value_changed", this, "_scroll_moved"); - v_scroll->connect_compat("value_changed", this, "_scroll_moved"); - text_editor->connect_compat("text_entered", this, "_text_editor_enter"); - text_editor->connect_compat("modal_closed", this, "_text_editor_modal_close"); - popup_menu->connect_compat("id_pressed", this, "_popup_select"); - value_editor->connect_compat("value_changed", this, "_value_editor_changed"); + h_scroll->connect("value_changed", callable_mp(this, &Tree::_scroll_moved)); + v_scroll->connect("value_changed", callable_mp(this, &Tree::_scroll_moved)); + text_editor->connect("text_entered", callable_mp(this, &Tree::text_editor_enter)); + text_editor->connect("modal_closed", callable_mp(this, &Tree::_text_editor_modal_close)); + popup_menu->connect("id_pressed", callable_mp(this, &Tree::popup_select)); + value_editor->connect("value_changed", callable_mp(this, &Tree::value_editor_changed)); value_editor->set_as_toplevel(true); text_editor->set_as_toplevel(true); |