From 8f692293fb2b7cf1b0d9ecc5105fa57cdd1bf83f Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 14 Dec 2020 10:54:54 +0100 Subject: ffs, fix stutter again........................................................... --- src/Body.cpp | 61 +++++++++++++++++++++++++++++++----------------------------- src/main.cpp | 4 ++-- 2 files changed, 34 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/Body.cpp b/src/Body.cpp index 6f1d9ae..b12ed7f 100644 --- a/src/Body.cpp +++ b/src/Body.cpp @@ -374,9 +374,7 @@ namespace QuickMedia { clear_body_item_cache(body_item->embedded_item.get()); } last_item_fully_visible = true; - top_cut_off = false; - bottom_cut_off = false; - body_full = false; + items_cut_off = false; offset_to_top = 0.0f; offset_to_bottom = 0.0f; return; @@ -434,33 +432,31 @@ namespace QuickMedia { selected_line_top_visible |= selected_item_fits_on_screen; selected_line_bottom_visible |= selected_item_fits_on_screen; - if(page_scroll > size.y - selected_item_height && selected_item_fits_on_screen) { - //fprintf(stderr, "top!\n"); - page_scroll = size.y - selected_item_height; - } else if(page_scroll < 0.0f && selected_line_top_visible && selected_item_fits_on_screen) { - //fprintf(stderr, "bottom!\n"); - page_scroll = 0.0f; - } - if(top_cut_off || bottom_cut_off) { - if(attach_side == AttachSide::TOP && offset_to_top > 0.0f) { + if(items_cut_off) { + if(offset_to_top > 0.0f) page_scroll -= offset_to_top; - } else if(attach_side == AttachSide::BOTTOM && offset_to_bottom > 0.0f) { + else if(offset_to_bottom > 0.0f) page_scroll += offset_to_bottom; - } } else { - if(attach_side == AttachSide::TOP) { + if(attach_side == AttachSide::TOP) page_scroll -= offset_to_top; - } else if(attach_side == AttachSide::BOTTOM) { + else if(attach_side == AttachSide::BOTTOM) page_scroll += offset_to_bottom; - } + } + + if(page_scroll > size.y - selected_item_height && selected_item_fits_on_screen) { + //fprintf(stderr, "top!\n"); + page_scroll = size.y - selected_item_height; + } else if(page_scroll < 0.0f && selected_line_top_visible && selected_item_fits_on_screen) { + //fprintf(stderr, "bottom!\n"); + page_scroll = 0.0f; } pos.y += page_scroll; - last_item_fully_visible = true; - top_cut_off = false; - bottom_cut_off = false; + bool last_item_fully_visible_set = false; + bool items_cut_off_set = false; sf::Vector2u window_size = window.getSize(); @@ -477,8 +473,10 @@ namespace QuickMedia { float item_height = get_item_height(item.get(), size.x); prev_pos.y -= (item_height + spacing_y); - if(prev_pos.y < start_y) - top_cut_off = true; + if(prev_pos.y < start_y) { + items_cut_off = true; + items_cut_off_set = true; + } if(prev_pos.y + item_height + spacing_y <= start_y) break; @@ -502,11 +500,13 @@ namespace QuickMedia { continue; if(after_pos.y < start_y) - top_cut_off = true; + items_cut_off = true; if(after_pos.y - start_y >= size.y) { last_item_fully_visible = false; - bottom_cut_off = true; + items_cut_off = true; + last_item_fully_visible_set = true; + items_cut_off_set = true; break; } @@ -523,7 +523,9 @@ namespace QuickMedia { if(after_pos.y - start_y > size.y) { last_item_fully_visible = false; - bottom_cut_off = true; + items_cut_off = true; + last_item_fully_visible_set = true; + items_cut_off_set = true; } else { last_fully_visible_item = i; } @@ -533,10 +535,11 @@ namespace QuickMedia { last_fully_visible_item = selected_item; offset_to_bottom = size.y - (after_pos.y - start_y); - if(top_cut_off && (bottom_cut_off || offset_to_bottom < 5.0f)) - body_full = true; - else - body_full = false; + + if(!last_item_fully_visible_set) + last_item_fully_visible = true; + if(!items_cut_off_set) + items_cut_off = false; for(auto it = item_thumbnail_textures.begin(); it != item_thumbnail_textures.end();) { if(!it->second->referenced) diff --git a/src/main.cpp b/src/main.cpp index 869b165..3383363 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,12 +1,12 @@ #include "../include/QuickMedia.hpp" -//#include +#include #include #include int main(int argc, char **argv) { chdir(dirname(argv[0])); setlocale(LC_ALL, "C"); // Sigh... stupid C - //XInitThreads(); + XInitThreads(); QuickMedia::Program program; return program.run(argc, argv); } -- cgit v1.2.3