mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:27:43 +00:00
LibGUI: Open and increment ComboBox ListViews by exact steps
This feels a bit nicer and always places the current index at the top of visible content in long scrollable lists.
This commit is contained in:
parent
207409c925
commit
1097f3066e
2 changed files with 6 additions and 2 deletions
|
@ -271,8 +271,11 @@ void ComboBox::open()
|
||||||
m_list_window->set_rect(rect);
|
m_list_window->set_rect(rect);
|
||||||
m_list_view->set_min_size(rect.size());
|
m_list_view->set_min_size(rect.size());
|
||||||
|
|
||||||
if (m_selected_index.has_value())
|
if (m_selected_index.has_value()) {
|
||||||
m_list_view->set_cursor(m_selected_index.value(), AbstractView::SelectionUpdate::Set);
|
m_list_view->set_cursor(m_selected_index.value(), AbstractView::SelectionUpdate::Set, false);
|
||||||
|
auto index_top = m_list_view->vertical_scrollbar().step() * m_selected_index.value().row();
|
||||||
|
m_list_view->vertical_scrollbar().set_value(index_top);
|
||||||
|
}
|
||||||
|
|
||||||
m_list_window->show();
|
m_list_window->show();
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ ListView::ListView()
|
||||||
set_background_role(ColorRole::Base);
|
set_background_role(ColorRole::Base);
|
||||||
set_foreground_role(ColorRole::BaseText);
|
set_foreground_role(ColorRole::BaseText);
|
||||||
set_searchable(true);
|
set_searchable(true);
|
||||||
|
vertical_scrollbar().set_step(item_height());
|
||||||
}
|
}
|
||||||
|
|
||||||
ListView::~ListView() = default;
|
ListView::~ListView() = default;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue