Username, password icons for Login window
This commit is contained in:
parent
136675b56a
commit
ba5efb101e
@ -639,8 +639,13 @@ void Graphics::draw_icon(int x, int y, Icon icon)
|
||||
case IconReport:
|
||||
drawchar(x, y, 0xE3, 255, 255, 0, 255);
|
||||
break;
|
||||
case IconFavourite:
|
||||
drawchar(x, y, 0xCC, 192, 160, 64, 255);
|
||||
case IconUsername:
|
||||
drawchar(x, y, 0x8B, 32, 64, 128, 255);
|
||||
drawchar(x, y, 0x8A, 255, 255, 255, 255);
|
||||
break;
|
||||
case IconPassword:
|
||||
drawchar(x, y, 0x8C, 160, 144, 32, 255);
|
||||
drawchar(x, y, 0x84, 255, 255, 255, 255);
|
||||
break;
|
||||
case IconVoteSort:
|
||||
case IconDateSort:
|
||||
|
@ -87,7 +87,9 @@ enum Icon
|
||||
IconFolder,
|
||||
IconSearch,
|
||||
IconDelete,
|
||||
IconReport
|
||||
IconReport,
|
||||
IconUsername,
|
||||
IconPassword
|
||||
};
|
||||
|
||||
//"Graphics lite" - slightly lower performance due to variable size,
|
||||
|
@ -11,7 +11,6 @@ using namespace ui;
|
||||
Textbox::Textbox(Point position, Point size, std::string textboxText):
|
||||
Component(position, size),
|
||||
text(textboxText),
|
||||
textPosition(ui::Point(0, 0)),
|
||||
actionCallback(NULL),
|
||||
masked(false),
|
||||
border(true)
|
||||
@ -26,19 +25,32 @@ Textbox::~Textbox()
|
||||
delete actionCallback;
|
||||
}
|
||||
|
||||
void Textbox::TextPosition()
|
||||
{
|
||||
if(cursor)
|
||||
{
|
||||
cursorPosition = Graphics::textnwidth((char *)displayText.c_str(), cursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
cursorPosition = 0;
|
||||
}
|
||||
Component::TextPosition(displayText);
|
||||
}
|
||||
|
||||
void Textbox::SetText(std::string text)
|
||||
{
|
||||
cursor = text.length();
|
||||
this->text = text;
|
||||
this->displayText = text;
|
||||
TextPosition(displayText);
|
||||
TextPosition();
|
||||
}
|
||||
|
||||
|
||||
void Textbox::SetDisplayText(std::string text)
|
||||
{
|
||||
displayText = text;
|
||||
TextPosition(displayText);
|
||||
TextPosition();
|
||||
}
|
||||
|
||||
std::string Textbox::GetText()
|
||||
@ -129,14 +141,14 @@ void Textbox::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool
|
||||
if(actionCallback)
|
||||
actionCallback->TextChangedCallback(this);
|
||||
}
|
||||
TextPosition(displayText);
|
||||
TextPosition();
|
||||
}
|
||||
|
||||
void Textbox::Draw(const Point& screenPos)
|
||||
{
|
||||
if(!drawn)
|
||||
{
|
||||
TextPosition(displayText);
|
||||
TextPosition();
|
||||
drawn = true;
|
||||
}
|
||||
Graphics * g = Engine::Ref().g;
|
||||
@ -150,4 +162,6 @@ void Textbox::Draw(const Point& screenPos)
|
||||
if(border) g->drawrect(screenPos.X, screenPos.Y, Size.X, Size.Y, 160, 160, 160, 255);
|
||||
}
|
||||
g->drawtext(screenPos.X+textPosition.X, screenPos.Y+textPosition.Y, displayText, 255, 255, 255, 255);
|
||||
if(Appearance.icon)
|
||||
g->draw_icon(screenPos.X+iconPosition.X, screenPos.Y+iconPosition.Y, Appearance.icon);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ class Textbox : public Component
|
||||
protected:
|
||||
std::string text;
|
||||
std::string displayText;
|
||||
ui::Point textPosition;
|
||||
int cursor, cursorPosition;
|
||||
TextboxAction *actionCallback;
|
||||
bool masked;
|
||||
@ -40,6 +39,8 @@ public:
|
||||
bool GetHidden() { return masked; }
|
||||
|
||||
void SetBorder(bool border) {this->border = border;}
|
||||
|
||||
void TextPosition();
|
||||
|
||||
virtual void Draw(const Point& screenPos);
|
||||
};
|
||||
|
@ -41,6 +41,11 @@ LoginView::LoginView():
|
||||
targetSize(0, 0)
|
||||
{
|
||||
targetSize = Size;
|
||||
|
||||
infoLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; infoLabel->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
infoLabel->Visible = false;
|
||||
AddComponent(infoLabel);
|
||||
|
||||
AddComponent(loginButton);
|
||||
loginButton->Appearance.HorizontalAlign = ui::Appearance::AlignRight;
|
||||
loginButton->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
@ -54,13 +59,12 @@ LoginView::LoginView():
|
||||
titleLabel->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; titleLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||
|
||||
AddComponent(usernameField);
|
||||
usernameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; usernameField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||
usernameField->Appearance.icon = IconUsername;
|
||||
usernameField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; usernameField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
AddComponent(passwordField);
|
||||
passwordField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; passwordField->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||
passwordField->Appearance.icon = IconPassword;
|
||||
passwordField->Appearance.HorizontalAlign = ui::Appearance::AlignLeft; passwordField->Appearance.VerticalAlign = ui::Appearance::AlignMiddle;
|
||||
passwordField->SetHidden(true);
|
||||
infoLabel->Appearance.HorizontalAlign = ui::Appearance::AlignCentre; infoLabel->Appearance.VerticalAlign = ui::Appearance::AlignBottom;
|
||||
infoLabel->Visible = false;
|
||||
AddComponent(infoLabel);
|
||||
}
|
||||
|
||||
void LoginView::OnKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool alt)
|
||||
@ -102,14 +106,14 @@ void LoginView::OnTick(float dt)
|
||||
ui::Point difference = targetSize-Size;
|
||||
if(difference.X!=0)
|
||||
{
|
||||
int xdiff = difference.X/100;
|
||||
int xdiff = difference.X/5;
|
||||
if(xdiff == 0)
|
||||
xdiff = 1*isign(difference.X);
|
||||
Size.X += xdiff;
|
||||
}
|
||||
if(difference.Y!=0)
|
||||
{
|
||||
int ydiff = difference.Y/100;
|
||||
int ydiff = difference.Y/5;
|
||||
if(ydiff == 0)
|
||||
ydiff = 1*isign(difference.Y);
|
||||
Size.Y += ydiff;
|
||||
|
Loading…
Reference in New Issue
Block a user