aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2020-12-14 10:54:54 +0100
committerdec05eba <dec05eba@protonmail.com>2020-12-14 10:54:54 +0100
commit8f692293fb2b7cf1b0d9ecc5105fa57cdd1bf83f (patch)
tree03fb0135271917e19edec9f94eb1cd84df135198 /src
parent951c3b640d97ebb99b6e2ec90f9f356596fbf8a5 (diff)
ffs, fix stutter again...........................................................
Diffstat (limited to 'src')
-rw-r--r--src/Body.cpp61
-rw-r--r--src/main.cpp4
2 files changed, 34 insertions, 31 deletions
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 <X11/Xlib.h>
+#include <X11/Xlib.h>
#include <libgen.h>
#include <unistd.h>
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);
}