From faff258d9a6f1808c4cb8784b660c6f4e0efc668 Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Mon, 6 Sep 2010 15:02:38 +0000 Subject: [PATCH] Use system grab/grabbing cursors. Fix #6549. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38543 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../backgrounds/BackgroundsView.cpp | 65 +++++-------------- src/preferences/backgrounds/BackgroundsView.h | 33 +++++----- 2 files changed, 35 insertions(+), 63 deletions(-) diff --git a/src/preferences/backgrounds/BackgroundsView.cpp b/src/preferences/backgrounds/BackgroundsView.cpp index 751b4bcf4d..f7c09876dc 100644 --- a/src/preferences/backgrounds/BackgroundsView.cpp +++ b/src/preferences/backgrounds/BackgroundsView.cpp @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -59,45 +60,6 @@ static const uint32 kMsgImagePlacement = 'xypl'; 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 @@ BackgroundsView::FoundPositionSetting() 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() } +PreView::~PreView() +{ + delete fGrabbingCursor; + delete fGrabCursor; +} + + void PreView::AttachedToWindow() { @@ -1220,6 +1190,7 @@ PreView::MouseDown(BPoint point) fYRatio = Bounds().Height() / fMode.virtual_height; SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY); + SetViewCursor(fGrabbingCursor); } } } @@ -1228,20 +1199,19 @@ PreView::MouseDown(BPoint point) 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 @@ PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message) messenger.SendMessage(kMsgUpdatePreviewPlacement); } } + BControl::MouseMoved(point, transit, message); } diff --git a/src/preferences/backgrounds/BackgroundsView.h b/src/preferences/backgrounds/BackgroundsView.h index 8d1ed27e2a..ca13def6f8 100644 --- a/src/preferences/backgrounds/BackgroundsView.h +++ b/src/preferences/backgrounds/BackgroundsView.h @@ -9,25 +9,25 @@ #define BACKGROUNDS_VIEW_H -#include -#include -#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include -#include +#include +#include #include "BackgroundImage.h" @@ -81,6 +81,7 @@ private: class PreView : public BControl { public: PreView(); + virtual ~PreView(); BPoint fPoint; BRect fImageBounds; @@ -96,8 +97,8 @@ protected: float fXRatio; float fYRatio; display_mode fMode; - - BCursor fMoveHandCursor; + BCursor* fGrabbingCursor; + BCursor* fGrabCursor; };