diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 3c66478cf59..65814d4359d 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -54,9 +54,15 @@ The current horizontal scroll value. + + Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's horizontal increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused. + The current vertical scroll value. + + Overrides the [member ScrollBar.custom_step] used when clicking the internal scroll bar's vertical increment and decrement buttons or when using arrow keys when the [ScrollBar] is focused. + Controls whether vertical scrollbar can be used and when it should be visible. See [enum ScrollMode] for options. diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index b678f46091e..85dd73beeb1 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -482,6 +482,22 @@ int ScrollContainer::get_v_scroll() const { return v_scroll->get_value(); } +void ScrollContainer::set_horizontal_custom_step(float p_custom_step) { + h_scroll->set_custom_step(p_custom_step); +} + +float ScrollContainer::get_horizontal_custom_step() const { + return h_scroll->get_custom_step(); +} + +void ScrollContainer::set_vertical_custom_step(float p_custom_step) { + v_scroll->set_custom_step(p_custom_step); +} + +float ScrollContainer::get_vertical_custom_step() const { + return v_scroll->get_custom_step(); +} + void ScrollContainer::set_horizontal_scroll_mode(ScrollMode p_mode) { if (horizontal_scroll_mode == p_mode) { return; @@ -570,6 +586,12 @@ void ScrollContainer::_bind_methods() { 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); @@ -594,6 +616,8 @@ void ScrollContainer::_bind_methods() { 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"), "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"), "set_vertical_scroll_mode", "get_vertical_scroll_mode"); ADD_PROPERTY(PropertyInfo(Variant::INT, "scroll_deadzone"), "set_deadzone", "get_deadzone"); diff --git a/scene/gui/scroll_container.h b/scene/gui/scroll_container.h index 56bc3f8381e..dbd1b3904ac 100644 --- a/scene/gui/scroll_container.h +++ b/scene/gui/scroll_container.h @@ -98,6 +98,12 @@ public: void set_v_scroll(int p_pos); int get_v_scroll() const; + void set_horizontal_custom_step(float p_custom_step); + float get_horizontal_custom_step() const; + + void set_vertical_custom_step(float p_custom_step); + float get_vertical_custom_step() const; + void set_horizontal_scroll_mode(ScrollMode p_mode); ScrollMode get_horizontal_scroll_mode() const;