aboutsummaryrefslogtreecommitdiff
path: root/src/Body.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Body.cpp')
-rw-r--r--src/Body.cpp38
1 files changed, 35 insertions, 3 deletions
diff --git a/src/Body.cpp b/src/Body.cpp
index 477591e..c52f8ad 100644
--- a/src/Body.cpp
+++ b/src/Body.cpp
@@ -74,7 +74,8 @@ namespace QuickMedia {
selected_item(0),
prev_selected_item(0),
page_scroll(0.0f),
- item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10)
+ item_background(sf::Vector2f(1.0f, 1.0f), 10.0f, 10),
+ num_visible_items(0)
{
progress_text.setFillColor(sf::Color::White);
replies_text.setFillColor(sf::Color(129, 162, 190));
@@ -91,6 +92,26 @@ namespace QuickMedia {
load_thumbnail_future.get();
}
+ // TODO: Make this work with wraparound enabled?
+ // TODO: For plugins with different sized body items this can be weird, because after scrolling down thumbnails could load and they could move items up/down until we see items we haven't seen
+ bool Body::select_previous_page() {
+ for(int i = 0; i < num_visible_items - 1; ++i) {
+ if(!select_previous_item())
+ return false;
+ }
+ return true;
+ }
+
+ // TODO: Make this work with wraparound enabled?
+ // TODO: For plugins with different sized body items this can be weird, because after scrolling down thumbnails could load and they could move items up/down until we see items we haven't seen
+ bool Body::select_next_page() {
+ for(int i = 0; i < num_visible_items - 1; ++i) {
+ if(!select_next_item())
+ return false;
+ }
+ return true;
+ }
+
bool Body::select_previous_item() {
if(items.empty())
return false;
@@ -161,6 +182,13 @@ namespace QuickMedia {
clamp_selection();
}
+ void Body::select_last_item() {
+ selected_item = std::max(0, (int)items.size() - 1);
+ //prev_selected_item = selected_item;
+ //page_scroll = 0.0f;
+ clamp_selection();
+ }
+
void Body::reset_selected() {
for(size_t i = 0; i < items.size(); ++i) {
if(items[i]->visible) {
@@ -229,8 +257,9 @@ namespace QuickMedia {
}
reset_scroll:
- prev_selected_item = selected_item;
- page_scroll = 0.0f;
+ {}
+ //prev_selected_item = selected_item;
+ //page_scroll = 0.0f;
}
static sf::Vector2f to_vec2f(const sf::Vector2u &vec) {
@@ -364,6 +393,7 @@ namespace QuickMedia {
//item_background.setOutlineColor(sf::Color(13, 15, 17));
image_fallback.setSize(thumbnail_fallback_size);
item_background_shadow.setFillColor(line_seperator_color);
+ num_visible_items = 0;
if(loading_thumbnail && load_thumbnail_future.valid() && load_thumbnail_future.wait_for(std::chrono::seconds(0)) == std::future_status::ready) {
load_thumbnail_future.get();
@@ -476,6 +506,7 @@ namespace QuickMedia {
break;
draw_item(window, item.get(), prev_pos, size, item_height, i, content_progress);
+ ++num_visible_items;
}
sf::Vector2f after_pos = pos;
@@ -492,6 +523,7 @@ namespace QuickMedia {
float item_height = get_item_height(item.get());
draw_item(window, item.get(), after_pos, size, item_height, i, content_progress);
after_pos.y += item_height + spacing_y;
+ ++num_visible_items;
}
glDisable(GL_SCISSOR_TEST);