aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2021-09-22 20:10:48 +0200
committerdec05eba <dec05eba@protonmail.com>2021-09-22 20:10:48 +0200
commitfdeb82815db468ac7e99e9646f57bed2bf1832de (patch)
treeffc1ca95e05f47e26c21cce29f5510275e01787e /src/Body.cpp
parent7934864d58ec39b237e2b45d0180aa567b29b944 (diff)
Sort anilist recommendations by best match, show episode duration, show titles differently
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 5509938..d5395fd 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -441,13 +441,13 @@ namespace QuickMedia {
}
BodyItem* Body::get_selected() const {
- if(selected_item < 0 || selected_item >= (int)items.size() || !items[selected_item]->visible)
+ if(selected_item < 0 || selected_item >= (int)items.size() || !items[selected_item]->visible || !items[selected_item]->is_selectable())
return nullptr;
return items[selected_item].get();
}
std::shared_ptr<BodyItem> Body::get_selected_shared() {
- if(selected_item < 0 || selected_item >= (int)items.size() || !items[selected_item]->visible)
+ if(selected_item < 0 || selected_item >= (int)items.size() || !items[selected_item]->visible || !items[selected_item]->is_selectable())
return nullptr;
return items[selected_item];
}
@@ -694,11 +694,13 @@ namespace QuickMedia {
if(mouse_scroll_accel.y > 0.1f && prev_first_visible_item != -1) {
selected_item = prev_first_visible_item;
// TODO: Cache this
+ // TODO: Selectable item
if(on_top_reached && get_previous_visible_item(selected_item) == -1)
on_top_reached();
} else if(mouse_scroll_accel.y < -0.1f && prev_last_visible_item != -1) {
selected_item = prev_last_visible_item;
// TODO: Cache this
+ // TODO: Selectable item
if(on_bottom_reached && get_next_visible_item(selected_item) == -1)
on_bottom_reached();
}
@@ -1094,7 +1096,7 @@ namespace QuickMedia {
item_pos.x = std::floor(pos.x);
item_pos.y = std::floor(pos.y);
- if(body_theme == BODY_THEME_MODERN_SPACIOUS) {
+ if(body_theme == BODY_THEME_MODERN_SPACIOUS && item->is_selectable()) {
item_background.set_position(item_pos);
item_background.set_size(sf::Vector2f(size.x, item->loaded_height));
item_background.set_color(get_theme().shade_color);
@@ -1273,10 +1275,12 @@ namespace QuickMedia {
new_view.setViewport(sf::FloatRect(0.0f, scissor_y / (float)window_size.y, 1.0f, size.y / (float)window_size.y));
window.setView(new_view);
- item_background.set_position(round(pos + pos_offset));
- item_background.set_size(round(sf::Vector2f(card_width, item_height)));
- item_background.set_color(get_theme().card_item_background_color);
- item_background.draw(window);
+ if(item->is_selectable()) {
+ item_background.set_position(round(pos + pos_offset));
+ item_background.set_size(round(sf::Vector2f(card_width, item_height)));
+ item_background.set_color(get_theme().card_item_background_color);
+ item_background.draw(window);
+ }
handle_item_render(pos + pos_offset, card_width, item_height, item_index);
@@ -1759,11 +1763,15 @@ namespace QuickMedia {
void Body::filter_search_fuzzy_item(const std::string &text, BodyItem *body_item) {
const bool prev_visible = body_item->visible;
- body_item->visible = string_find_fuzzy_case_insensitive(body_item->get_title(), text);
- if(!body_item->visible && !body_item->get_description().empty())
- body_item->visible = string_find_fuzzy_case_insensitive(body_item->get_description(), text);
- if(!body_item->visible && !body_item->get_author().empty())
- body_item->visible = string_find_fuzzy_case_insensitive(body_item->get_author(), text);
+ if(!body_item->is_selectable()) {
+ body_item->visible = true;
+ } else {
+ body_item->visible = string_find_fuzzy_case_insensitive(body_item->get_title(), text);
+ if(!body_item->visible && !body_item->get_description().empty())
+ body_item->visible = string_find_fuzzy_case_insensitive(body_item->get_description(), text);
+ if(!body_item->visible && !body_item->get_author().empty())
+ body_item->visible = string_find_fuzzy_case_insensitive(body_item->get_author(), text);
+ }
if(prev_visible && !body_item->visible) {
clear_body_item_cache(body_item);
@@ -1773,14 +1781,7 @@ namespace QuickMedia {
}
}
- bool Body::no_items_visible() const {
- for(auto &item : items) {
- if(item->visible)
- return false;
- }
- return true;
- }
-
+ // TODO: Selectable
bool Body::is_selected_item_last_visible_item() const {
if(selected_item < 0 || selected_item >= (int)items.size() || !items[selected_item]->visible)
return false;