move fonts to listView and close using inkview met
parent
73adc742fd
commit
c32bcc03f0
|
@ -23,9 +23,6 @@ ListView::ListView(const irect *contentRect, const std::shared_ptr<vector<Item>>
|
||||||
{
|
{
|
||||||
FillAreaRect(_contentRect, WHITE);
|
FillAreaRect(_contentRect, WHITE);
|
||||||
|
|
||||||
_titleFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", 35, 1));
|
|
||||||
_footerFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", 30, 1));
|
|
||||||
|
|
||||||
_entries.clear();
|
_entries.clear();
|
||||||
|
|
||||||
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / _itemCount;
|
int entrySize = (_contentRect->h - _footerHeight - _headerHeight) / _itemCount;
|
||||||
|
@ -65,11 +62,15 @@ ListView::ListView(const irect *contentRect, const std::shared_ptr<vector<Item>>
|
||||||
|
|
||||||
ListView::~ListView()
|
ListView::~ListView()
|
||||||
{
|
{
|
||||||
|
CloseFont(_entryFont);
|
||||||
|
CloseFont(_entryFontBold);
|
||||||
|
CloseFont(_titleFont);
|
||||||
|
CloseFont(_footerFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListView::drawHeader(string headerText)
|
void ListView::drawHeader(string headerText)
|
||||||
{
|
{
|
||||||
SetFont(_titleFont.get(), BLACK);
|
SetFont(_titleFont, BLACK);
|
||||||
Util::decodeUrl(headerText);
|
Util::decodeUrl(headerText);
|
||||||
DrawTextRect(_contentRect->x, _contentRect->y, _contentRect->w, _headerHeight - 1, headerText.c_str(), ALIGN_LEFT);
|
DrawTextRect(_contentRect->x, _contentRect->y, _contentRect->w, _headerHeight - 1, headerText.c_str(), ALIGN_LEFT);
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ void ListView::drawHeader(string headerText)
|
||||||
|
|
||||||
void ListView::drawFooter()
|
void ListView::drawFooter()
|
||||||
{
|
{
|
||||||
SetFont(_footerFont.get(), WHITE);
|
SetFont(_footerFont, WHITE);
|
||||||
string footer = Util::valueToString<int>(_shownPage) + "/" + Util::valueToString<int>(_page);
|
string footer = Util::valueToString<int>(_shownPage) + "/" + Util::valueToString<int>(_page);
|
||||||
FillAreaRect(&_pageIcon, BLACK);
|
FillAreaRect(&_pageIcon, BLACK);
|
||||||
|
|
||||||
|
@ -95,7 +96,7 @@ void ListView::drawFooter()
|
||||||
void ListView::drawEntry(int itemID)
|
void ListView::drawEntry(int itemID)
|
||||||
{
|
{
|
||||||
FillAreaRect(_entries[itemID].getPosition(), WHITE);
|
FillAreaRect(_entries[itemID].getPosition(), WHITE);
|
||||||
_entries[itemID].draw(_items->at(itemID));
|
_entries[itemID].draw(_items->at(itemID), _entryFont, _entryFontBold, _fontHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListView::drawEntries()
|
void ListView::drawEntries()
|
||||||
|
@ -103,7 +104,7 @@ void ListView::drawEntries()
|
||||||
for (auto i = 0; i < _entries.size(); i++)
|
for (auto i = 0; i < _entries.size(); i++)
|
||||||
{
|
{
|
||||||
if (_entries[i].getPage() == _shownPage)
|
if (_entries[i].getPage() == _shownPage)
|
||||||
_entries[i].draw(_items->at(i));
|
_entries[i].draw(_items->at(i), _entryFont, _entryFontBold, _fontHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,19 +69,22 @@ public:
|
||||||
int listClicked(int x, int y);
|
int listClicked(int x, int y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
int _footerHeight = 100;
|
||||||
|
int _headerHeight = 40;
|
||||||
|
int _fontHeight = 30;
|
||||||
const irect *_contentRect;
|
const irect *_contentRect;
|
||||||
const std::shared_ptr<vector<Item>> _items = nullptr;
|
const std::shared_ptr<vector<Item>> _items = nullptr;
|
||||||
vector<ListViewEntry> _entries;
|
vector<ListViewEntry> _entries;
|
||||||
std::unique_ptr<ifont> _titleFont;
|
ifont *_titleFont = OpenFont("LiberationMono", 35, 1);
|
||||||
std::unique_ptr<ifont> _footerFont;
|
ifont *_footerFont = OpenFont("LiberationMono", 30, 1);
|
||||||
|
ifont *_entryFont = OpenFont("LiberationMono", _fontHeight, 1);
|
||||||
|
ifont *_entryFontBold = OpenFont("LiberationMono-Bold", _fontHeight, 1);
|
||||||
int _page;
|
int _page;
|
||||||
int _shownPage;
|
int _shownPage;
|
||||||
irect _pageIcon;
|
irect _pageIcon;
|
||||||
irect _nextPageButton;
|
irect _nextPageButton;
|
||||||
irect _lastPageButton;
|
irect _lastPageButton;
|
||||||
irect _firstPageButton;
|
irect _firstPageButton;
|
||||||
int _footerHeight = 100;
|
|
||||||
int _headerHeight = 40;
|
|
||||||
int _itemCount = 7;
|
int _itemCount = 7;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -17,34 +17,34 @@ ListViewEntry::ListViewEntry(int page, irect rect) : _page(page), _position(rect
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ListViewEntry::draw(const Item &item)
|
void ListViewEntry::draw(const Item &item, ifont *entryFont, ifont *entryFontBold, int fontHeight)
|
||||||
{
|
{
|
||||||
SetFont(_entryFontBold.get(), BLACK);
|
SetFont(entryFontBold, BLACK);
|
||||||
DrawTextRect(_position.x, _position.y, _position.w, _fontHeight, item.getTitle().c_str(), ALIGN_LEFT);
|
DrawTextRect(_position.x, _position.y, _position.w, fontHeight, item.getTitle().c_str(), ALIGN_LEFT);
|
||||||
|
|
||||||
SetFont(_entryFont.get(), BLACK);
|
SetFont(entryFont, BLACK);
|
||||||
|
|
||||||
if (item.getState() == FileState::ILOCAL)
|
if (item.getState() == FileState::ILOCAL)
|
||||||
{
|
{
|
||||||
DrawTextRect(_position.x, _position.y + 3 * _fontHeight, _position.w, _fontHeight, "Local", ALIGN_RIGHT);
|
DrawTextRect(_position.x, _position.y + 3 * fontHeight, _position.w, fontHeight, "Local", ALIGN_RIGHT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (item.getType() == IFILE)
|
if (item.getType() == IFILE)
|
||||||
{
|
{
|
||||||
DrawTextRect(_position.x, _position.y + _fontHeight, _position.w, _fontHeight, item.getFiletype().c_str(), ALIGN_LEFT);
|
DrawTextRect(_position.x, _position.y + fontHeight, _position.w, fontHeight, item.getFiletype().c_str(), ALIGN_LEFT);
|
||||||
|
|
||||||
if (item.getState() == FileState::ISYNCED)
|
if (item.getState() == FileState::ISYNCED)
|
||||||
{
|
{
|
||||||
DrawTextRect(_position.x, _position.y + 3 * _fontHeight, _position.w, _fontHeight, "Synced", ALIGN_RIGHT);
|
DrawTextRect(_position.x, _position.y + 3 * fontHeight, _position.w, fontHeight, "Synced", ALIGN_RIGHT);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DrawTextRect(_position.x, _position.y + 3 * _fontHeight, _position.w, _fontHeight, "Click to Download", ALIGN_RIGHT);
|
DrawTextRect(_position.x, _position.y + 3 * fontHeight, _position.w, fontHeight, "Click to Download", ALIGN_RIGHT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DrawTextRect(_position.x, _position.y + 2 * _fontHeight, _position.w, _fontHeight, item.getLastEditDate().c_str(), ALIGN_LEFT);
|
DrawTextRect(_position.x, _position.y + 2 * fontHeight, _position.w, fontHeight, item.getLastEditDate().c_str(), ALIGN_LEFT);
|
||||||
DrawTextRect(_position.x, _position.y + 3 * _fontHeight, _position.w, _fontHeight, item.getSize().c_str(), ALIGN_LEFT);
|
DrawTextRect(_position.x, _position.y + 3 * fontHeight, _position.w, fontHeight, item.getSize().c_str(), ALIGN_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
int line = (_position.y + _position.h) - 1;
|
int line = (_position.y + _position.h) - 1;
|
||||||
|
|
|
@ -33,14 +33,10 @@ public:
|
||||||
*
|
*
|
||||||
* @param item item that shall be drawn
|
* @param item item that shall be drawn
|
||||||
*/
|
*/
|
||||||
void draw(const Item &item);
|
void draw(const Item &item, ifont *entryFont, ifont *entryFontBold, int fontHeight);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _page;
|
int _page;
|
||||||
//TODO in central class?
|
|
||||||
int _fontHeight = 30;
|
|
||||||
std::unique_ptr<ifont> _entryFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", _fontHeight, 1));;
|
|
||||||
std::unique_ptr<ifont> _entryFontBold = std::unique_ptr<ifont>(OpenFont("LiberationMono-Bold", _fontHeight, 1));
|
|
||||||
irect _position;
|
irect _position;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
|
@ -20,9 +20,8 @@ LoginView *LoginView::_loginViewStatic;
|
||||||
LoginView::LoginView(const irect *contentRect) : _contentRect(contentRect)
|
LoginView::LoginView(const irect *contentRect) : _contentRect(contentRect)
|
||||||
{
|
{
|
||||||
_loginViewStatic = this;
|
_loginViewStatic = this;
|
||||||
_loginFont = std::unique_ptr<ifont>(OpenFont("LiberationMono", 40, 1));
|
|
||||||
|
|
||||||
SetFont(_loginFont.get(), BLACK);
|
SetFont(_loginFont, BLACK);
|
||||||
FillAreaRect(_contentRect, WHITE);
|
FillAreaRect(_contentRect, WHITE);
|
||||||
|
|
||||||
_urlButton = iRect(50, 200, (ScreenWidth() - 100), 75, ALIGN_CENTER);
|
_urlButton = iRect(50, 200, (ScreenWidth() - 100), 75, ALIGN_CENTER);
|
||||||
|
@ -41,10 +40,14 @@ LoginView::LoginView(const irect *contentRect) : _contentRect(contentRect)
|
||||||
_loginButton = iRect(50, 750, (ScreenWidth() - 100), 75, ALIGN_CENTER);
|
_loginButton = iRect(50, 750, (ScreenWidth() - 100), 75, ALIGN_CENTER);
|
||||||
|
|
||||||
FillAreaRect(&_loginButton, BLACK);
|
FillAreaRect(&_loginButton, BLACK);
|
||||||
SetFont(_loginFont.get(), WHITE);
|
SetFont(_loginFont, WHITE);
|
||||||
DrawTextRect2(&_loginButton, "Login");
|
DrawTextRect2(&_loginButton, "Login");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LoginView::~LoginView()
|
||||||
|
{
|
||||||
|
CloseFont(_loginFont);
|
||||||
|
}
|
||||||
void LoginView::keyboardHandlerStatic(char *text)
|
void LoginView::keyboardHandlerStatic(char *text)
|
||||||
{
|
{
|
||||||
_loginViewStatic->keyboardHandler(text);
|
_loginViewStatic->keyboardHandler(text);
|
||||||
|
|
|
@ -30,6 +30,8 @@ class LoginView
|
||||||
public:
|
public:
|
||||||
LoginView(const irect *contentRect);
|
LoginView(const irect *contentRect);
|
||||||
|
|
||||||
|
~LoginView();
|
||||||
|
|
||||||
int logginClicked(int x, int y);
|
int logginClicked(int x, int y);
|
||||||
|
|
||||||
string getUsername() { return _username; };
|
string getUsername() { return _username; };
|
||||||
|
@ -38,7 +40,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static LoginView *_loginViewStatic;
|
static LoginView *_loginViewStatic;
|
||||||
std::unique_ptr<ifont> _loginFont;
|
ifont *_loginFont = OpenFont("LiberationMono", 40, 1);
|
||||||
const irect *_contentRect;
|
const irect *_contentRect;
|
||||||
irect _urlButton;
|
irect _urlButton;
|
||||||
irect _loginButton;
|
irect _loginButton;
|
||||||
|
|
Loading…
Reference in New Issue