From de8682ce581cdc3f0886e3edf89b430a7215aea1 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sun, 12 Sep 2021 12:36:13 +0200 Subject: Scroll body list view on item height diff --- src/Body.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 10e31dd..45ca190 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -1050,6 +1050,8 @@ namespace QuickMedia { prev_body_item = items[prev_index].get(); } + const float pos_y_before = pos.y; + const bool merge_with_previous = body_item_merge_handler && body_item_merge_handler(prev_body_item, item.get()); if(attach_side == AttachSide::TOP && merge_with_previous) pos.y -= body_spacing[body_theme].spacing_y; @@ -1124,10 +1126,25 @@ namespace QuickMedia { if(attach_side == AttachSide::BOTTOM && merge_with_previous) pos.y += body_spacing[body_theme].spacing_y; + const float pos_y_after = pos.y; + item->height = std::abs(pos_y_after - pos_y_before); + const float height_diff = item->height - item->prev_height; + item->prev_height = item->height; + if(attach_side == AttachSide::TOP) { + if(index < selected_item) { + page_scroll -= height_diff; + pos.y -= height_diff; + } + prev_body_item = item.get(); index = get_next_visible_item(index); } else { + if(index > selected_item) { + page_scroll += height_diff; + pos.y += height_diff; + } + index = prev_index; } } -- cgit v1.2.3