From 18d219175da4d991d2e863af0c6cc67c466b1782 Mon Sep 17 00:00:00 2001 From: JuanJakobo <34421964+JuanJakobo@users.noreply.github.com> Date: Thu, 5 Nov 2020 10:32:12 +0100 Subject: [PATCH] changed UI of loginscreen --- src/handler/eventHandler.cpp | 2 -- src/ui/loginView.cpp | 38 +++++++++++++++++------------------- src/ui/loginView.h | 3 +-- 3 files changed, 19 insertions(+), 24 deletions(-) diff --git a/src/handler/eventHandler.cpp b/src/handler/eventHandler.cpp index 1951bd4..a35f38e 100644 --- a/src/handler/eventHandler.cpp +++ b/src/handler/eventHandler.cpp @@ -38,7 +38,6 @@ EventHandler::EventHandler() } _loginView = std::unique_ptr(new LoginView(_menu.getContentRect())); - _loginView->drawLoginView(); FullUpdate(); } @@ -98,7 +97,6 @@ void EventHandler::mainMenuHandler(const int index) _listView.reset(); _loginView = std::unique_ptr(new LoginView(_menu.getContentRect())); - _loginView->drawLoginView(); FullUpdate(); break; } diff --git a/src/ui/loginView.cpp b/src/ui/loginView.cpp index 5e2f33e..7a9bdfa 100644 --- a/src/ui/loginView.cpp +++ b/src/ui/loginView.cpp @@ -21,26 +21,24 @@ LoginView::LoginView(irect *contentRect) : _contentRect(contentRect) { _loginViewStatic = this; _loginFont = std::unique_ptr(OpenFont("LiberationMono", 40, 1)); -} -void LoginView::drawLoginView() -{ SetFont(_loginFont.get(), BLACK); - FillAreaRect(_contentRect, WHITE); - _urlButton = iRect(50, 200, (ScreenWidth() - 50), 75, ALIGN_CENTER); - DrawLine(20, 275, (ScreenWidth() - 20), 275, BLACK); - DrawTextRect2(&_urlButton, "Url"); - _usernameButton = iRect(50, 400, ScreenWidth() - 50, 75, ALIGN_CENTER); - DrawLine(20, 475, (ScreenWidth() - 20), 475, BLACK); - DrawTextRect2(&_usernameButton, "Username"); + _urlButton = iRect(50, 200, (ScreenWidth() - 100), 75, ALIGN_CENTER); - _passwordButton = iRect(50, 600, (ScreenWidth() - 50), 75, ALIGN_CENTER); - DrawLine(20, 675, (ScreenWidth() - 20), 675, BLACK); - DrawTextRect2(&_passwordButton, "Password"); + DrawTextRect(_urlButton.x, _urlButton.y - 50, _urlButton.w, _urlButton.h, "Server address:", ALIGN_LEFT); + DrawRect(_urlButton.x-1, _urlButton.y-1, _urlButton.w+2, _urlButton.h+2, BLACK); - _loginButton = iRect(ScreenWidth() / 2 - (200 / 2), 700, 200, 50, ALIGN_CENTER); + _usernameButton = iRect(50, 400, ScreenWidth() - 100, 75, ALIGN_CENTER); + DrawTextRect(_usernameButton.x, _usernameButton.y - 50, _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); + DrawRect(_passwordButton.x-1, _passwordButton.y-1, _passwordButton.w+2, _passwordButton.h+2, BLACK); + + _loginButton = iRect(50, 750, (ScreenWidth() - 100), 75, ALIGN_CENTER); FillAreaRect(&_loginButton, BLACK); SetFont(_loginFont.get(), WHITE); @@ -61,13 +59,13 @@ void LoginView::keyboardHandler(char *text) if (s.empty()) return; - if (_test == 1) + if (_keyboardValue == 1) { _url = s.c_str(); FillAreaRect(&_urlButton, WHITE); DrawTextRect2(&_urlButton, s.c_str()); } - else if (_test == 2) + else if (_keyboardValue == 2) { _username = s.c_str(); FillAreaRect(&_usernameButton, WHITE); @@ -96,20 +94,20 @@ int LoginView::logginClicked(int x, int y) if (IsInRect(x, y, &_urlButton)) { - _test = 1; - OpenKeyboard("Url", _charBuffer, MAX_CHAR_BUFF_LENGHT - 1, KBD_NORMAL, &keyboardHandlerStatic); + _keyboardValue = 1; + OpenKeyboard("Server address", _charBuffer, MAX_CHAR_BUFF_LENGHT - 1, KBD_NORMAL, &keyboardHandlerStatic); return 1; } else if (IsInRect(x, y, &_usernameButton)) { - _test = 2; + _keyboardValue = 2; OpenKeyboard("Username", _charBuffer, MAX_CHAR_BUFF_LENGHT - 1, KBD_NORMAL, &keyboardHandlerStatic); return 1; } else if (IsInRect(x, y, &_passwordButton)) { - _test = 3; + _keyboardValue = 3; OpenKeyboard("Password", _charBuffer, MAX_CHAR_BUFF_LENGHT - 1, KBD_PASSWORD, &keyboardHandlerStatic); return 1; diff --git a/src/ui/loginView.h b/src/ui/loginView.h index 2542bd4..f1ffd5a 100644 --- a/src/ui/loginView.h +++ b/src/ui/loginView.h @@ -23,7 +23,6 @@ class LoginView public: LoginView(irect *contentRect); - void drawLoginView(); int logginClicked(int x, int y); string getUsername() { return _username; }; @@ -38,7 +37,7 @@ private: irect _loginButton; irect _usernameButton; irect _passwordButton; - int _test; + int _keyboardValue; string _username; string _password; string _url;