diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-05-11 14:24:52 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-05-11 14:24:52 +0200 |
commit | e308d77b06405b91885cf6f97c0dc2a1b70679ef (patch) | |
tree | 7fb0ed73c20354f3e0ff49ebb199e33ebc3427f7 /src/Entry.cpp | |
parent | 6b90f55f4dc14b9d39fa0dbf6b82b3c12ccc29d9 (diff) |
Improve file saving gui
Diffstat (limited to 'src/Entry.cpp')
-rw-r--r-- | src/Entry.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/Entry.cpp b/src/Entry.cpp index 96a34f3..5e18340 100644 --- a/src/Entry.cpp +++ b/src/Entry.cpp @@ -7,7 +7,7 @@ #include <cmath> const float background_margin_horizontal = std::floor(5.0f * QuickMedia::get_ui_scale()); -const float padding_vertical = std::floor(3.0f * QuickMedia::get_ui_scale()); +const float padding_vertical = std::floor(5.0f * QuickMedia::get_ui_scale()); const float background_margin_vertical = std::floor(0.0f * QuickMedia::get_ui_scale()); namespace QuickMedia { @@ -16,7 +16,7 @@ namespace QuickMedia { 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, sf::Color(55, 60, 68), rounded_rectangle_shader), + background(sf::Vector2f(1.0f, 1.0f), 10.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) { @@ -74,6 +74,10 @@ namespace QuickMedia { } } + void Entry::set_single_line(bool single_line) { + text.single_line_edit = single_line; + } + void Entry::set_editable(bool editable) { text.setEditable(editable); } @@ -93,8 +97,8 @@ namespace QuickMedia { void Entry::set_position(const sf::Vector2f &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()))); + text.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical)); + placeholder.setPosition(pos + sf::Vector2f(background_margin_horizontal, background_margin_vertical)); } void Entry::set_max_width(float width) { @@ -102,8 +106,16 @@ namespace QuickMedia { text.setMaxWidth(this->width - background_margin_horizontal * 2.0f); } + bool Entry::is_editable() const { + return text.isEditable(); + } + float Entry::get_height() { text.updateGeometry(); - return std::floor(text.getHeight() + background_margin_vertical * 2.0f + padding_vertical *2.0f); + return std::floor(text.getHeight() + background_margin_vertical * 2.0f + padding_vertical * 2.0f); + } + + const sf::String& Entry::get_text() const { + return text.getString(); } }
\ No newline at end of file |