M module-apps/options/OptionsModel.cpp => module-apps/options/OptionsModel.cpp +1 -1
@@ 14,7 14,7 @@ auto OptionsModel::requestRecordsCount() -> unsigned int
auto OptionsModel::getMinimalItemHeight() const -> unsigned int
{
- return style::window::label::big_h;
+ return style::window::label::big_h + gui::option::window::option_bottom_margin;
}
void OptionsModel::requestRecords(const uint32_t offset, const uint32_t limit)
M module-gui/gui/widgets/ListView.cpp => module-gui/gui/widgets/ListView.cpp +5 -3
@@ 34,7 34,7 @@ namespace gui
void ListViewScroll::updateFixed(const ListViewScrollUpdateData &data)
{
- auto elementsOnPage = (parent->widgetArea.h - data.topMargin) / data.elementMinimalHeight;
+ auto elementsOnPage = parent->widgetArea.h / data.elementMinimalHeight;
pagesCount = data.elementsCount % elementsOnPage == 0 ? data.elementsCount / elementsOnPage
: data.elementsCount / elementsOnPage + 1;
@@ 71,7 71,7 @@ namespace gui
storedStartIndex = data.startIndex;
- auto scrollH = (parent->widgetArea.h - data.topMargin) / pagesCount;
+ auto scrollH = parent->widgetArea.h / pagesCount;
auto scrollY = currentPage * scrollH > 0 ? currentPage * scrollH : data.topMargin;
setArea(BoundingBox(
@@ 295,7 295,8 @@ namespace gui
void ListView::prepareOnPageElementRebuild(unsigned int dataOffset)
{
- storedFocusIndex = dataOffset;
+ startIndex = (dataOffset / calculateMaxItemsOnPage()) * calculateMaxItemsOnPage();
+ storedFocusIndex = dataOffset % calculateMaxItemsOnPage();
}
void ListView::setup(listview::RebuildType rebuildType, unsigned int dataOffset)
@@ 317,6 318,7 @@ namespace gui
if (prepareRebuildCallback) {
prepareRebuildCallback();
+ setElementsCount(provider->requestRecordsCount());
}
lastRebuildRequest = {rebuildType, dataOffset};
M module-gui/gui/widgets/ListView.hpp => module-gui/gui/widgets/ListView.hpp +1 -1
@@ 37,7 37,7 @@ namespace gui
{
Full, ///< Full rebuild - resets lists to all initial conditions and request data from beginning.
InPlace, ///< InPlace rebuild - stores currently focused part of list and rebuild from that part.
- OnPageElement, ///< OnPageElement rebuild - same page but focus changed on provided element index.
+ OnPageElement, ///< OnPageElement rebuild - focus on provided element index and calculated page.
OnOffset ///< OnOffset rebuild - resets lists to all initial conditions and request data from provided
///< offset.
};
M module-gui/test/test-google/test-gui-listview.cpp => module-gui/test/test-google/test-gui-listview.cpp +4 -4
@@ 394,10 394,10 @@ TEST_F(ListViewTesting, Rebuild_Type_Test)
ASSERT_EQ(1, dynamic_cast<gui::TestListItem *>(testListView->body->getFocusItem())->ID)
<< "Check if item 1 has focus";
- // Do on page element rebuild on index outside Page scope (should focus on last possible)
- testListView->rebuildList(gui::listview::RebuildType::OnPageElement, 10);
+ // Do on page element rebuild on index outside Page scope. Page should change and proper element should be focused.
+ testListView->rebuildList(gui::listview::RebuildType::OnPageElement, 8);
// Check if focused item did not change
- ASSERT_EQ(5, dynamic_cast<gui::TestListItem *>(testListView->body->getFocusItem())->ID)
- << "Check if item 5 has focus";
+ ASSERT_EQ(8, dynamic_cast<gui::TestListItem *>(testListView->body->getFocusItem())->ID)
+ << "Check if item 8 has focus";
}