diff options
Diffstat (limited to 'scene/gui/scroll_container.cpp')
-rw-r--r-- | scene/gui/scroll_container.cpp | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 5829a86a42..fb17adf96e 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -30,7 +30,7 @@ #include "scroll_container.h" #include "core/os/os.h" -#include "scene/main/viewport.h" +#include "scene/main/window.h" bool ScrollContainer::clips_input() const { @@ -39,7 +39,7 @@ bool ScrollContainer::clips_input() const { Size2 ScrollContainer::get_minimum_size() const { - Ref<StyleBox> sb = get_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox("bg"); Size2 min_size; for (int i = 0; i < get_child_count(); i++) { @@ -129,7 +129,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { if (v_scroll->get_value() != prev_v_scroll || h_scroll->get_value() != prev_h_scroll) accept_event(); //accept event if scroll changed - if (!OS::get_singleton()->has_touchscreen_ui_hint()) + if (!DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id()))) return; if (mb->get_button_index() != BUTTON_LEFT) @@ -145,7 +145,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { drag_accum = Vector2(); last_drag_accum = Vector2(); drag_from = Vector2(h_scroll->get_value(), v_scroll->get_value()); - drag_touching = OS::get_singleton()->has_touchscreen_ui_hint(); + drag_touching = !DisplayServer::get_singleton()->screen_is_touchscreen(DisplayServer::get_singleton()->window_get_current_screen(get_viewport()->get_window_id())); drag_touching_deaccel = false; beyond_deadzone = false; time_since_motion = 0; @@ -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) { @@ -276,7 +276,7 @@ void ScrollContainer::_notification(int p_what) { Size2 size = get_size(); Point2 ofs; - Ref<StyleBox> sb = get_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox("bg"); size -= sb->get_minimum_size(); ofs += sb->get_offset(); @@ -323,7 +323,7 @@ void ScrollContainer::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> sb = get_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox("bg"); draw_style_box(sb, Rect2(Vector2(), get_size())); update_scrollbars(); @@ -404,7 +404,7 @@ void ScrollContainer::_notification(int p_what) { void ScrollContainer::update_scrollbars() { Size2 size = get_size(); - Ref<StyleBox> sb = get_stylebox("bg"); + Ref<StyleBox> sb = get_theme_stylebox("bg"); size -= sb->get_minimum_size(); Size2 hmin; @@ -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; |