aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ImageViewer.cpp14
-rw-r--r--src/QuickMedia.cpp17
2 files changed, 16 insertions, 15 deletions
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index 9071214..7b188c8 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -212,6 +212,8 @@ namespace QuickMedia {
scroll -= size.y;
page_size[i].prev_size = size;
}
+
+ scroll -= (get_page_size(current_page).y * 0.5 - window_size.y * 0.5);
}
// TODO: Only redraw when scrolling and when image has finished downloading
@@ -334,10 +336,14 @@ namespace QuickMedia {
page_offset += current_page_size.y;
}
- if(scroll > 0.0) {
- scroll = 0.0;
- } else if(scroll + page_offset < window_size.y && page_offset > window_size.y) {
- scroll += (window_size.y - (scroll + page_offset));
+ const double first_image_height = get_page_size(0).y;
+ const double last_image_height = get_page_size((int)image_data.size() - 1).y;
+
+ const double top_scroll = -first_image_height * 0.5 + window_size.y * 0.5;
+ if(scroll > top_scroll) {
+ scroll = top_scroll;
+ } else if(scroll + page_offset < window_size.y + last_image_height * 0.5 - window_size.y * 0.5 && page_offset > window_size.y) {
+ scroll = -page_offset + (window_size.y + last_image_height * 0.5 - window_size.y * 0.5);
}
if(page_closest_to_center != -1) {
diff --git a/src/QuickMedia.cpp b/src/QuickMedia.cpp
index 594c1e1..d1cc0e3 100644
--- a/src/QuickMedia.cpp
+++ b/src/QuickMedia.cpp
@@ -3488,13 +3488,8 @@ namespace QuickMedia {
latest_read = image_index + 1;
if(json_chapters.isObject()) {
json_chapter = json_chapters[images_page->get_chapter_name()];
- if(json_chapter.isObject()) {
- const Json::Value &current = json_chapter["current"];
- if(current.isNumeric())
- latest_read = std::max(latest_read, current.asInt());
- } else {
+ if(!json_chapter.isObject())
json_chapter = Json::Value(Json::objectValue);
- }
} else {
json_chapters = Json::Value(Json::objectValue);
json_chapter = Json::Value(Json::objectValue);
@@ -3720,8 +3715,8 @@ namespace QuickMedia {
Json::Value json_chapters;
Json::Value json_chapter;
- int latest_read;
- save_manga_progress(images_page, json_chapters, json_chapter, latest_read);
+ int current_read_page;
+ save_manga_progress(images_page, json_chapters, json_chapter, current_read_page);
ImageViewer image_viewer(&window, num_manga_pages, images_page->manga_name, images_page->get_chapter_name(), image_index, content_cache_dir, &fit_image_to_window);
idle_active_handler();
@@ -3746,9 +3741,9 @@ namespace QuickMedia {
int focused_page = image_viewer.get_focused_page();
image_index = focused_page - 1;
- if(focused_page > latest_read) {
- latest_read = focused_page;
- json_chapter["current"] = latest_read;
+ if(focused_page != current_read_page) {
+ current_read_page = focused_page;
+ json_chapter["current"] = current_read_page;
json_chapters[images_page->get_chapter_name()] = json_chapter;
content_storage_json["chapters"] = json_chapters;
if(!save_json_to_file_atomic(content_storage_file, content_storage_json)) {