From cbcdbdbf488b73120b2b604343ac64213cdbb1f8 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 5 Jun 2021 13:20:02 +0200 Subject: Improve card handler, less computation --- src/Body.cpp | 8 +++++--- src/QuickMedia.cpp | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 209ba6d..01ae8b7 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -1142,9 +1142,8 @@ namespace QuickMedia { if(item_index == selected_item) selected_column = drawn_column_index; - handle_item_render(pos + pos_offset, card_width, card_height, item_index); - if(item->visible && pos_offset.y + card_height > -body_spacing[body_theme].body_padding_vertical && pos_offset.y < size.y) { + handle_item_render(pos + pos_offset, card_width, card_height, item_index); sf::View new_view(sf::FloatRect(0.0f, 0.0f, window_size.x, size.y)); 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); @@ -1157,7 +1156,7 @@ namespace QuickMedia { item_background.draw(window); { - get_item_height(item, card_max_image_size.x); + get_item_height(item, card_max_image_size.x, true, false, false, item_index); sf::Vector2i thumbnail_size = get_item_thumbnail_size(item); std::shared_ptr item_thumbnail; if(draw_thumbnails && !item->thumbnail_url.empty()) @@ -1249,6 +1248,9 @@ namespace QuickMedia { if(last_visible_item == -1 || item_index > last_visible_item) last_visible_item = item_index; } else { + if(item_index == selected_item) + handle_item_render(pos + pos_offset, card_width, card_height, item_index); + if(item->keep_alive_frames == 0) { clear_body_item_cache(item); // TODO: Make sure the embedded item is not referencing another item in the |items| list diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp index 68a86e0..48d73d5 100644 --- a/src/QuickMedia.cpp +++ b/src/QuickMedia.cpp @@ -1056,7 +1056,7 @@ namespace QuickMedia { } if(strcmp(plugin_name, "launcher") == 0) { - auto pipe_body = create_body(); + auto pipe_body = create_body(true); pipe_body->items.push_back(create_launcher_body_item("4chan", "4chan", resources_root + "icons/4chan_launcher.png")); pipe_body->items.push_back(create_launcher_body_item("Manga (all)", "manga", "")); pipe_body->items.push_back(create_launcher_body_item("Mangadex", "mangadex", resources_root + "icons/mangadex_launcher.png")); -- cgit v1.2.3