From 93434f5cdf846b8c25de7897286232a17e0c19e1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 21 Nov 2019 01:30:35 +0100 Subject: Fix clamping of search result in history tab --- src/Body.cpp | 5 +++++ src/QuickMedia.cpp | 10 ++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index db27214..4976a1f 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -50,6 +50,11 @@ namespace QuickMedia { } } + void Body::select_first_item() { + selected_item = 0; + clamp_selection(); + } + void Body::reset_selected() { selected_item = 0; } diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 67e0324..586b23d 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -381,7 +381,7 @@ namespace QuickMedia { update_search_text = text; else { tabs[selected_tab].body->filter_search_fuzzy(text); - tabs[selected_tab].body->selected_item = 0; + tabs[selected_tab].body->clamp_selection(); } }; @@ -456,8 +456,10 @@ namespace QuickMedia { current_page = Page::EXIT; } else if(event.key.code == sf::Keyboard::Left) { selected_tab = std::max(0, selected_tab - 1); + search_bar->clear(); } else if(event.key.code == sf::Keyboard::Right) { selected_tab = std::min((int)tabs.size() - 1, selected_tab + 1); + search_bar->clear(); } } } @@ -540,7 +542,7 @@ namespace QuickMedia { #if 0 search_bar->onTextUpdateCallback = [this](const std::string &text) { body->filter_search_fuzzy(text); - body->selected_item = 0; + body->sele }; search_bar->onTextSubmitCallback = [this](const std::string &text) { @@ -880,7 +882,7 @@ namespace QuickMedia { void Program::episode_list_page() { search_bar->onTextUpdateCallback = [this](const std::string &text) { body->filter_search_fuzzy(text); - body->selected_item = 0; + body->select_first_item(); }; search_bar->onTextSubmitCallback = [this](const std::string &text) -> bool { @@ -1238,7 +1240,7 @@ namespace QuickMedia { search_bar->onTextUpdateCallback = [this](const std::string &text) { body->filter_search_fuzzy(text); - body->selected_item = 0; + body->select_first_item(); }; search_bar->onTextSubmitCallback = [this](const std::string &text) -> bool { -- cgit v1.2.3