Added button to navigate to last page

pull/23/head
JuanJakobo 2021-02-15 19:39:36 +01:00
parent 53ecf7042f
commit ab36cf429f
2 changed files with 9 additions and 1 deletions

View File

@ -66,6 +66,7 @@ ListView::ListView(const irect *contentRect, const vector<Item> &items) : _conte
_firstPageButton = iRect(_contentRect->x, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER);
_prevPageButton = iRect(_contentRect->x + 150, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER);
_nextPageButton = iRect(_contentRect->x + 300, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER);
_lastPageButton = iRect(_contentRect->x + 450, _contentRect->h + _contentRect->y - _footerHeight, 130, _footerHeight, ALIGN_CENTER);
drawEntries();
drawFooter();
@ -102,10 +103,12 @@ void ListView::drawFooter()
DrawTextRect2(&_prevPageButton, "Prev");
FillAreaRect(&_nextPageButton, BLACK);
DrawTextRect2(&_nextPageButton, "Next");
FillAreaRect(&_lastPageButton, BLACK);
DrawTextRect2(&_lastPageButton, "Last");
}
void ListView::drawEntry(int itemID)
{
{
FillAreaRect(_entries[itemID].getPosition(), WHITE);
_entries[itemID].draw(_items->at(itemID), _entryFont, _entryFontBold, _entryFontHeight);
}
@ -152,6 +155,10 @@ int ListView::listClicked(int x, int y)
{
actualizePage(_shownPage - 1);
}
else if (IsInRect(x, y, &_lastPageButton))
{
actualizePage(_page);
}
else
{
for (unsigned int i = 0; i < _entries.size(); i++)

View File

@ -87,6 +87,7 @@ private:
irect _nextPageButton;
irect _prevPageButton;
irect _firstPageButton;
irect _lastPageButton;
int _itemCount = 7;
};
#endif