forked from sschellhoff/SFMLGameDevelopmentByExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI_TextField.cpp
More file actions
31 lines (30 loc) · 1021 Bytes
/
Copy pathGUI_TextField.cpp
File metadata and controls
31 lines (30 loc) · 1021 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "GUI_Textfield.h"
#include <algorithm>
#include <iostream>
#include "Utilities.h"
GUI_Textfield::GUI_Textfield(const std::string& l_name, GUI_Interface* l_owner)
: GUI_Element(l_name, GUI_ElementType::Textfield , l_owner){}
GUI_Textfield::~GUI_Textfield(){}
void GUI_Textfield::ReadIn(std::stringstream& l_stream){
std::string content;
Utils::ReadQuotedString(l_stream, content);
m_visual.m_text.setString(content);
}
void GUI_Textfield::OnClick(const sf::Vector2f& l_mousePos){
SetState(GUI_ElementState::Clicked);
}
void GUI_Textfield::OnRelease(){}
void GUI_Textfield::OnHover(const sf::Vector2f& l_mousePos){
SetState(GUI_ElementState::Focused);
}
void GUI_Textfield::OnLeave(){
SetState(GUI_ElementState::Neutral);
}
void GUI_Textfield::Update(float l_dT){}
void GUI_Textfield::Draw(sf::RenderTarget* l_target){
l_target->draw(m_visual.m_backgroundSolid);
if (m_style[m_state].m_glyph != ""){
l_target->draw(m_visual.m_glyph);
}
l_target->draw(m_visual.m_text);
}