diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ImageViewer.cpp | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp index 416f27f..c45e35d 100644 --- a/src/ImageViewer.cpp +++ b/src/ImageViewer.cpp @@ -76,6 +76,8 @@ namespace QuickMedia { } if(page_image_data) { + page_image_data->visible_on_screen = true; + if(page_image_data->image_status == ImageStatus::APPLIED_TO_TEXTURE) { page_image_data->sprite.setPosition(render_pos.x, render_pos.y); window.draw(page_image_data->sprite); @@ -255,16 +257,26 @@ namespace QuickMedia { int page_i = 0; for(auto &page_data : image_data) { - if(page_data && page_data->image_status == ImageStatus::LOADED) { - if(page_data->texture.loadFromImage(*page_data->image)) { - page_data->sprite.setTexture(page_data->texture, true); - page_size[page_i].size = get_page_size(page_i); - page_size[page_i].loaded = true; - page_data->image_status = ImageStatus::APPLIED_TO_TEXTURE; - } else { - page_data->image_status = ImageStatus::FAILED_TO_LOAD; + if(page_data) { + if(page_data->image_status == ImageStatus::LOADED) { + if(page_data->texture.loadFromImage(*page_data->image)) { + double height_before = get_page_size(page_i).y; + page_data->image_status = ImageStatus::APPLIED_TO_TEXTURE; + page_data->sprite.setTexture(page_data->texture, true); + page_size[page_i].size = get_page_size(page_i); + page_size[page_i].loaded = true; + double height_after = page_size[page_i].size.y; + + double height_diff = height_before - height_after; + if(scroll_speed <= 0.0 && page_i < current_page) { + scroll -= height_diff; + } + } else { + page_data->image_status = ImageStatus::FAILED_TO_LOAD; + } + page_data->image.reset(); } - page_data->image.reset(); + page_data->visible_on_screen = false; } ++page_i; } @@ -345,7 +357,7 @@ namespace QuickMedia { if(page_size[page].loaded) return page_size[page].size; - if(!image_data[page]) + if(!image_data[page] || image_data[page]->image_status != ImageStatus::APPLIED_TO_TEXTURE) return no_image_page_size; sf::Vector2u texture_size = image_data[page]->texture.getSize(); |