Skip to content

Commit f99b494

Browse files
wvpmSpartan322
authored andcommitted
Refactor scrollbar
1 parent bb4a040 commit f99b494

File tree

7 files changed

+257
-229
lines changed

7 files changed

+257
-229
lines changed

extension/doc_classes/GUIScrollbar.xml

Lines changed: 4 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
</method>
2020
<method name="decrement_value">
2121
<return type="void" />
22-
<param index="0" name="signal" type="bool" default="true" />
2322
<description>
2423
</description>
2524
</method>
@@ -38,31 +37,11 @@
3837
<description>
3938
</description>
4039
</method>
41-
<method name="get_max_value" qualifiers="const">
42-
<return type="int" />
43-
<description>
44-
</description>
45-
</method>
46-
<method name="get_min_value" qualifiers="const">
47-
<return type="int" />
48-
<description>
49-
</description>
50-
</method>
5140
<method name="get_orientation" qualifiers="const">
5241
<return type="int" enum="Orientation" />
5342
<description>
5443
</description>
5544
</method>
56-
<method name="get_range_limit_max" qualifiers="const">
57-
<return type="int" />
58-
<description>
59-
</description>
60-
</method>
61-
<method name="get_range_limit_min" qualifiers="const">
62-
<return type="int" />
63-
<description>
64-
</description>
65-
</method>
6645
<method name="get_value" qualifiers="const">
6746
<return type="int" />
6847
<description>
@@ -80,7 +59,6 @@
8059
</method>
8160
<method name="increment_value">
8261
<return type="void" />
83-
<param index="0" name="signal" type="bool" default="true" />
8462
<description>
8563
</description>
8664
</method>
@@ -90,7 +68,7 @@
9068
</description>
9169
</method>
9270
<method name="reset">
93-
<return type="int" enum="Error" />
71+
<return type="void" />
9472
<description>
9573
</description>
9674
</method>
@@ -107,28 +85,9 @@
10785
<description>
10886
</description>
10987
</method>
110-
<method name="set_limits">
111-
<return type="int" enum="Error" />
112-
<param index="0" name="new_min_value" type="int" />
113-
<param index="1" name="new_max_value" type="int" />
114-
<param index="2" name="signal" type="bool" default="true" />
115-
<description>
116-
</description>
117-
</method>
118-
<method name="set_range_limits">
119-
<return type="int" enum="Error" />
120-
<param index="0" name="new_range_limit_min" type="int" />
121-
<param index="1" name="new_range_limit_max" type="int" />
122-
<param index="2" name="signal" type="bool" default="true" />
123-
<description>
124-
</description>
125-
</method>
126-
<method name="set_range_limits_and_value">
127-
<return type="int" enum="Error" />
128-
<param index="0" name="new_range_limit_min" type="int" />
129-
<param index="1" name="new_range_limit_max" type="int" />
130-
<param index="2" name="new_value" type="int" />
131-
<param index="3" name="signal" type="bool" default="true" />
88+
<method name="set_step_count">
89+
<return type="void" />
90+
<param index="0" name="new_step_count" type="int" />
13291
<description>
13392
</description>
13493
</method>
@@ -142,14 +101,12 @@
142101
<method name="set_value">
143102
<return type="void" />
144103
<param index="0" name="new_value" type="int" />
145-
<param index="1" name="signal" type="bool" default="true" />
146104
<description>
147105
</description>
148106
</method>
149107
<method name="set_value_as_ratio">
150108
<return type="void" />
151109
<param index="0" name="new_ratio" type="float" />
152-
<param index="1" name="signal" type="bool" default="true" />
153110
<description>
154111
</description>
155112
</method>

extension/src/openvic-extension/classes/GUIListBox.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ Error GUIListBox::_calculate_max_scroll_index(bool signal) {
6363

6464
ERR_FAIL_NULL_V(scrollbar, FAILED);
6565

66-
scrollbar->set_limits(0, max_scroll_index, false);
66+
const bool was_blocking_signals = scrollbar->is_blocking_signals();
67+
scrollbar->set_block_signals(true);
68+
scrollbar->set_step_count(max_scroll_index);
69+
scrollbar->set_block_signals(was_blocking_signals);
70+
6771
scrollbar->set_visible(max_scroll_index > 0);
6872

6973
set_scroll_index(scrollbar->get_value(), signal);
@@ -209,7 +213,10 @@ void GUIListBox::set_scroll_index(int32_t new_scroll_index, bool signal) {
209213
scroll_index = std::clamp(new_scroll_index, 0, max_scroll_index);
210214

211215
if (scrollbar != nullptr && scrollbar->get_value() != scroll_index) {
212-
scrollbar->set_value(scroll_index, false);
216+
const bool was_blocking_signals = scrollbar->is_blocking_signals();
217+
scrollbar->set_block_signals(true);
218+
scrollbar->set_value(scroll_index);
219+
scrollbar->set_block_signals(was_blocking_signals);
213220
}
214221

215222
if (signal && scroll_index != old_scroll_index) {

0 commit comments

Comments
 (0)