diff --git a/src/ui/loginView.cpp b/src/ui/loginView.cpp index e71dfee..1f721f9 100644 --- a/src/ui/loginView.cpp +++ b/src/ui/loginView.cpp @@ -11,7 +11,6 @@ #include "eventHandler.h" #include -#include using std::string; @@ -21,23 +20,33 @@ LoginView::LoginView(const irect *contentRect) : _contentRect(contentRect) { _loginViewStatic = this; + int contentHeight = contentRect->h / 2; + int contentWidth = _contentRect->w * 0.9; + + int beginY = 0.4 * contentHeight; + int beginX = (_contentRect->w - contentWidth) / 2; + + int contents = contentHeight / 7; + + _loginFontHeight = contents / 2; + + _loginFont = OpenFont("LiberationMono", _loginFontHeight, 1); SetFont(_loginFont, BLACK); FillAreaRect(_contentRect, WHITE); - _urlButton = iRect(50, 200, (ScreenWidth() - 100), 75, ALIGN_CENTER); - - DrawTextRect(_urlButton.x, _urlButton.y - 50, _urlButton.w, _urlButton.h, "Server address:", ALIGN_LEFT); + _urlButton = iRect(beginX, beginY, contentWidth, contents, ALIGN_CENTER); + DrawTextRect(_urlButton.x, _urlButton.y - _loginFontHeight - _loginFontHeight/2, _urlButton.w, _urlButton.h, "Server address:", ALIGN_LEFT); DrawRect(_urlButton.x - 1, _urlButton.y - 1, _urlButton.w + 2, _urlButton.h + 2, BLACK); - _usernameButton = iRect(50, 400, ScreenWidth() - 100, 75, ALIGN_CENTER); - DrawTextRect(_usernameButton.x, _usernameButton.y - 50, _usernameButton.w, _usernameButton.h, "Username:", ALIGN_LEFT); + _usernameButton = iRect(beginX, beginY + 2 * contents, contentWidth, contents, ALIGN_CENTER); + DrawTextRect(_usernameButton.x, _usernameButton.y - _loginFontHeight - _loginFontHeight/3, _usernameButton.w, _usernameButton.h, "Username:", ALIGN_LEFT); DrawRect(_usernameButton.x - 1, _usernameButton.y - 1, _usernameButton.w + 2, _usernameButton.h + 2, BLACK); - _passwordButton = iRect(50, 600, (ScreenWidth() - 100), 75, ALIGN_CENTER); - DrawTextRect(_passwordButton.x, _passwordButton.y - 50, _passwordButton.w, _passwordButton.h, "Password:", ALIGN_LEFT); + _passwordButton = iRect(beginX, beginY + 4 * contents, contentWidth, contents, ALIGN_CENTER); + DrawTextRect(_passwordButton.x, _passwordButton.y - _loginFontHeight - _loginFontHeight/4, _passwordButton.w, _passwordButton.h, "Password:", ALIGN_LEFT); DrawRect(_passwordButton.x - 1, _passwordButton.y - 1, _passwordButton.w + 2, _passwordButton.h + 2, BLACK); - _loginButton = iRect(50, 750, (ScreenWidth() - 100), 75, ALIGN_CENTER); + _loginButton = iRect(beginX, beginY + 6 * contents, contentWidth, contents, ALIGN_CENTER); FillAreaRect(&_loginButton, BLACK); SetFont(_loginFont, WHITE); @@ -48,6 +57,7 @@ LoginView::~LoginView() { CloseFont(_loginFont); } + void LoginView::keyboardHandlerStatic(char *text) { _loginViewStatic->keyboardHandler(text); @@ -96,17 +106,17 @@ int LoginView::logginClicked(int x, int y) if (IsInRect(x, y, &_urlButton)) { _target = KeyboardTarget::IURL; - if(!_url.empty()) + if (!_url.empty()) _temp = _url; _temp.resize(KEYBOARD_STRING_LENGHT); - OpenKeyboard("Server address", &_temp[0],KEYBOARD_STRING_LENGHT - 1, KBD_NORMAL, &keyboardHandlerStatic); + OpenKeyboard("Server address", &_temp[0], KEYBOARD_STRING_LENGHT - 1, KBD_NORMAL, &keyboardHandlerStatic); return 1; } else if (IsInRect(x, y, &_usernameButton)) { _target = KeyboardTarget::IUSERNAME; - if(!_username.empty()) + if (!_username.empty()) _temp = _username; _temp.resize(KEYBOARD_STRING_LENGHT); OpenKeyboard("Username", &_temp[0], KEYBOARD_STRING_LENGHT, KBD_NORMAL, &keyboardHandlerStatic); @@ -116,7 +126,7 @@ int LoginView::logginClicked(int x, int y) { _target = KeyboardTarget::IPASSWORD; _temp.resize(KEYBOARD_STRING_LENGHT); - OpenKeyboard("Password",&_temp[0], KEYBOARD_STRING_LENGHT, KBD_PASSWORD, &keyboardHandlerStatic); + OpenKeyboard("Password", &_temp[0], KEYBOARD_STRING_LENGHT, KBD_PASSWORD, &keyboardHandlerStatic); return 1; } diff --git a/src/ui/loginView.h b/src/ui/loginView.h index bdb7b8d..5e54d9d 100644 --- a/src/ui/loginView.h +++ b/src/ui/loginView.h @@ -12,7 +12,6 @@ #include "inkview.h" #include -#include using std::string; @@ -40,7 +39,8 @@ public: private: static LoginView *_loginViewStatic; - ifont *_loginFont = OpenFont("LiberationMono", 40, 1); + int _loginFontHeight; + ifont *_loginFont; const irect *_contentRect; irect _urlButton; irect _loginButton;