From 05df15fb05ed5a8c174ac11edf13aa15060b623d Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 6 Jun 2021 00:43:48 +0200 Subject: Do not move in body when moving to another tab with arrow keys --- TODO | 3 ++- src/Body.cpp | 14 +++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index a1ae9ff..cc762ab 100644 --- a/TODO +++ b/TODO @@ -150,4 +150,5 @@ To fix jitter in body when items are added before the selected item, we should i Cancel current search when search is updated. Support 4chan archive. Use old method of rendering body where rendering items is done up and down, starting from the selected item. This will make quickmedia run as fast when displaying 100 000 items as when displaying 10 items. -Use correct spacing when in grid (card) mode. Should be row spacing instead of body spacing. \ No newline at end of file +Use correct spacing when in grid (card) mode. Should be row spacing instead of body spacing. +Instead of selecting the first/last item when reaching the top/bottom, keep the selected column and instead scroll the body so the first/last item is visible. \ No newline at end of file diff --git a/src/Body.cpp b/src/Body.cpp index d2af084..e04bc56 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -434,7 +434,7 @@ namespace QuickMedia { if(!bottom_reached && on_bottom_reached) on_bottom_reached(); return true; - } else if(rendering_card_view && selected_column > 0 && (event.key.code == sf::Keyboard::Left || (event.key.control && event.key.code == sf::Keyboard::H))) { + } else if(rendering_card_view && selected_column > 0 && ((!event.key.control && event.key.code == sf::Keyboard::Left) || (event.key.control && event.key.code == sf::Keyboard::H))) { render_selected_item_bg = true; const int new_selected_item = get_previous_visible_item(selected_item); if(new_selected_item != -1) { @@ -443,7 +443,7 @@ namespace QuickMedia { on_top_reached(); } return true; - } else if(rendering_card_view && selected_column + 1 < num_columns && (event.key.code == sf::Keyboard::Right || (event.key.control && event.key.code == sf::Keyboard::L))) { + } else if(rendering_card_view && selected_column + 1 < num_columns && ((!event.key.control && event.key.code == sf::Keyboard::Right) || (event.key.control && event.key.code == sf::Keyboard::L))) { render_selected_item_bg = true; const int new_selected_item = get_next_visible_item(selected_item); if(new_selected_item != -1) { @@ -1141,7 +1141,7 @@ namespace QuickMedia { item_background.set_position(pos + pos_offset); item_background.set_size(sf::Vector2f(card_width, card_height)); - item_background.set_color(sf::Color(33, 37, 44)); + item_background.set_color(sf::Color(28, 32, 39)); item_background.set_band(item_background_prev_pos - (pos + pos_offset), item_background_prev_size); item_background.set_band_color(sf::Color(55, 60, 68)); item_background.draw(window); @@ -1222,7 +1222,7 @@ namespace QuickMedia { const float gradient_height = 5.0f; if(text_offset_y >= text_height - gradient_height) { const sf::Vector2f card_bottom(text_pos.x, text_height); - const sf::Color color = item_index == selected_item ? sf::Color(55, 60, 68) : sf::Color(33, 37, 44); + const sf::Color color = item_index == selected_item ? sf::Color(55, 60, 68) : sf::Color(28, 32, 39); sf::Vertex gradient_points[4]; gradient_points[0] = sf::Vertex(card_bottom + sf::Vector2f(0.0f, -gradient_height), sf::Color(color.r, color.g, color.b, 0)); @@ -1549,8 +1549,8 @@ namespace QuickMedia { item_height = std::max(item_height, image_height); item_height += (padding_y * 2.0f); - const bool first_height_set = item->last_loaded_height < 0.01f; - if(item_index != -1 && (first_height_set || load_texture)) { + const bool first_height_set = item->last_loaded_height > 0.01f; + if(item_index != -1 && (!first_height_set || load_texture)) { const float height_diff = item_height - item->prev_last_loaded_height; //if(attach_side == AttachSide::TOP) { // if(item_index < selected_item) @@ -1561,7 +1561,7 @@ namespace QuickMedia { //} item->last_loaded_height = item_height; item->prev_last_loaded_height = item_height; - if(first_height_set) + if(!first_height_set) item->current_loaded_height = item_height; } -- cgit v1.2.3