@@ -293,7 +293,7 @@ void list::update_children_list()
293293
294294 // remove rest
295295 if (iter_index < iter_end_index) {
296- ASSERT (iter != this ->children ().end ())
296+ utki::assert (iter != this ->children ().end (), SL);
297297 for (; iter != this ->children ().end (); ++iter_index) {
298298 iter = this ->erase (iter);
299299 }
@@ -355,6 +355,9 @@ void list::notify_scroll_pos_changed(size_t old_index, real old_offset)
355355
356356real list::scroll_by (real delta)
357357{
358+ using std::round;
359+ delta = round (delta);
360+
358361 size_t old_index = this ->pos_index ;
359362 real old_offset = this ->pos_offset ;
360363
@@ -364,6 +367,7 @@ real list::scroll_by(real delta)
364367 real scrolled_by = 0 ;
365368
366369 if (delta >= 0 ) {
370+ // go through visible widgets first
367371 for (auto & c : this ->children ()) {
368372 auto wd = c.get ().rect ().d [long_index] - this ->pos_offset ;
369373 if (wd > delta) {
@@ -379,6 +383,7 @@ real list::scroll_by(real delta)
379383 ++this ->pos_index ;
380384 }
381385
386+ // if there is still distance to scroll, then go through the rest of the widgets
382387 if (delta > 0 ) {
383388 utki::assert (
384389 this ->pos_index > this ->added_index + this ->children ().size (),
@@ -438,10 +443,15 @@ real list::scroll_by(real delta)
438443 }
439444 }
440445
446+ // this will update the scrolling position to the bottom of the list if we have scrolled past the end of the list
441447 this ->update_children_list ();
442448
449+ // TODO: detect the situation when we have scrolled past the list's end and update the scrolled_by value accordingly
450+
443451 this ->notify_scroll_pos_changed (old_index, old_offset);
444452
453+ std::cout << " list: scrolled_by = " << scrolled_by << std::endl;
454+
445455 return scrolled_by;
446456}
447457
0 commit comments