From 281ad93ce7d923d10bae466916aa4decbcb1f3a1 Mon Sep 17 00:00:00 2001 From: Ryan Leavengood Date: Sat, 25 Jun 2011 04:24:54 +0000 Subject: [PATCH] Make the zoom "sticky" at 1.0 for about half a second when zooming with the mousewheel. It might be a bit annoying, not sure yet. Implements #7253. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42311 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageView.cpp | 20 ++++++++++++++++---- src/apps/showimage/ShowImageView.h | 3 +++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/apps/showimage/ShowImageView.cpp b/src/apps/showimage/ShowImageView.cpp index f5b194e4a0..f959060df2 100644 --- a/src/apps/showimage/ShowImageView.cpp +++ b/src/apps/showimage/ShowImageView.cpp @@ -71,6 +71,7 @@ class PopUpMenu : public BPopUpMenu { // the delay time for hiding the cursor in 1/10 seconds (the pulse rate) #define HIDE_CURSOR_DELAY_TIME 20 +#define STICKY_ZOOM_DELAY_TIME 5 #define SHOW_IMAGE_ORIENTATION_ATTRIBUTE "ShowImage:orientation" @@ -196,6 +197,7 @@ ShowImageView::ShowImageView(BRect rect, const char *name, uint32 resizingMode, fShowCaption(false), fShowingPopUpMenu(false), fHideCursorCountDown(HIDE_CURSOR_DELAY_TIME), + fStickyZoomCountDown(0), fIsActiveWin(true), fDefaultCursor(NULL), fGrabCursor(NULL) @@ -253,6 +255,10 @@ ShowImageView::Pulse() } else fHideCursorCountDown--; } + + if (fStickyZoomCountDown > 0) + fStickyZoomCountDown--; + } @@ -1355,10 +1361,16 @@ ShowImageView::_MouseWheelChanged(BMessage *msg) uint32 buttons; GetMouse(&where, &buttons); - if (dy < 0) - ZoomIn(where); - else if (dy > 0) - ZoomOut(where); + if (fStickyZoomCountDown <= 0) { + if (dy < 0) + ZoomIn(where); + else if (dy > 0) + ZoomOut(where); + + if (fZoom == 1.0) + fStickyZoomCountDown = STICKY_ZOOM_DELAY_TIME; + } + } } diff --git a/src/apps/showimage/ShowImageView.h b/src/apps/showimage/ShowImageView.h index 64bdedf920..b72be7d104 100644 --- a/src/apps/showimage/ShowImageView.h +++ b/src/apps/showimage/ShowImageView.h @@ -219,6 +219,9 @@ private: int fHideCursorCountDown; // Hides the cursor when it reaches zero + int fStickyZoomCountDown; + // Make the zoom sticky at 1.0 when zoomed with the mousewheel + bool fIsActiveWin; // Is the parent window the active window?