diff options
Diffstat (limited to 'scene/gui/scroll_container.cpp')
-rw-r--r-- | scene/gui/scroll_container.cpp | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index fb17adf96e..2f54ece449 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -33,17 +33,14 @@ #include "scene/main/window.h" bool ScrollContainer::clips_input() const { - return true; } Size2 ScrollContainer::get_minimum_size() const { - Ref<StyleBox> sb = get_theme_stylebox("bg"); Size2 min_size; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -88,14 +85,12 @@ void ScrollContainer::_cancel_drag() { } void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { - double prev_v_scroll = v_scroll->get_value(); double prev_h_scroll = h_scroll->get_value(); Ref<InputEventMouseButton> mb = p_gui_input; if (mb.is_valid()) { - if (mb->get_button_index() == BUTTON_WHEEL_UP && mb->is_pressed()) { // only horizontal is enabled, scroll horizontally if (h_scroll->is_visible() && (!v_scroll->is_visible() || mb->get_shift())) { @@ -136,7 +131,6 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { return; if (mb->is_pressed()) { - if (drag_touching) { _cancel_drag(); } @@ -156,11 +150,9 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { } else { if (drag_touching) { - if (drag_speed == Vector2()) { _cancel_drag(); } else { - drag_touching_deaccel = true; } } @@ -170,9 +162,7 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { Ref<InputEventMouseMotion> mm = p_gui_input; if (mm.is_valid()) { - if (drag_touching && !drag_touching_deaccel) { - Vector2 motion = Vector2(mm->get_relative().x, mm->get_relative().y); drag_accum -= motion; @@ -201,7 +191,6 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { Ref<InputEventPanGesture> pan_gesture = p_gui_input; if (pan_gesture.is_valid()) { - if (h_scroll->is_visible_in_tree()) { h_scroll->set_value(h_scroll->get_value() + h_scroll->get_page() * pan_gesture->get_delta().x / 8); } @@ -215,7 +204,6 @@ void ScrollContainer::_gui_input(const Ref<InputEvent> &p_gui_input) { } void ScrollContainer::_update_scrollbar_position() { - Size2 hmin = h_scroll->get_combined_minimum_size(); Size2 vmin = v_scroll->get_combined_minimum_size(); @@ -234,7 +222,6 @@ void ScrollContainer::_update_scrollbar_position() { } void ScrollContainer::_ensure_focused_visible(Control *p_control) { - if (!follow_focus) { return; } @@ -259,19 +246,15 @@ void ScrollContainer::_ensure_focused_visible(Control *p_control) { } void ScrollContainer::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { - call_deferred("_update_scrollbar_position"); }; if (p_what == NOTIFICATION_READY) { - get_viewport()->connect("gui_focus_changed", callable_mp(this, &ScrollContainer::_ensure_focused_visible)); } if (p_what == NOTIFICATION_SORT_CHILDREN) { - child_max_size = Size2(0, 0); Size2 size = get_size(); Point2 ofs; @@ -287,7 +270,6 @@ void ScrollContainer::_notification(int p_what) { size.x -= v_scroll->get_minimum_size().x; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -322,7 +304,6 @@ void ScrollContainer::_notification(int p_what) { }; if (p_what == NOTIFICATION_DRAW) { - Ref<StyleBox> sb = get_theme_stylebox("bg"); draw_style_box(sb, Rect2(Vector2(), get_size())); @@ -330,11 +311,8 @@ void ScrollContainer::_notification(int p_what) { } if (p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS) { - if (drag_touching) { - if (drag_touching_deaccel) { - Vector2 pos = Vector2(h_scroll->get_value(), v_scroll->get_value()); pos += drag_speed * get_physics_process_delta_time(); @@ -387,9 +365,7 @@ void ScrollContainer::_notification(int p_what) { } } else { - if (time_since_motion == 0 || time_since_motion > 0.1) { - Vector2 diff = drag_accum - last_drag_accum; last_drag_accum = drag_accum; drag_speed = diff / get_physics_process_delta_time(); @@ -402,7 +378,6 @@ void ScrollContainer::_notification(int p_what) { }; void ScrollContainer::update_scrollbars() { - Size2 size = get_size(); Ref<StyleBox> sb = get_theme_stylebox("bg"); size -= sb->get_minimum_size(); @@ -422,11 +397,9 @@ void ScrollContainer::update_scrollbars() { bool hide_scroll_h = !scroll_h || min.width <= size.width; if (hide_scroll_v) { - v_scroll->hide(); scroll.y = 0; } else { - v_scroll->show(); v_scroll->set_max(min.height); if (hide_scroll_h) { @@ -439,11 +412,9 @@ void ScrollContainer::update_scrollbars() { } if (hide_scroll_h) { - h_scroll->hide(); scroll.x = 0; } else { - h_scroll->show(); h_scroll->set_max(min.width); if (hide_scroll_v) { @@ -461,7 +432,6 @@ void ScrollContainer::update_scrollbars() { } void ScrollContainer::_scroll_moved(float) { - scroll.x = h_scroll->get_value(); scroll.y = v_scroll->get_value(); queue_sort(); @@ -480,7 +450,6 @@ void ScrollContainer::set_enable_h_scroll(bool p_enable) { } bool ScrollContainer::is_h_scroll_enabled() const { - return scroll_h; } @@ -495,26 +464,21 @@ void ScrollContainer::set_enable_v_scroll(bool p_enable) { } bool ScrollContainer::is_v_scroll_enabled() const { - return scroll_v; } int ScrollContainer::get_v_scroll() const { - return v_scroll->get_value(); } void ScrollContainer::set_v_scroll(int p_pos) { - v_scroll->set_value(p_pos); _cancel_drag(); } int ScrollContainer::get_h_scroll() const { - return h_scroll->get_value(); } void ScrollContainer::set_h_scroll(int p_pos) { - h_scroll->set_value(p_pos); _cancel_drag(); } @@ -536,11 +500,9 @@ void ScrollContainer::set_follow_focus(bool p_follow) { } String ScrollContainer::get_configuration_warning() const { - int found = 0; for (int i = 0; i < get_child_count(); i++) { - Control *c = Object::cast_to<Control>(get_child(i)); if (!c) continue; @@ -559,17 +521,14 @@ String ScrollContainer::get_configuration_warning() const { } HScrollBar *ScrollContainer::get_h_scrollbar() { - return h_scroll; } VScrollBar *ScrollContainer::get_v_scrollbar() { - return v_scroll; } void ScrollContainer::_bind_methods() { - 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); @@ -604,7 +563,6 @@ void ScrollContainer::_bind_methods() { }; ScrollContainer::ScrollContainer() { - h_scroll = memnew(HScrollBar); h_scroll->set_name("_h_scroll"); add_child(h_scroll); |