aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/SearchBar.hpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp
index 19cd121..514b33e 100644
--- a/include/SearchBar.hpp
+++ b/include/SearchBar.hpp
@@ -20,9 +20,15 @@ namespace QuickMedia {
using TextSubmitCallback = std::function<void(const std::string &text)>;
using TextBeginTypingCallback = std::function<void()>;
+ enum class SearchBarType {
+ Search,
+ Text,
+ Password
+ };
+
class SearchBar {
public:
- SearchBar(mgl::Texture *plugin_logo, mgl::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked = false);
+ SearchBar(mgl::Texture *plugin_logo, mgl::Shader *rounded_rectangle_shader, const std::string &placeholder, SearchBarType type);
void draw(mgl::Window &window, mgl::vec2f size, bool draw_background);
void on_event(mgl::Window &window, mgl::Event &event);
void update();
@@ -37,7 +43,7 @@ namespace QuickMedia {
float getBottom() const;
float getBottomWithoutShadow() const;
- std::string get_text() const;
+ const std::string& get_text() const;
bool is_empty() const;
TextUpdateCallback onTextUpdateCallback;
@@ -53,17 +59,15 @@ namespace QuickMedia {
void onTextEntered(const mgl::Event::TextEvent &text_event);
private:
mgl::Text text;
+ mgl::Text placeholder_text;
RoundedRectangle background;
mgl::Rectangle shade;
mgl::Rectangle caret;
mgl::Sprite plugin_logo_sprite;
mgl::Sprite search_icon_sprite;
- std::string placeholder_str;
- bool show_placeholder;
bool updated_search;
bool draw_logo;
bool needs_update;
- bool input_masked;
bool typing;
bool backspace_pressed;
bool mouse_left_inside;
@@ -71,5 +75,6 @@ namespace QuickMedia {
mgl::Clock time_since_search_update;
mgl::vec2f prev_size;
bool editable = true;
+ SearchBarType type;
};
} \ No newline at end of file