Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down Expand Up @@ -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;
}

2 changes: 2 additions & 0 deletions src/application.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ class Application
void deleteAllLocalData();
void initAssets();

int getNumItemPerPage();

private:
Database db;
WallabagApi wallabag_api;
Expand Down
7 changes: 4 additions & 3 deletions src/gui/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<entriesItems.size() ; i++) {
GuiListItemEntry item(entryTitleFont, entryInfosFont);
Expand Down Expand Up @@ -182,7 +183,7 @@ void Gui::show(int numPage, int numberOfPages, int countAllEntries, std::vector<
}

// Update screen area for all items at once
PartialUpdate(0, y, screenWidth, GuiListItemEntry::getHeight()*8 - 1);
PartialUpdate(0, y, screenWidth, GuiListItemEntry::getHeight()*nb_items - 1);


if (countAllEntries == 0) {
Expand Down