From 8e79b2e10827f42d76ec61621f2c484f9cdc2551 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 19 May 2021 23:45:27 +0200 Subject: Start on notifications run matrix delegate on main (ui) thread instead of mutex hell --- src/Body.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src/Body.cpp') diff --git a/src/Body.cpp b/src/Body.cpp index 4f2e816..d51ea29 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -314,10 +314,12 @@ namespace QuickMedia { void Body::prepend_items(BodyItems new_items) { items.insert(items.begin(), std::make_move_iterator(new_items.begin()), std::make_move_iterator(new_items.end())); + items_set_dirty(); } void Body::append_items(BodyItems new_items) { items.insert(items.end(), std::make_move_iterator(new_items.begin()), std::make_move_iterator(new_items.end())); + items_set_dirty(); } // TODO: Binary search and use hint to start search from start or end (for example when adding "previous" items or "next" items) @@ -336,6 +338,7 @@ namespace QuickMedia { for(auto &new_item : new_items) { insert_item_by_timestamp(new_item); } + items_set_dirty(); } void Body::clear_cache() { @@ -486,7 +489,8 @@ namespace QuickMedia { void Body::draw(sf::RenderWindow &window, sf::Vector2f pos, sf::Vector2f size, const Json::Value &content_progress) { if(items_dirty) { items_dirty = false; - filter_search_fuzzy(current_filter); + if(using_filter) + filter_search_fuzzy(current_filter, false); } sf::Vector2f scissor_pos = pos; @@ -1490,7 +1494,7 @@ namespace QuickMedia { return full_match; } - void Body::filter_search_fuzzy(const std::string &text) { + void Body::filter_search_fuzzy(const std::string &text, bool select_first_if_empty) { current_filter = text; if(text.empty()) { @@ -1498,7 +1502,8 @@ namespace QuickMedia { item->visible = true; } - select_first_item(); + if(select_first_if_empty) + select_first_item(); return; } @@ -1507,6 +1512,7 @@ namespace QuickMedia { } select_first_item(); + using_filter = true; } void Body::filter_search_fuzzy_item(const std::string &text, BodyItem *body_item) { -- cgit v1.2.3