diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/Body.hpp | 2 | ||||
-rw-r--r-- | include/Entry.hpp | 4 | ||||
-rw-r--r-- | include/MessageQueue.hpp | 12 | ||||
-rw-r--r-- | include/Text.hpp | 4 |
4 files changed, 17 insertions, 5 deletions
diff --git a/include/Body.hpp b/include/Body.hpp index 4007bc4..abf0d4b 100644 --- a/include/Body.hpp +++ b/include/Body.hpp @@ -369,7 +369,7 @@ namespace QuickMedia { sf::Vector2f item_background_target_pos; sf::Vector2f item_background_prev_size; sf::Vector2f item_background_target_size; - TargetSetState target_y_set = TargetSetState::NOT_SET; + TargetSetState target_set = TargetSetState::NOT_SET; // TODO: Instead of using this, add functions for modifying |items| and apply the filter on those new items DirtyState items_dirty = DirtyState::FALSE; std::string current_filter; diff --git a/include/Entry.hpp b/include/Entry.hpp index 22680b5..1ee237b 100644 --- a/include/Entry.hpp +++ b/include/Entry.hpp @@ -24,11 +24,11 @@ namespace QuickMedia { void set_single_line(bool single_line); void set_editable(bool editable); - void set_text(std::string text); + void set_text(const std::string &text); void set_position(const sf::Vector2f &pos); void set_max_width(float width); void move_caret_to_end(); - void append_text(std::string str); + void append_text(const std::string &str); void replace(size_t start_index, size_t length, const sf::String &insert_str); int get_caret_index() const; diff --git a/include/MessageQueue.hpp b/include/MessageQueue.hpp index 7c34d51..3f38ca2 100644 --- a/include/MessageQueue.hpp +++ b/include/MessageQueue.hpp @@ -4,6 +4,7 @@ #include <mutex> #include <condition_variable> #include <optional> +#include <functional> namespace QuickMedia { template <typename T> @@ -55,6 +56,17 @@ namespace QuickMedia { std::unique_lock<std::mutex> lock(mutex); running = true; } + + // Returns true from |callback| to remove the element + void erase_if(std::function<bool(T&)> callback) { + std::unique_lock<std::mutex> lock(mutex); + for(auto it = data_queue.begin(); it != data_queue.end();) { + if(callback(*it)) + it = data_queue.erase(it); + else + ++it; + } + } private: std::deque<T> data_queue; std::mutex mutex; diff --git a/include/Text.hpp b/include/Text.hpp index 5749072..a39b2ba 100644 --- a/include/Text.hpp +++ b/include/Text.hpp @@ -68,9 +68,9 @@ namespace QuickMedia Text(bool bold_font); Text(sf::String str, bool bold_font, unsigned int characterSize, float maxWidth, bool highlight_urls = false); - void setString(sf::String str); + void setString(const sf::String &str); const sf::String& getString() const; - void appendText(sf::String str); + void appendText(const sf::String &str); void setPosition(float x, float y); void setPosition(const sf::Vector2f &position); |