#include "scroll_container.h"
#include "core/config/project_settings.h"
#include "scene/main/window.h"
#include "scene/theme/theme_db.h"
Size2 ScrollContainer::get_minimum_size() const { … }
void ScrollContainer::_cancel_drag() { … }
bool ScrollContainer::_is_h_scroll_visible() const { … }
bool ScrollContainer::_is_v_scroll_visible() const { … }
void ScrollContainer::gui_input(const Ref<InputEvent> &p_gui_input) { … }
void ScrollContainer::_update_scrollbar_position() { … }
void ScrollContainer::_gui_focus_changed(Control *p_control) { … }
void ScrollContainer::ensure_control_visible(Control *p_control) { … }
void ScrollContainer::_reposition_children() { … }
void ScrollContainer::_notification(int p_what) { … }
void ScrollContainer::update_scrollbars() { … }
void ScrollContainer::_scroll_moved(float) {
queue_sort();
};
void ScrollContainer::set_h_scroll(int p_pos) { … }
int ScrollContainer::get_h_scroll() const { … }
void ScrollContainer::set_v_scroll(int p_pos) { … }
int ScrollContainer::get_v_scroll() const { … }
void ScrollContainer::set_horizontal_custom_step(float p_custom_step) { … }
float ScrollContainer::get_horizontal_custom_step() const { … }
void ScrollContainer::set_vertical_custom_step(float p_custom_step) { … }
float ScrollContainer::get_vertical_custom_step() const { … }
void ScrollContainer::set_horizontal_scroll_mode(ScrollMode p_mode) { … }
ScrollContainer::ScrollMode ScrollContainer::get_horizontal_scroll_mode() const { … }
void ScrollContainer::set_vertical_scroll_mode(ScrollMode p_mode) { … }
ScrollContainer::ScrollMode ScrollContainer::get_vertical_scroll_mode() const { … }
int ScrollContainer::get_deadzone() const { … }
void ScrollContainer::set_deadzone(int p_deadzone) { … }
bool ScrollContainer::is_following_focus() const { … }
void ScrollContainer::set_follow_focus(bool p_follow) { … }
PackedStringArray ScrollContainer::get_configuration_warnings() const { … }
HScrollBar *ScrollContainer::get_h_scroll_bar() { … }
VScrollBar *ScrollContainer::get_v_scroll_bar() { … }
void ScrollContainer::_bind_methods() {
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);
ClassDB::bind_method(D_METHOD("get_v_scroll"), &ScrollContainer::get_v_scroll);
ClassDB::bind_method(D_METHOD("set_horizontal_custom_step", "value"), &ScrollContainer::set_horizontal_custom_step);
ClassDB::bind_method(D_METHOD("get_horizontal_custom_step"), &ScrollContainer::get_horizontal_custom_step);
ClassDB::bind_method(D_METHOD("set_vertical_custom_step", "value"), &ScrollContainer::set_vertical_custom_step);
ClassDB::bind_method(D_METHOD("get_vertical_custom_step"), &ScrollContainer::get_vertical_custom_step);
ClassDB::bind_method(D_METHOD("set_horizontal_scroll_mode", "enable"), &ScrollContainer::set_horizontal_scroll_mode);
ClassDB::bind_method(D_METHOD("get_horizontal_scroll_mode"), &ScrollContainer::get_horizontal_scroll_mode);
ClassDB::bind_method(D_METHOD("set_vertical_scroll_mode", "enable"), &ScrollContainer::set_vertical_scroll_mode);
ClassDB::bind_method(D_METHOD("get_vertical_scroll_mode"), &ScrollContainer::get_vertical_scroll_mode);
ClassDB::bind_method(D_METHOD("set_deadzone", "deadzone"), &ScrollContainer::set_deadzone);
ClassDB::bind_method(D_METHOD("get_deadzone"), &ScrollContainer::get_deadzone);
ClassDB::bind_method(D_METHOD("set_follow_focus", "enabled"), &ScrollContainer::set_follow_focus);
ClassDB::bind_method(D_METHOD("is_following_focus"), &ScrollContainer::is_following_focus);
ClassDB::bind_method(D_METHOD("get_h_scroll_bar"), &ScrollContainer::get_h_scroll_bar);
ClassDB::bind_method(D_METHOD("get_v_scroll_bar"), &ScrollContainer::get_v_scroll_bar);
ClassDB::bind_method(D_METHOD("ensure_control_visible", "control"), &ScrollContainer::ensure_control_visible);
ADD_SIGNAL(MethodInfo("scroll_started"));
ADD_SIGNAL(MethodInfo("scroll_ended"));
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "follow_focus"), "set_follow_focus", "is_following_focus");
ADD_GROUP("Scroll", "scroll_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_horizontal", PROPERTY_HINT_NONE, "suffix:px"), "set_h_scroll", "get_h_scroll");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_vertical", PROPERTY_HINT_NONE, "suffix:px"), "set_v_scroll", "get_v_scroll");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scroll_horizontal_custom_step", PROPERTY_HINT_RANGE, "-1,4096,suffix:px"), "set_horizontal_custom_step", "get_horizontal_custom_step");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "scroll_vertical_custom_step", PROPERTY_HINT_RANGE, "-1,4096,suffix:px"), "set_vertical_custom_step", "get_vertical_custom_step");
ADD_PROPERTY(PropertyInfo(Variant::INT, "horizontal_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show,Reserve"), "set_horizontal_scroll_mode", "get_horizontal_scroll_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "vertical_scroll_mode", PROPERTY_HINT_ENUM, "Disabled,Auto,Always Show,Never Show,Reserve"), "set_vertical_scroll_mode", "get_vertical_scroll_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_deadzone"), "set_deadzone", "get_deadzone");
BIND_ENUM_CONSTANT(SCROLL_MODE_DISABLED);
BIND_ENUM_CONSTANT(SCROLL_MODE_AUTO);
BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_ALWAYS);
BIND_ENUM_CONSTANT(SCROLL_MODE_SHOW_NEVER);
BIND_ENUM_CONSTANT(SCROLL_MODE_RESERVE);
BIND_THEME_ITEM_CUSTOM(Theme::DATA_TYPE_STYLEBOX, ScrollContainer, panel_style, "panel");
GLOBAL_DEF("gui/common/default_scroll_deadzone", 0);
};
ScrollContainer::ScrollContainer() {
h_scroll = memnew(HScrollBar);
h_scroll->set_name("_h_scroll");
add_child(h_scroll, false, INTERNAL_MODE_BACK);
h_scroll->connect(SceneStringName(value_changed), callable_mp(this, &ScrollContainer::_scroll_moved));
v_scroll = memnew(VScrollBar);
v_scroll->set_name("_v_scroll");
add_child(v_scroll, false, INTERNAL_MODE_BACK);
v_scroll->connect(SceneStringName(value_changed), callable_mp(this, &ScrollContainer::_scroll_moved));
deadzone = GLOBAL_GET("gui/common/default_scroll_deadzone");
set_clip_contents(true);
};