[haiku-development] ShowImage patch

  • From: Christian Packmann <Christian.Packmann@xxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Fri, 27 Feb 2009 10:53:40 +0100

/trunk/src/apps/showimage/

Patches ShowImageView.cpp, mousewheel scroll behavior:
- when <Shift> is held during scroll, scrolls x-axis
- when <Ctrl> or <Command> held during scroll, zooms in/out

I think these are small but useful changes, which provide higher usability - much better than having to use the scrollbar for horiz. scrolls or use menus/shortcuts for zoom control. While this behavior is not exactly intuitive, it doesn't change the default behavior, so it won't hurt anyone... I hope. :)

Christian
Index: ShowImageView.cpp
===================================================================
--- ShowImageView.cpp   (revision 29181)
+++ ShowImageView.cpp   (working copy)
@@ -1707,16 +1707,33 @@
        // |dy| is the number of notches scrolled up or down.
        // When the wheel is scrolled down (towards the user) dy > 0
        // When the wheel is scrolled up (away from the user) dy < 0
+       
+       // Modifier keys influence the behavior of scrolling:
+       // Shift transforms y-scroll to the x-axis
+       // Control or Command zoom in/out
        const float kscrollBy = 40;
        float dy, dx;
        float x, y;
        x = 0; y = 0;
+       uint32 mod = modifiers();
+
        if (msg->FindFloat("be:wheel_delta_x", &dx) == B_OK)
                x = dx * kscrollBy;
-       if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK)
-               y = dy * kscrollBy;
-
-       ScrollRestrictedBy(x, y);
+       if (msg->FindFloat("be:wheel_delta_y", &dy) == B_OK) {
+               if ( mod & B_SHIFT_KEY ) {
+                       x = dy * kscrollBy;
+               }
+               else if ( mod & B_COMMAND_KEY || mod & B_CONTROL_KEY ) {
+                       if ( dy <= 0.0 )
+                               ZoomIn();
+                       else
+                               ZoomOut();
+               }
+               else
+                       y = dy * kscrollBy;
+       }
+       
+       ScrollRestrictedBy(x, y);       
 }
 

Other related posts: