From 6b124f17dbbb6e99c3a279f1a9437a03548fed43 Mon Sep 17 00:00:00 2001 From: Guillaume Virlet Date: Sat, 28 Dec 2019 22:01:56 +0100 Subject: [PATCH] [Fixes #99] dynamically manage height of screen on HD devices --- src/application.cpp | 11 +++++++++++ src/application.h | 2 ++ src/gui/gui.cpp | 7 ++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index 8ce888a..e957082 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -39,6 +39,12 @@ void Application::init() curl_global_init(CURL_GLOBAL_ALL); restoreModeAndPage(); + // we calaculate the number of items to show (we remove the header (35+35+5+2) and + // the footer (35) + // we divide it by the height of an item (114) + // TODO: centralize the item Height and size of header / footer + numPerPage = (int)floor((float)(ScreenHeight()-35-35-5-2-35)/(float(114))); + DEBUG("Nb items per page: %d", numPerPage); } @@ -1066,3 +1072,8 @@ void Application::initAssets() writeIconToFile(PLOP_ICON_SMALL_STARRED_PATH, small_grade_png, small_grade_png_len); } +int Application::getNumItemPerPage() +{ + return numPerPage; +} + diff --git a/src/application.h b/src/application.h index 17c8f3e..3697858 100644 --- a/src/application.h +++ b/src/application.h @@ -77,6 +77,8 @@ class Application void deleteAllLocalData(); void initAssets(); + int getNumItemPerPage(); + private: Database db; WallabagApi wallabag_api; diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index abf43ee..18ec209 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -148,11 +148,12 @@ void Gui::show(int numPage, int numberOfPages, int countAllEntries, std::vector< // TODO déplacer tout ça vers une méthode de changement / chargement de page + int nb_items = app_ref.getNumItemPerPage(); entriesItems.clear(); - entriesItems.resize(8); + entriesItems.resize(nb_items); // Empty the whole area for all items at once - FillArea(0, y, screenWidth, GuiListItemEntry::getHeight()*8 - 1, WHITE); + FillArea(0, y, screenWidth, GuiListItemEntry::getHeight()*nb_items - 1, WHITE); for (unsigned int i=0 ; i