[haiku-commits] r38543 - haiku/trunk/src/preferences/backgrounds

  • From: philippe.houdoin@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Mon, 6 Sep 2010 17:02:38 +0200 (CEST)

Author: phoudoin
Date: 2010-09-06 17:02:38 +0200 (Mon, 06 Sep 2010)
New Revision: 38543
Changeset: http://dev.haiku-os.org/changeset/38543
Ticket: http://dev.haiku-os.org/ticket/6549

Modified:
   haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp
   haiku/trunk/src/preferences/backgrounds/BackgroundsView.h
Log:
Use system grab/grabbing cursors.
Fix #6549.


Modified: haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp
===================================================================
--- haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp 2010-09-06 
10:41:05 UTC (rev 38542)
+++ haiku/trunk/src/preferences/backgrounds/BackgroundsView.cpp 2010-09-06 
15:02:38 UTC (rev 38543)
@@ -16,6 +16,7 @@
 
 #include <Bitmap.h>
 #include <Catalog.h>
+#include <Cursor.h>
 #include <Debug.h>
 #include <File.h>
 #include <FindDirectory.h>
@@ -59,45 +60,6 @@
 static const uint32 kMsgUpdatePreviewPlacement = 'pvpl';
 
 
-const uint8 kHandCursorData[68] = {
-       16, 1, 2, 2,
-
-       0, 0,           // 0000000000000000
-       7, 128,         // 0000011110000000
-       61, 112,        // 0011110101110000
-       37, 40,         // 0010010100101000
-       36, 168,        // 0010010010101000
-       18, 148,        // 0001001010010100
-       18, 84,         // 0001001001010100
-       9, 42,          // 0000100100101010
-       8, 1,           // 0000100000000001
-       60, 1,          // 0011110000000001
-       76, 1,          // 0100110000000001
-       66, 1,          // 0100001000000001
-       48, 1,          // 0011000000000001
-       12, 1,          // 0000110000000001
-       2, 0,           // 0000001000000000
-       1, 0,           // 0000000100000000
-
-       0, 0,           // 0000000000000000
-       7, 128,         // 0000011110000000
-       63, 240,        // 0011111111110000
-       63, 248,        // 0011111111111000
-       63, 248,        // 0011111111111000
-       31, 252,        // 0001111111111100
-       31, 252,        // 0001111111111100
-       15, 254,        // 0000111111111110
-       15, 255,        // 0000111111111111
-       63, 255,        // 0011111111111111
-       127, 255,       // 0111111111111111
-       127, 255,       // 0111111111111111
-       63, 255,        // 0011111111111111
-       15, 255,        // 0000111111111111
-       3, 254,         // 0000001111111110
-       1, 248          // 0000000111111000
-};
-
-
 BackgroundsView::BackgroundsView()
        :
        BBox("BackgroundsView"),
@@ -1185,7 +1147,8 @@
 PreView::PreView()
        :
        BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE),
-       fMoveHandCursor(kHandCursorData)
+       fGrabbingCursor(new BCursor(B_CURSOR_ID_GRABBING)),
+       fGrabCursor(new BCursor(B_CURSOR_ID_GRAB))
 {
        float aspectRatio = BScreen().Frame().Width() / 
BScreen().Frame().Height();
        float previewWidth = 120.0f;
@@ -1197,6 +1160,13 @@
 }
 
 
+PreView::~PreView()
+{
+       delete fGrabbingCursor;
+       delete fGrabCursor;
+}
+
+
 void
 PreView::AttachedToWindow()
 {
@@ -1220,6 +1190,7 @@
                        fYRatio = Bounds().Height() / fMode.virtual_height;
                        SetMouseEventMask(B_POINTER_EVENTS,
                                B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
+                       SetViewCursor(fGrabbingCursor);
                }
        }
 }
@@ -1228,20 +1199,19 @@
 void
 PreView::MouseUp(BPoint point)
 {
-       if (IsTracking())
+       if (IsTracking()) {
                SetTracking(false);
+               SetViewCursor(fGrabCursor);
+       }
 }
 
 
 void
 PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
 {
-       if (IsEnabled())
-               SetViewCursor(&fMoveHandCursor);
-       else
-               SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
-
-       if (IsTracking()) {
+       if (!IsTracking())
+               SetViewCursor(IsEnabled() ? fGrabCursor : 
B_CURSOR_SYSTEM_DEFAULT);
+       else {
                float x, y;
                x = fPoint.x + (point.x - fOldPoint.x) / fXRatio;
                y = fPoint.y + (point.y - fOldPoint.y) / fYRatio;
@@ -1289,6 +1259,7 @@
                        messenger.SendMessage(kMsgUpdatePreviewPlacement);
                }
        }
+
        BControl::MouseMoved(point, transit, message);
 }
 

Modified: haiku/trunk/src/preferences/backgrounds/BackgroundsView.h
===================================================================
--- haiku/trunk/src/preferences/backgrounds/BackgroundsView.h   2010-09-06 
10:41:05 UTC (rev 38542)
+++ haiku/trunk/src/preferences/backgrounds/BackgroundsView.h   2010-09-06 
15:02:38 UTC (rev 38543)
@@ -9,25 +9,25 @@
 #define BACKGROUNDS_VIEW_H
 
 
-#include <View.h>
+#include <Box.h>
+#include <Button.h>
+#include <CheckBox.h>
 #include <ColorControl.h>
+#include <Control.h>
+#include <Cursor.h>
+#include <Entry.h>
+#include <FilePanel.h>
+#include <Menu.h>
+#include <MenuItem.h>
 #include <Message.h>
-#include <Button.h>
+#include <Picture.h>
+#include <Screen.h>
 #include <ScrollView.h>
 #include <ScrollBar.h>
 #include <String.h>
-#include <Box.h>
-#include <CheckBox.h>
+#include <StringView.h>
 #include <TextControl.h>
-#include <Menu.h>
-#include <MenuItem.h>
-#include <Entry.h>
-#include <Screen.h>
-#include <Control.h>
-#include <Picture.h>
-#include <FilePanel.h>
-#include <StringView.h>
-#include <Cursor.h>
+#include <View.h>
 
 #include "BackgroundImage.h"
 
@@ -81,6 +81,7 @@
 class PreView : public BControl {
 public:
                                                        PreView();
+                       virtual                 ~PreView();
 
                        BPoint                  fPoint;
                        BRect                   fImageBounds;
@@ -96,8 +97,8 @@
                        float                   fXRatio;
                        float                   fYRatio;
                        display_mode    fMode;
-
-                       BCursor                 fMoveHandCursor;
+                       BCursor*                fGrabbingCursor;
+                       BCursor*                fGrabCursor;
 };
 
 


Other related posts:

  • » [haiku-commits] r38543 - haiku/trunk/src/preferences/backgrounds - philippe . houdoin