aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--include/Body.hpp2
-rw-r--r--src/Body.cpp5
-rw-r--r--src/QuickMedia.cpp10
4 files changed, 14 insertions, 4 deletions
diff --git a/.gitignore b/.gitignore
index 3d24e52..385c15f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,4 @@ tests/compile_commands.json
.vscode/
.gdb_history
+.clangd/
diff --git a/include/Body.hpp b/include/Body.hpp
index fd1e438..ae1c3ff 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -33,6 +33,8 @@ namespace QuickMedia {
// Select next item, ignoring invisible items
void select_next_item();
+
+ void select_first_item();
void reset_selected();
void clear_items();
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 {