diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-11-17 09:47:45 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-11-17 09:59:29 +0100 |
commit | 453eac7f1f5ef70390ec51087fc1f190811a7507 (patch) | |
tree | 21a32ef6de9a3d7c29562484104b56c12518a6f0 /include/SearchBar.hpp | |
parent | fc49d40c0d2f6edbbe9dde1f1b53d6a17e9d9f7d (diff) |
Replace sfml with mgl
Diffstat (limited to 'include/SearchBar.hpp')
-rw-r--r-- | include/SearchBar.hpp | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/include/SearchBar.hpp b/include/SearchBar.hpp index 12daf58..9170f7a 100644 --- a/include/SearchBar.hpp +++ b/include/SearchBar.hpp @@ -1,16 +1,17 @@ #pragma once #include "RoundedRectangle.hpp" -#include <SFML/Graphics/Text.hpp> -#include <SFML/Graphics/RectangleShape.hpp> -#include <SFML/Graphics/Sprite.hpp> -#include <SFML/System/Clock.hpp> +#include <mglpp/window/Event.hpp> +#include <mglpp/graphics/Text.hpp> +#include <mglpp/graphics/Rectangle.hpp> +#include <mglpp/graphics/Sprite.hpp> +#include <mglpp/system/Clock.hpp> #include <functional> +#include <string> -namespace sf { +namespace mgl { class Font; - class RenderWindow; - class Event; + class Window; class Shader; } @@ -21,15 +22,15 @@ namespace QuickMedia { class SearchBar { public: - SearchBar(sf::Texture *plugin_logo, sf::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked = false); - void draw(sf::RenderWindow &window, sf::Vector2f size, bool draw_background); - void on_event(sf::Event &event); + SearchBar(mgl::Texture *plugin_logo, mgl::Shader *rounded_rectangle_shader, const std::string &placeholder, bool input_masked = false); + void draw(mgl::Window &window, mgl::vec2f size, bool draw_background); + void on_event(mgl::Window &window, mgl::Event &event); void update(); - void onWindowResize(const sf::Vector2f &window_size); + void onWindowResize(const mgl::vec2f &window_size); void clear(); void set_text(const std::string &text, bool update_search = true); void append_text(const std::string &text_to_add); - void set_position(sf::Vector2f pos); + void set_position(mgl::vec2f pos); void set_editable(bool editable); bool is_editable() const; @@ -42,20 +43,20 @@ namespace QuickMedia { TextUpdateCallback onTextUpdateCallback; TextSubmitCallback onTextSubmitCallback; TextBeginTypingCallback onTextBeginTypingCallback; - int text_autosearch_delay; + int text_autosearch_delay_ms; bool caret_visible; float padding_top = 0.0f; float padding_bottom = 0.0f; float padding_x = 10.0f; private: - void onTextEntered(sf::Uint32 codepoint); + void onTextEntered(const mgl::Event::TextEvent &text_event); private: - sf::Text text; + mgl::Text text; RoundedRectangle background; - sf::RectangleShape shade; - sf::RectangleShape caret; - sf::Sprite plugin_logo_sprite; + mgl::Rectangle shade; + mgl::Rectangle caret; + mgl::Sprite plugin_logo_sprite; std::string placeholder_str; bool show_placeholder; bool updated_search; @@ -65,9 +66,9 @@ namespace QuickMedia { bool typing; bool backspace_pressed; bool mouse_left_inside; - sf::Vector2f pos; - sf::Clock time_since_search_update; - sf::Vector2f prev_size; + mgl::vec2f pos; + mgl::Clock time_since_search_update; + mgl::vec2f prev_size; bool editable = true; }; }
\ No newline at end of file |