Use system grab/grabbing cursors.

Fix #6549.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38543 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Philippe Houdoin
2010-09-06 15:02:38 +00:00
parent dec32162b5
commit faff258d9a
2 changed files with 35 additions and 63 deletions
+18 -47
View File
@@ -16,6 +16,7 @@
#include <Bitmap.h> #include <Bitmap.h>
#include <Catalog.h> #include <Catalog.h>
#include <Cursor.h>
#include <Debug.h> #include <Debug.h>
#include <File.h> #include <File.h>
#include <FindDirectory.h> #include <FindDirectory.h>
@@ -59,45 +60,6 @@ static const uint32 kMsgImagePlacement = 'xypl';
static const uint32 kMsgUpdatePreviewPlacement = 'pvpl'; 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() BackgroundsView::BackgroundsView()
: :
BBox("BackgroundsView"), BBox("BackgroundsView"),
@@ -1185,7 +1147,8 @@ BackgroundsView::FoundPositionSetting()
PreView::PreView() PreView::PreView()
: :
BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE), 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 aspectRatio = BScreen().Frame().Width() / BScreen().Frame().Height();
float previewWidth = 120.0f; float previewWidth = 120.0f;
@@ -1197,6 +1160,13 @@ PreView::PreView()
} }
PreView::~PreView()
{
delete fGrabbingCursor;
delete fGrabCursor;
}
void void
PreView::AttachedToWindow() PreView::AttachedToWindow()
{ {
@@ -1220,6 +1190,7 @@ PreView::MouseDown(BPoint point)
fYRatio = Bounds().Height() / fMode.virtual_height; fYRatio = Bounds().Height() / fMode.virtual_height;
SetMouseEventMask(B_POINTER_EVENTS, SetMouseEventMask(B_POINTER_EVENTS,
B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY); B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
SetViewCursor(fGrabbingCursor);
} }
} }
} }
@@ -1228,20 +1199,19 @@ PreView::MouseDown(BPoint point)
void void
PreView::MouseUp(BPoint point) PreView::MouseUp(BPoint point)
{ {
if (IsTracking()) if (IsTracking()) {
SetTracking(false); SetTracking(false);
SetViewCursor(fGrabCursor);
}
} }
void void
PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message) PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
{ {
if (IsEnabled()) if (!IsTracking())
SetViewCursor(&fMoveHandCursor); SetViewCursor(IsEnabled() ? fGrabCursor : B_CURSOR_SYSTEM_DEFAULT);
else else {
SetViewCursor(B_CURSOR_SYSTEM_DEFAULT);
if (IsTracking()) {
float x, y; float x, y;
x = fPoint.x + (point.x - fOldPoint.x) / fXRatio; x = fPoint.x + (point.x - fOldPoint.x) / fXRatio;
y = fPoint.y + (point.y - fOldPoint.y) / fYRatio; y = fPoint.y + (point.y - fOldPoint.y) / fYRatio;
@@ -1289,6 +1259,7 @@ PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
messenger.SendMessage(kMsgUpdatePreviewPlacement); messenger.SendMessage(kMsgUpdatePreviewPlacement);
} }
} }
BControl::MouseMoved(point, transit, message); BControl::MouseMoved(point, transit, message);
} }
+17 -16
View File
@@ -9,25 +9,25 @@
#define BACKGROUNDS_VIEW_H #define BACKGROUNDS_VIEW_H
#include <View.h> #include <Box.h>
#include <ColorControl.h>
#include <Message.h>
#include <Button.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 <Picture.h>
#include <Screen.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <String.h> #include <String.h>
#include <Box.h>
#include <CheckBox.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 <StringView.h>
#include <Cursor.h> #include <TextControl.h>
#include <View.h>
#include "BackgroundImage.h" #include "BackgroundImage.h"
@@ -81,6 +81,7 @@ private:
class PreView : public BControl { class PreView : public BControl {
public: public:
PreView(); PreView();
virtual ~PreView();
BPoint fPoint; BPoint fPoint;
BRect fImageBounds; BRect fImageBounds;
@@ -96,8 +97,8 @@ protected:
float fXRatio; float fXRatio;
float fYRatio; float fYRatio;
display_mode fMode; display_mode fMode;
BCursor* fGrabbingCursor;
BCursor fMoveHandCursor; BCursor* fGrabCursor;
}; };