aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/Body.hpp6
-rw-r--r--src/Body.cpp61
-rw-r--r--src/main.cpp4
3 files changed, 36 insertions, 35 deletions
diff --git a/include/Body.hpp b/include/Body.hpp
index fb3f20e..62d8b27 100644
--- a/include/Body.hpp
+++ b/include/Body.hpp
@@ -236,7 +236,7 @@ namespace QuickMedia {
float get_page_scroll() const { return page_scroll; }
// This is the item we can see the end of
bool is_last_item_fully_visible() const { return last_item_fully_visible; }
- bool is_body_full_with_items() const { return body_full; }
+ bool is_body_full_with_items() const { return items_cut_off; }
int get_num_visible_items() const { return num_visible_items; };
sf::Text progress_text;
@@ -275,9 +275,7 @@ namespace QuickMedia {
double elapsed_time_sec = 0.0;
bool selected_line_top_visible = true;
bool selected_line_bottom_visible = true;
- bool top_cut_off = false;
- bool bottom_cut_off = false;
- bool body_full = false;
+ bool items_cut_off = false;
float offset_to_top = 0.0f;
float offset_to_bottom = 0.0f;
};
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);
}