aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2022-01-31 23:46:14 +0100
committerdec05eba <dec05eba@protonmail.com>2022-01-31 23:46:14 +0100
commit39ab966ebf9c23c8e801a904836a73be56b5ab92 (patch)
tree45c097b79fb299d9f16e9caabd744e84a30fd4e0 /src
parentf318546c4bf57e3441cbe33e2d203f26035aacfc (diff)
ImageViewer: proper clamp to first/last image top/bottom, change acceleration values
Diffstat (limited to 'src')
-rw-r--r--src/ImageViewer.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/ImageViewer.cpp b/src/ImageViewer.cpp
index 7b188c8..ff35d06 100644
--- a/src/ImageViewer.cpp
+++ b/src/ImageViewer.cpp
@@ -196,10 +196,10 @@ namespace QuickMedia {
ImageViewerAction ImageViewer::draw() {
const double frame_delta = frame_timer.restart();
- const double scroll_speed_key_input = 50.0;
- const double scroll_speed_mouse_wheel = 600.0;
+ const double scroll_speed_key_input = 200.0;
+ const double scroll_speed_mouse_wheel = 800.0;
const double scroll_speed_autoscroll = 10.0;
- const double scroll_deaccel = 0.96;
+ const double scroll_deaccel = 6.0; // higher value = faster stop
if(!window_size_set) {
auto window_size_i = window->get_size();
@@ -288,7 +288,7 @@ namespace QuickMedia {
if(scroll_speed < -max_speed)
scroll_speed = -max_speed;
- scroll_speed *= scroll_deaccel;
+ scroll_speed *= (1.0 - std::min(1.0, scroll_deaccel * frame_delta));
if(std::abs(scroll_speed) < 0.01) {
scroll_speed = 0.0;
scroll = std::round(scroll); /* Better image quality! */
@@ -339,11 +339,12 @@ namespace QuickMedia {
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;
+ const double top_scroll = std::max(0.0, -first_image_height * 0.5 + window_size.y * 0.5);
+ const double bottom_scroll = std::min(window_size.y, window_size.y + last_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);
+ } else if(scroll + page_offset < bottom_scroll && page_offset > window_size.y) {
+ scroll = -page_offset + bottom_scroll;
}
if(page_closest_to_center != -1) {