aboutsummaryrefslogtreecommitdiff
path: root/src/Entry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Entry.cpp')
-rw-r--r--src/Entry.cpp15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Entry.cpp b/src/Entry.cpp
index 5a6110c..96a34f3 100644
--- a/src/Entry.cpp
+++ b/src/Entry.cpp
@@ -11,29 +11,28 @@ const float padding_vertical = std::floor(3.0f * QuickMedia::get_ui_scale());
const float background_margin_vertical = std::floor(0.0f * QuickMedia::get_ui_scale());
namespace QuickMedia {
- Entry::Entry(const std::string &placeholder_text) :
+ Entry::Entry(const std::string &placeholder_text, sf::Shader *rounded_rectangle_shader) :
on_submit_callback(nullptr),
draw_background(true),
text("", false, std::floor(16 * get_ui_scale()), 0.0f),
width(0.0f),
- background(sf::Vector2f(1.0f, 1.0f), 7.0f, 10),
+ background(sf::Vector2f(1.0f, 1.0f), 7.0f, sf::Color(55, 60, 68), rounded_rectangle_shader),
placeholder(placeholder_text, *FontLoader::get_font(FontLoader::FontType::LATIN), std::floor(16 * get_ui_scale())),
mouse_left_inside(false)
{
text.setEditable(true);
- background.setFillColor(sf::Color(55, 60, 68));
placeholder.setFillColor(sf::Color(255, 255, 255, 100));
}
void Entry::process_event(sf::Event &event) {
if(is_touch_enabled() && event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) {
- sf::FloatRect box(background.getPosition(), background.getSize());
+ sf::FloatRect box(background.get_position(), background.get_size());
if(box.contains(event.mouseButton.x, event.mouseButton.y))
mouse_left_inside = true;
else
mouse_left_inside = false;
} else if(is_touch_enabled() && event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Left) {
- sf::FloatRect box(background.getPosition(), background.getSize());
+ sf::FloatRect box(background.get_position(), background.get_size());
if(mouse_left_inside && box.contains(event.mouseButton.x, event.mouseButton.y))
show_virtual_keyboard();
mouse_left_inside = false;
@@ -58,9 +57,9 @@ namespace QuickMedia {
// TODO: Set the max number of visible lines and use glScissor to cut off the lines outsides
// (and also split text into lines to not draw them at all once they are not inside the scissor box)
void Entry::draw(sf::RenderWindow &window) {
- background.setSize(sf::Vector2f(width, get_height()));
+ background.set_size(sf::Vector2f(width, get_height()));
if(draw_background)
- window.draw(background);
+ background.draw(window);
if(text.getString().isEmpty() && !text.isEditable()) {
window.draw(placeholder);
@@ -93,7 +92,7 @@ namespace QuickMedia {
}
void Entry::set_position(const sf::Vector2f &pos) {
- background.setPosition(pos);
+ background.set_position(pos);
text.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical - std::floor(3.0f * get_ui_scale())));
placeholder.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical + std::floor(3.0f * get_ui_scale())));
}