From a213862c5e34116890e210eda71ea04758149f98 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 7 Dec 2019 18:20:17 +0100 Subject: Do not clear page when exiting video. Clear thumbnails when clearing items --- include/QuickMedia.hpp | 2 +- src/Body.cpp | 2 +- src/QuickMedia.cpp | 12 +++++++----- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/QuickMedia.hpp b/include/QuickMedia.hpp index 9cc85d5..a9d1a72 100644 --- a/include/QuickMedia.hpp +++ b/include/QuickMedia.hpp @@ -25,7 +25,7 @@ namespace QuickMedia { Plugin* get_current_plugin() { return current_plugin; } private: - void base_event_handler(sf::Event &event, Page previous_page, bool handle_key_press = true); + void base_event_handler(sf::Event &event, Page previous_page, bool handle_key_press = true, bool clear_on_escape = true); void search_suggestion_page(); void search_result_page(); void video_content_page(); diff --git a/src/Body.cpp b/src/Body.cpp index 27e09f9..ac809eb 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -72,7 +72,7 @@ namespace QuickMedia { void Body::clear_items() { items.clear(); selected_item = 0; - //item_thumbnail_textures.clear(); + item_thumbnail_textures.clear(); } BodyItem* Body::get_selected() const { diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index e2fc237..a9e5a89 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -234,7 +234,7 @@ namespace QuickMedia { return 0; } - void Program::base_event_handler(sf::Event &event, Page previous_page, bool handle_keypress) { + void Program::base_event_handler(sf::Event &event, Page previous_page, bool handle_keypress, bool clear_on_escape) { if (event.type == sf::Event::Closed) { current_page = Page::EXIT; } else if(event.type == sf::Event::Resized) { @@ -249,9 +249,11 @@ namespace QuickMedia { body->select_next_item(); } else if(event.key.code == sf::Keyboard::Escape) { current_page = previous_page; - body->clear_items(); - body->reset_selected(); - search_bar->clear(); + if(clear_on_escape) { + body->clear_items(); + body->reset_selected(); + search_bar->clear(); + } } } else if(event.type == sf::Event::TextEntered) { search_bar->onTextEntered(event.text.unicode); @@ -764,7 +766,7 @@ namespace QuickMedia { while (current_page == Page::VIDEO_CONTENT) { while (window.pollEvent(event)) { - base_event_handler(event, previous_page); + base_event_handler(event, previous_page, true, false); if(event.type == sf::Event::Resized) { if(video_player_ui_window) ui_resize = true; -- cgit v1.2.3