diff options
author | dec05eba <dec05eba@protonmail.com> | 2021-09-12 12:36:13 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2021-09-12 12:36:13 +0200 |
commit | de8682ce581cdc3f0886e3edf89b430a7215aea1 (patch) | |
tree | c30bc53c85a42fb1c80f990ffa1c40a63907c584 /src | |
parent | 381f449e7153d5305df5ae5218cb6a8dfcf20184 (diff) |
Scroll body list view on item height diff
Diffstat (limited to 'src')
-rw-r--r-- | src/Body.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
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; } } |