@@ -117,31 +117,21 @@ pub fn scrollview_add[T](mut w T) {
117
117
// TODO: documentation
118
118
pub fn scrollview_widget_set_orig_xy (w Widget, reset_offset bool ) {
119
119
if w is Stack {
120
- if has_scrollview (w) {
121
- scrollview_set_orig_xy (w, reset_offset)
122
- }
120
+ scrollview_set_orig_xy (w, reset_offset)
123
121
for child in w.children {
124
122
scrollview_widget_set_orig_xy (child, reset_offset)
125
123
}
126
124
} else if w is CanvasLayout {
127
- if has_scrollview (w) {
128
- scrollview_set_orig_xy (w, reset_offset)
129
- }
125
+ scrollview_set_orig_xy (w, reset_offset)
130
126
for child in w.children {
131
127
scrollview_widget_set_orig_xy (child, reset_offset)
132
128
}
133
129
} else if w is ListBox {
134
- if has_scrollview (w) {
135
- scrollview_set_orig_xy (w, reset_offset)
136
- }
130
+ scrollview_set_orig_xy (w, reset_offset)
137
131
} else if w is ChunkView {
138
- if has_scrollview (w) {
139
- scrollview_set_orig_xy (w, reset_offset)
140
- }
132
+ scrollview_set_orig_xy (w, reset_offset)
141
133
} else if w is TextBox {
142
- if has_scrollview (w) {
143
- scrollview_set_orig_xy (w, reset_offset)
144
- }
134
+ scrollview_set_orig_xy (w, reset_offset)
145
135
} else if w is Group {
146
136
// if has_scrollview(w) {
147
137
// scrollview_set_orig_xy(w)
@@ -150,9 +140,7 @@ pub fn scrollview_widget_set_orig_xy(w Widget, reset_offset bool) {
150
140
scrollview_widget_set_orig_xy (child, reset_offset)
151
141
}
152
142
} else if w is BoxLayout {
153
- if has_scrollview (w) {
154
- scrollview_set_orig_xy (w, reset_offset)
155
- }
143
+ scrollview_set_orig_xy (w, reset_offset)
156
144
for child in w.children {
157
145
scrollview_widget_set_orig_xy (child, reset_offset)
158
146
}
@@ -207,7 +195,7 @@ fn has_parent_scrolling(w Widget) bool {
207
195
}
208
196
209
197
// TODO: documentation
210
- pub fn scrollview_set_orig_xy [T] (w & T , reset_offset bool ) {
198
+ pub fn scrollview_set_orig_xy (w & ScrollableWidget , reset_offset bool ) {
211
199
if has_scrollview (w) {
212
200
mut sv := w.scrollview
213
201
// rest values
@@ -234,32 +222,24 @@ pub fn scrollview_set_orig_xy[T](w &T, reset_offset bool) {
234
222
// TODO: documentation
235
223
pub fn scrollview_widget_save_offset (w Widget) {
236
224
if w is Stack {
237
- if has_scrollview (w) {
238
- scrollview_save_offset (w)
239
- }
225
+ scrollview_save_offset (w)
240
226
for child in w.children {
241
227
scrollview_widget_save_offset (child)
242
228
}
243
229
} else if w is CanvasLayout {
244
- if has_scrollview (w) {
245
- scrollview_save_offset (w)
246
- }
230
+ scrollview_save_offset (w)
247
231
for child in w.children {
248
232
scrollview_widget_save_offset (child)
249
233
}
250
234
} else if w is ListBox {
251
- if has_scrollview (w) {
252
- scrollview_save_offset (w)
253
- }
235
+ scrollview_save_offset (w)
254
236
} else if w is TextBox {
255
- if has_scrollview (w) {
256
- scrollview_save_offset (w)
257
- }
237
+ scrollview_save_offset (w)
258
238
}
259
239
}
260
240
261
241
// TODO: documentation
262
- pub fn scrollview_save_offset [T] (w & T ) {
242
+ pub fn scrollview_save_offset (w & ScrollableWidget ) {
263
243
if has_scrollview (w) {
264
244
mut sv := w.scrollview
265
245
// Save prev values
@@ -271,32 +251,24 @@ pub fn scrollview_save_offset[T](w &T) {
271
251
// TODO: documentation
272
252
pub fn scrollview_widget_restore_offset (w Widget, orig bool ) {
273
253
if w is Stack {
274
- if has_scrollview (w) {
275
- scrollview_restore_offset (w, orig)
276
- }
254
+ scrollview_restore_offset (w, orig)
277
255
for child in w.children {
278
256
scrollview_widget_restore_offset (child, orig)
279
257
}
280
258
} else if w is CanvasLayout {
281
- if has_scrollview (w) {
282
- scrollview_restore_offset (w, orig)
283
- }
259
+ scrollview_restore_offset (w, orig)
284
260
for child in w.children {
285
261
scrollview_widget_restore_offset (child, orig)
286
262
}
287
263
} else if w is ListBox {
288
- if has_scrollview (w) {
289
- scrollview_restore_offset (w, orig)
290
- }
264
+ scrollview_restore_offset (w, orig)
291
265
} else if w is TextBox {
292
- if has_scrollview (w) {
293
- scrollview_restore_offset (w, orig)
294
- }
266
+ scrollview_restore_offset (w, orig)
295
267
}
296
268
}
297
269
298
270
// TODO: documentation
299
- pub fn scrollview_restore_offset [T] (w & T , orig bool ) {
271
+ pub fn scrollview_restore_offset (w & ScrollableWidget , orig bool ) {
300
272
if has_scrollview (w) {
301
273
mut sv := w.scrollview
302
274
sv.update_active ()
@@ -320,17 +292,17 @@ pub fn scrollview_restore_offset[T](w &T, orig bool) {
320
292
}
321
293
322
294
// TODO: documentation
323
- pub fn scrollview_delegate_parent_scrollview [T] (mut w T ) {
295
+ pub fn scrollview_delegate_parent_scrollview (mut w Widget ) {
324
296
parent := w.parent
325
- if parent is Stack {
297
+ if parent is Stack && mut w is ScrollableWidget {
326
298
w.scrollview = parent.scrollview
327
- } else if parent is CanvasLayout {
299
+ } else if parent is CanvasLayout && mut w is ScrollableWidget {
328
300
w.scrollview = parent.scrollview
329
301
}
330
302
}
331
303
332
304
// TODO: documentation
333
- pub fn scrollview_update [T] (w & T ) {
305
+ pub fn scrollview_update (w & ScrollableWidget ) {
334
306
if has_scrollview (w) {
335
307
mut sv := w.scrollview
336
308
sv.update ()
@@ -340,17 +312,15 @@ pub fn scrollview_update[T](w &T) {
340
312
// TODO: documentation
341
313
pub fn scrollview_widget_update (w Widget) {
342
314
if w is Stack {
343
- if has_scrollview (w) {
344
- scrollview_update (w)
345
- }
315
+ scrollview_update (w)
346
316
for child in w.children {
347
317
scrollview_widget_update (child)
348
318
}
349
319
}
350
320
}
351
321
352
322
// TODO: documentation
353
- pub fn scrollview_update_active [T] (w & T ) {
323
+ pub fn scrollview_update_active (w & ScrollableWidget ) {
354
324
if has_scrollview (w) {
355
325
mut sv := w.scrollview
356
326
sv.update_active ()
@@ -360,9 +330,7 @@ pub fn scrollview_update_active[T](w &T) {
360
330
// TODO: documentation
361
331
pub fn scrollview_widget_update_active (w Widget) {
362
332
if w is Stack {
363
- if has_scrollview (w) {
364
- scrollview_update_active (w)
365
- }
333
+ scrollview_update_active (w)
366
334
for child in w.children {
367
335
scrollview_widget_update_active (child)
368
336
}
@@ -391,7 +359,7 @@ pub fn scrollview_draw_begin[T](mut w T, d DrawDevice) {
391
359
}
392
360
393
361
// TODO: documentation
394
- pub fn scrollview_draw_end [T] (w & T , d DrawDevice) {
362
+ pub fn scrollview_draw_end (w & ScrollableWidget , d DrawDevice) {
395
363
if has_scrollview (w) {
396
364
sv := w.scrollview
397
365
sv.draw_device (d)
0 commit comments