]> git.tdb.fi Git - libs/gltk.git/commitdiff
Make sure Entry::first_row stays consistent
authorMikko Rasa <tdb@tdb.fi>
Mon, 16 Sep 2019 17:25:30 +0000 (20:25 +0300)
committerMikko Rasa <tdb@tdb.fi>
Mon, 16 Sep 2019 17:25:30 +0000 (20:25 +0300)
Shrinking and then enlarging an Entry caused first_row to first be set to
the edit position, but would never be reset to zero due to the check in
slider_value_changed.  Yet the visual result was correct thanks to Text
clamping first_row independently.

source/entry.cpp

index 751f173d0c234a36a10c340987112fa6a7dd1605..36658dae18c0cf90bf73642a8ea77eab364f9ef1 100644 (file)
@@ -458,10 +458,13 @@ void Entry::check_view_range()
        else if(row>=first_row+visible_rows)
                first_row = row+1-visible_rows;
 
+       unsigned scroll = max(text.get_n_lines(), visible_rows)-visible_rows;
+       if(first_row>scroll)
+               first_row = scroll;
+
        if(first_row!=old_first_row)
                signal_scroll_position_changed.emit(first_row);
 
-       unsigned scroll = max(text.get_n_lines(), visible_rows)-visible_rows;
        slider->set_range(0, scroll);
        slider->set_value(scroll-first_row);
 }