fix make font sizes in login relative to screen

pull/23/head 0.51
JuanJakobo 2021-01-12 16:28:14 +01:00
parent 3d745a26d6
commit bfe632f67e
2 changed files with 25 additions and 15 deletions

View File

@ -11,7 +11,6 @@
#include "eventHandler.h"
#include <string>
#include <memory>
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);

View File

@ -12,7 +12,6 @@
#include "inkview.h"
#include <string>
#include <memory>
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;