diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-11-21 01:30:35 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2019-11-21 01:30:35 +0100 |
commit | 93434f5cdf846b8c25de7897286232a17e0c19e1 (patch) | |
tree | e6ad1c1a9227cff059ba6aaf1e0b26faef4591a9 /src | |
parent | 78f6f8210d76760e3be8d76abe29796a20873e90 (diff) |
Fix clamping of search result in history tab
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 5 | ||||
-rw-r--r-- | src/QuickMedia.cpp | 10 |
2 files changed, 11 insertions, 4 deletions
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 { |