mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:05:08 +00:00
LibGUI: Implement the virtual ListView::scroll_into_view()
Instead of shadowing the one from AbstractView.
This commit is contained in:
parent
04507e288f
commit
a56360f787
2 changed files with 8 additions and 7 deletions
|
@ -208,7 +208,7 @@ void ListView::move_selection(int steps)
|
||||||
if (model.is_valid(new_index)) {
|
if (model.is_valid(new_index)) {
|
||||||
set_last_valid_hovered_index({});
|
set_last_valid_hovered_index({});
|
||||||
selection().set(new_index);
|
selection().set(new_index);
|
||||||
scroll_into_view(new_index, Orientation::Vertical);
|
scroll_into_view(new_index, false, true);
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
if (hover_highlighting() && m_last_valid_hovered_index.is_valid()) {
|
if (hover_highlighting() && m_last_valid_hovered_index.is_valid()) {
|
||||||
|
@ -252,7 +252,7 @@ void ListView::keydown_event(KeyEvent& event)
|
||||||
}
|
}
|
||||||
if (model.is_valid(new_index)) {
|
if (model.is_valid(new_index)) {
|
||||||
selection().set(new_index);
|
selection().set(new_index);
|
||||||
scroll_into_view(new_index, Orientation::Vertical);
|
scroll_into_view(new_index, false, true);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -269,7 +269,7 @@ void ListView::keydown_event(KeyEvent& event)
|
||||||
}
|
}
|
||||||
if (model.is_valid(new_index)) {
|
if (model.is_valid(new_index)) {
|
||||||
selection().set(new_index);
|
selection().set(new_index);
|
||||||
scroll_into_view(new_index, Orientation::Vertical);
|
scroll_into_view(new_index, false, true);
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -282,10 +282,11 @@ void ListView::keydown_event(KeyEvent& event)
|
||||||
return Widget::keydown_event(event);
|
return Widget::keydown_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListView::scroll_into_view(const ModelIndex& index, Orientation orientation)
|
void ListView::scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically)
|
||||||
{
|
{
|
||||||
auto rect = content_rect(index.row());
|
if (!model())
|
||||||
ScrollableWidget::scroll_into_view(rect, orientation);
|
return;
|
||||||
|
ScrollableWidget::scroll_into_view(content_rect(index.row()), scroll_horizontally, scroll_vertically);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public:
|
||||||
|
|
||||||
int horizontal_padding() const { return m_horizontal_padding; }
|
int horizontal_padding() const { return m_horizontal_padding; }
|
||||||
|
|
||||||
void scroll_into_view(const ModelIndex&, Orientation);
|
virtual void scroll_into_view(const ModelIndex& index, bool scroll_horizontally, bool scroll_vertically) override;
|
||||||
|
|
||||||
Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const;
|
Gfx::IntPoint adjusted_position(const Gfx::IntPoint&) const;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue