M module-apps/application-alarm-clock/windows/AlarmClockMainWindow.cpp => module-apps/application-alarm-clock/windows/AlarmClockMainWindow.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "AlarmClockMainWindow.hpp"
@@ 47,6 47,7 @@ namespace app::alarmClock
style::alarmClock::window::listView_h,
presenter->getAlarmsItemProvider(),
gui::listview::ScrollBarType::Fixed);
+ alarmsList->setBoundaries(gui::Boundaries::Continuous);
alarmsList->focusChangedCallback = [this](gui::Item &) {
onListFilled();
M module-apps/application-calllog/windows/CallLogMainWindow.cpp => module-apps/application-calllog/windows/CallLogMainWindow.cpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "CallLogMainWindow.hpp"
@@ 56,7 56,7 @@ namespace gui
mainWindow::h,
calllogModel,
gui::listview::ScrollBarType::Fixed);
-
+ list->setBoundaries(Boundaries::Continuous);
setFocusItem(list);
buildInterfaceForEmptyState();
M module-apps/application-messages/windows/MessagesMainWindow.cpp => module-apps/application-messages/windows/MessagesMainWindow.cpp +4 -4
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ApplicationMessages.hpp"
@@ 53,8 53,8 @@ namespace gui
msgThreadStyle::listHeight,
threadsModel,
listview::ScrollBarType::Fixed);
+ list->setBoundaries(Boundaries::Continuous);
list->setScrollTopMargin(style::margins::small);
- list->rebuildList();
navBar->setActive(nav_bar::Side::Left, true);
navBar->setActive(nav_bar::Side::Center, true);
@@ 112,7 112,7 @@ namespace gui
using db::query::ThreadGetByNumberResult;
auto primaryNumber = pdata->result->numbers[0].number;
auto query = std::make_unique<ThreadGetByNumber>(primaryNumber);
- auto task = app::AsyncQuery::createFromQuery(std::move(query), db::Interface::Name::Contact);
+ auto task = app::AsyncQuery::createFromQuery(std::move(query), db::Interface::Name::Contact);
task->setCallback([app = application](auto response) {
if (const auto result = dynamic_cast<ThreadGetByNumberResult *>(response); result != nullptr) {
if (auto thread = result->getThread(); thread.isValid()) {
@@ 132,7 132,7 @@ namespace gui
db::Interface::Name::Notifications,
std::make_unique<db::query::notifications::Clear>(NotificationsRecord::Key::Sms));
- list->rebuildList();
+ list->rebuildList(listview::RebuildType::InPlace);
}
bool MessagesMainWindow::onInput(const InputEvent &inputEvent)
M module-apps/application-music-player/windows/MusicPlayerAllSongsWindow.cpp => module-apps/application-music-player/windows/MusicPlayerAllSongsWindow.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "MusicPlayerAllSongsWindow.hpp"
@@ 37,6 37,7 @@ namespace gui
musicPlayerStyle::allSongsWindow::h,
presenter->getMusicPlayerModelInterface(),
listview::ScrollBarType::Fixed);
+ songsList->setBoundaries(Boundaries::Continuous);
emptyListIcon = new gui::Icon(this,
style::window::default_left_margin,
M module-apps/application-notes/windows/NoteMainWindow.cpp => module-apps/application-notes/windows/NoteMainWindow.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "NoteMainWindow.hpp"
@@ 61,6 61,7 @@ namespace app::notes
listStyle::Height,
presenter->getNotesItemProvider(),
gui::listview::ScrollBarType::Fixed);
+ list->setBoundaries(gui::Boundaries::Continuous);
list->setPenWidth(listStyle::PenWidth);
list->setPenFocusWidth(listStyle::FocusedPenWidth);
list->focusChangedCallback = [this]([[maybe_unused]] gui::Item &item) {
M module-apps/application-notes/windows/SearchResultsWindow.cpp => module-apps/application-notes/windows/SearchResultsWindow.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "SearchResultsWindow.hpp"
@@ 41,6 41,7 @@ namespace app::notes
style::list::Height,
presenter->getNotesItemProvider(),
gui::listview::ScrollBarType::Fixed);
+ list->setBoundaries(gui::Boundaries::Continuous);
list->setScrollTopMargin(::style::margins::small);
list->emptyListCallback = [&]() { onNothingFound(presenter->getSearchText()); };
setFocusItem(list);
M module-apps/application-phonebook/windows/PhonebookContactDetails.cpp => module-apps/application-phonebook/windows/PhonebookContactDetails.cpp +1 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhonebookContactDetails.hpp"
M module-apps/application-phonebook/windows/PhonebookMainWindow.cpp => module-apps/application-phonebook/windows/PhonebookMainWindow.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhonebookMainWindow.hpp"
@@ 46,6 46,7 @@ namespace gui
phonebookStyle::mainWindow::contactsList::w,
phonebookStyle::mainWindow::contactsList::h,
phonebookModel);
+ contactsList->setBoundaries(Boundaries::Continuous);
setFocusItem(contactsList);
emptyListIcon =
M module-apps/application-phonebook/windows/PhonebookNewContact.cpp => module-apps/application-phonebook/windows/PhonebookNewContact.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhonebookNewContact.hpp"
@@ 41,6 41,7 @@ namespace gui
phonebookStyle::newContactWindow::newContactsList::h,
newContactModel,
listview::ScrollBarType::PreRendered);
+ list->setBoundaries(Boundaries::Continuous);
setFocusItem(list);
}
M module-apps/application-phonebook/windows/PhonebookSearchResults.cpp => module-apps/application-phonebook/windows/PhonebookSearchResults.cpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "PhonebookSearchResults.hpp"
@@ 34,6 34,7 @@ namespace gui
phonebookStyle::searchResultsWindow::searchResultList::w,
phonebookStyle::searchResultsWindow::searchResultList::h,
searchResultsModel);
+ searchResultList->setBoundaries(Boundaries::Continuous);
setFocusItem(searchResultList);
navBar->setActive(nav_bar::Side::Center, true);
M module-apps/apps-common/InternalModel.hpp => module-apps/apps-common/InternalModel.hpp +8 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 42,8 42,11 @@ namespace app
{
auto index = 0;
if (order == gui::Order::Previous) {
- index = internalOffset + internalLimit - 1 + modelIndex;
+ auto calculatedIndex = internalOffset + internalLimit >= internalData.size()
+ ? internalData.size()
+ : internalOffset + internalLimit;
+ index = calculatedIndex - 1 + modelIndex;
modelIndex--;
}
if (order == gui::Order::Next) {
@@ 57,7 60,9 @@ namespace app
[[nodiscard]] bool isIndexValid(unsigned int index, gui::Order order) const noexcept
{
- return (index < internalData.size()) || (order == gui::Order::Previous && index < internalOffset);
+ return (order == gui::Order::Next && index < internalData.size()) ||
+ (order == gui::Order::Previous && static_cast<int>(index) >= 0 && index < internalData.size() &&
+ index >= internalOffset);
}
void clearItemProperties(T Item)
M module-apps/apps-common/windows/OptionWindow.cpp => module-apps/apps-common/windows/OptionWindow.cpp +2 -2
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "OptionWindow.hpp"
@@ 43,7 43,7 @@ namespace gui
option::window::optionsListH,
optionsModel,
listview::ScrollBarType::None);
-
+ optionsList->setBoundaries(Boundaries::Continuous);
optionsList->prepareRebuildCallback = [this]() { recreateOptions(); };
optionsModel->createData(options);
M module-gui/gui/widgets/ListView.cpp => module-gui/gui/widgets/ListView.cpp +16 -3
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ListView.hpp"
@@ 179,7 179,7 @@ namespace gui
style::listview::scroll::h,
scrollBarType);
}
-
+ determineFetchType(scrollBarType);
applyScrollCallbacks();
type = gui::ItemType::LIST;
@@ 209,6 209,20 @@ namespace gui
};
}
+ void ListView::determineFetchType(listview::ScrollBarType scrollType)
+ {
+ switch (scrollType) {
+ case listview::ScrollBarType::None:
+ case listview::ScrollBarType::Fixed:
+ fetchType = listview::FetchType::Fixed;
+ break;
+ case listview::ScrollBarType::Proportional:
+ case listview::ScrollBarType::PreRendered:
+ fetchType = listview::FetchType::Filled;
+ break;
+ }
+ }
+
void ListView::clear()
{
if (scroll) {
@@ 262,5 276,4 @@ namespace gui
{
return Size(request_w, request_h);
}
-
} /* namespace gui */
M module-gui/gui/widgets/ListView.hpp => module-gui/gui/widgets/ListView.hpp +2 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 39,6 39,7 @@ namespace gui
protected:
ListViewScroll *scroll = nullptr;
void applyScrollCallbacks();
+ void determineFetchType(listview::ScrollBarType scrollType);
void setFocus() override;
public:
M module-gui/gui/widgets/ListViewEngine.cpp => module-gui/gui/widgets/ListViewEngine.cpp +19 -7
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "ListViewEngine.hpp"
@@ 275,7 275,7 @@ namespace gui
void ListViewEngine::fillFirstPage()
{
- // Check if first page is filled with items. If not reload page to be filed with items. Check for both
+ // Check if first page is filled with items. If not reload page to be filled with items. Check for both
// Orientations.
if (orientation == listview::Orientation::TopBottom && direction == listview::Direction::Top &&
startIndex == 0) {
@@ 465,10 465,12 @@ namespace gui
{
auto minLimit =
(2 * currentPageSize > calculateMaxItemsOnPage() ? 2 * currentPageSize : calculateMaxItemsOnPage());
- if (value == listview::Direction::Bottom)
+ if (value == listview::Direction::Bottom) {
return (minLimit + startIndex <= elementsCount ? minLimit : elementsCount - startIndex);
- else
+ }
+ else {
return minLimit < startIndex ? minLimit : startIndex;
+ }
}
bool ListViewEngine::requestNextPage()
@@ 503,9 505,18 @@ namespace gui
if (startIndex == 0 && boundaries == Boundaries::Continuous) {
- startIndex = elementsCount;
- topFetchIndex = elementsCount - calculateLimit(listview::Direction::Top);
- limit = calculateLimit(listview::Direction::Top);
+ startIndex = elementsCount;
+ if (elementsCount > currentPageSize && fetchType == listview::FetchType::Fixed) {
+
+ auto calculateFixedFill =
+ elementsCount % currentPageSize != 0 ? elementsCount % currentPageSize : currentPageSize;
+ topFetchIndex = elementsCount - calculateFixedFill;
+ }
+ else {
+ topFetchIndex = elementsCount - calculateLimit(listview::Direction::Top);
+ }
+
+ limit = calculateLimit(listview::Direction::Top);
}
else if (startIndex == 0 && boundaries == Boundaries::Fixed) {
@@ 523,6 534,7 @@ namespace gui
body->setReverseOrder(true);
pageLoaded = false;
storedFocusIndex = listview::nPos;
+
provider->requestRecords(topFetchIndex, limit);
return true;
M module-gui/gui/widgets/ListViewEngine.hpp => module-gui/gui/widgets/ListViewEngine.hpp +10 -1
@@ 1,4 1,4 @@
-// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
+// Copyright (c) 2017-2022, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
@@ 42,6 42,13 @@ namespace gui
///< context and can be time consuming.
};
+ /// Possible page fill types
+ enum class FetchType
+ {
+ Filled, ///< Filled - list always fetch object from provider as long it has space.
+ Fixed ///< Fixed - lists fetches objects from provider accordinly to fixed pages sizes.
+ };
+
enum class Orientation
{
TopBottom,
@@ 150,6 157,8 @@ namespace gui
listview::Direction direction = listview::Direction::Bottom;
/// List orientation (from which end element will start to load)
listview::Orientation orientation = listview::Orientation::TopBottom;
+ /// List fill type
+ listview::FetchType fetchType = listview::FetchType::Filled;
/// Flag to indicate full data request completed
bool requestCompleteData = false;