diff options
author | dec05eba <dec05eba@protonmail.com> | 2022-03-01 11:15:53 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2022-03-01 11:20:39 +0100 |
commit | 29d3f495e3b3be801cbb8c8dbd3f7250ec22415a (patch) | |
tree | 5012ae8a8e8752474128245b6d484c8d263d58a7 /include | |
parent | d1ea6b9f9ae63f2715f2e0b8aa6eedb9a334bf7a (diff) |
SearchBar refactor. Dont show search icon if searchbar is not used for search
Diffstat (limited to 'include')
-rw-r--r-- | include/SearchBar.hpp | 15 |
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 |