[gnome-commander] InternalViewer: Scroll image horizontally while pressing ctrl key and using the mouse wheel, #95



commit 9fd9d149b440214bfd2d273ac851c426a61892d6
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Sun Feb 14 22:24:17 2021 +0100

    InternalViewer: Scroll image horizontally while pressing ctrl key and using the mouse wheel, #95

 src/intviewer/image-render.cc | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
---
diff --git a/src/intviewer/image-render.cc b/src/intviewer/image-render.cc
index 99e2b7f4..4ab8d0ed 100644
--- a/src/intviewer/image-render.cc
+++ b/src/intviewer/image-render.cc
@@ -397,6 +397,38 @@ static gboolean image_render_scroll(GtkWidget *widget, GdkEventScroll *event)
 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wswitch-enum"
 #endif
+    if (state_is_ctrl(event->state))
+    {
+        switch (event->direction)
+        {
+            case GDK_SCROLL_UP:
+            {
+                auto hAdjustment = image_render_get_h_adjustment(imageRender);
+                auto current = gtk_adjustment_get_value(hAdjustment);
+                auto lower = gtk_adjustment_get_lower(hAdjustment);
+                if (current > lower)
+                {
+                    gtk_adjustment_set_value(hAdjustment, current - INC_VALUE);
+                }
+                return TRUE;
+            }
+            case GDK_SCROLL_DOWN:
+            {
+                auto hAdjustment = image_render_get_h_adjustment(imageRender);
+                auto current = gtk_adjustment_get_value(hAdjustment);
+                auto upper = gtk_adjustment_get_upper(hAdjustment);
+                auto page_size = gtk_adjustment_get_page_size(hAdjustment);
+                if (current < upper - page_size)
+                {
+                    gtk_adjustment_set_value(hAdjustment, current + INC_VALUE);
+                }
+                return TRUE;
+            }
+            default:
+                return FALSE;
+        }
+    }
+
     switch (event->direction)
     {
         case GDK_SCROLL_UP:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]