Fix multiline_text's overriding of set_cursor (#8418)

Subhraman rewrote the scrolling code in the last few commits,
and it seems that the autoscroll check is not needed anymore.
Remove that check altogether and make it 2 argument.

The problem with the 3-argument override was that, when
code in text_box_base.cpp calls the virtual method, it will
only consider the 2-argument version, and thus skip any
3-argument wrapper.

This fixes a Clang warning, although the warning itself points
out the opposite effect - that the 3-argument version hid the
2-argument one in the subclass.

Also fix a Clang warning that scroll_text could mark a method
as an override.

Co-authored-by: Subhraman Sarkar <suvrax@gmail.com>
This commit is contained in:
Steve Cotton 2024-02-19 17:10:16 +01:00 committed by GitHub
parent b4abee7c38
commit 8877848306
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 10 deletions

View file

@ -211,8 +211,7 @@ void multiline_text::handle_mouse_selection(point mouse, const bool start_select
line_num_ = get_line_num_from_offset(offset);
// moving scrollbars during click causes viewport to jump
set_cursor(offset, !start_selection, false);
set_cursor(offset, !start_selection);
update_canvas();
queue_redraw();

View file

@ -132,16 +132,13 @@ protected:
update_layout();
}
/** Inherited from text_box_base. */
void set_cursor(const std::size_t offset, const bool select, const bool autoscroll = true)
/** Inherited from text_box_base */
void set_cursor(const std::size_t offset, const bool select) override
{
text_box_base::set_cursor(offset, select);
set_line_num_from_offset();
if (autoscroll) {
// Whenever cursor moves, this tells scroll_text to update the scrollbars
update_layout();
}
// Whenever cursor moves, this tells scroll_text to update the scrollbars
update_layout();
}
/** Inherited from text_box_base. */

View file

@ -163,7 +163,7 @@ private:
return vertical_scrollbar()->get_positioner_offset();
}
void place(const point& origin, const point& size);
void place(const point& origin, const point& size) override;
/** See @ref widget::calculate_best_size. */
point calculate_best_size() const override;