Reworked, as suggested by stippi, to avoid keeping cursors instances of system ones.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@38566 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -166,9 +166,6 @@ ObjectView::ObjectView(BRect rect, const char *name, ulong resizingMode,
|
|||||||
quittingSem = create_sem(1, "quitting sem");
|
quittingSem = create_sem(1, "quitting sem");
|
||||||
drawEvent = create_sem(0, "draw event");
|
drawEvent = create_sem(0, "draw event");
|
||||||
|
|
||||||
fGrabbingCursor = new BCursor(B_CURSOR_ID_GRABBING);
|
|
||||||
fGrabCursor = new BCursor(B_CURSOR_ID_GRAB);
|
|
||||||
|
|
||||||
char findDir[PATH_MAX];
|
char findDir[PATH_MAX];
|
||||||
find_directory(B_SYSTEM_DATA_DIRECTORY, -1, true, findDir, PATH_MAX);
|
find_directory(B_SYSTEM_DATA_DIRECTORY, -1, true, findDir, PATH_MAX);
|
||||||
sprintf(teapotPath, "%s/%s", findDir, teapotData);
|
sprintf(teapotPath, "%s/%s", findDir, teapotData);
|
||||||
@@ -182,8 +179,6 @@ ObjectView::~ObjectView()
|
|||||||
{
|
{
|
||||||
delete_sem(quittingSem);
|
delete_sem(quittingSem);
|
||||||
delete_sem(drawEvent);
|
delete_sem(drawEvent);
|
||||||
delete fGrabCursor;
|
|
||||||
delete fGrabbingCursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -439,7 +434,9 @@ ObjectView::MouseDown(BPoint point)
|
|||||||
|
|
||||||
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);
|
|
||||||
|
BCursor grabbingCursor(B_CURSOR_ID_GRABBING);
|
||||||
|
SetViewCursor(&grabbingCursor);
|
||||||
} else {
|
} else {
|
||||||
ConvertToScreen(&point);
|
ConvertToScreen(&point);
|
||||||
object->MenuInvoked(point);
|
object->MenuInvoked(point);
|
||||||
@@ -473,7 +470,8 @@ ObjectView::MouseUp(BPoint point)
|
|||||||
fTrackingInfo.lastDx = 0.0f;
|
fTrackingInfo.lastDx = 0.0f;
|
||||||
fTrackingInfo.lastDy = 0.0f;
|
fTrackingInfo.lastDy = 0.0f;
|
||||||
|
|
||||||
SetViewCursor(fGrabCursor);
|
BCursor grabCursor(B_CURSOR_ID_GRAB);
|
||||||
|
SetViewCursor(&grabCursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -520,7 +518,9 @@ ObjectView::MouseMoved(BPoint point, uint32 transit, const BMessage *msg)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
GLObject* object = reinterpret_cast<GLObject*>(fObjects.ItemAt(ObjectAtPoint(point)));
|
GLObject* object = reinterpret_cast<GLObject*>(fObjects.ItemAt(ObjectAtPoint(point)));
|
||||||
SetViewCursor(object != NULL ? fGrabCursor : B_CURSOR_SYSTEM_DEFAULT);
|
BCursor cursor(object != NULL ?
|
||||||
|
B_CURSOR_ID_GRAB : B_CURSOR_ID_SYSTEM_DEFAULT);
|
||||||
|
SetViewCursor(&cursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ enum lights {
|
|||||||
|
|
||||||
class ResScroll;
|
class ResScroll;
|
||||||
class GLObject;
|
class GLObject;
|
||||||
class BCursor;
|
|
||||||
|
|
||||||
struct TrackingInfo {
|
struct TrackingInfo {
|
||||||
float lastX;
|
float lastX;
|
||||||
@@ -91,8 +90,6 @@ class ObjectView : public BGLView {
|
|||||||
float fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE];
|
float fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE];
|
||||||
float fObjectDistance, fLastObjectDistance;
|
float fObjectDistance, fLastObjectDistance;
|
||||||
TrackingInfo fTrackingInfo;
|
TrackingInfo fTrackingInfo;
|
||||||
BCursor* fGrabCursor;
|
|
||||||
BCursor* fGrabbingCursor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OBJECT_VIEW_H
|
#endif // OBJECT_VIEW_H
|
||||||
|
|||||||
@@ -1146,9 +1146,7 @@ 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)
|
||||||
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;
|
||||||
@@ -1160,13 +1158,6 @@ PreView::PreView()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
PreView::~PreView()
|
|
||||||
{
|
|
||||||
delete fGrabbingCursor;
|
|
||||||
delete fGrabCursor;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PreView::AttachedToWindow()
|
PreView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
@@ -1190,7 +1181,9 @@ 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);
|
|
||||||
|
BCursor grabbingCursor(B_CURSOR_ID_GRABBING);
|
||||||
|
SetViewCursor(&grabbingCursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1201,7 +1194,8 @@ PreView::MouseUp(BPoint point)
|
|||||||
{
|
{
|
||||||
if (IsTracking()) {
|
if (IsTracking()) {
|
||||||
SetTracking(false);
|
SetTracking(false);
|
||||||
SetViewCursor(fGrabCursor);
|
BCursor grabCursor(B_CURSOR_ID_GRAB);
|
||||||
|
SetViewCursor(&grabCursor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,9 +1203,10 @@ PreView::MouseUp(BPoint point)
|
|||||||
void
|
void
|
||||||
PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
|
PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
|
||||||
{
|
{
|
||||||
if (!IsTracking())
|
if (!IsTracking()) {
|
||||||
SetViewCursor(IsEnabled() ? fGrabCursor : B_CURSOR_SYSTEM_DEFAULT);
|
BCursor cursor(IsEnabled() ? B_CURSOR_ID_GRAB : B_CURSOR_ID_SYSTEM_DEFAULT);
|
||||||
else {
|
SetViewCursor(&cursor);
|
||||||
|
} else {
|
||||||
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;
|
||||||
|
|||||||
@@ -81,7 +81,6 @@ private:
|
|||||||
class PreView : public BControl {
|
class PreView : public BControl {
|
||||||
public:
|
public:
|
||||||
PreView();
|
PreView();
|
||||||
virtual ~PreView();
|
|
||||||
|
|
||||||
BPoint fPoint;
|
BPoint fPoint;
|
||||||
BRect fImageBounds;
|
BRect fImageBounds;
|
||||||
@@ -97,8 +96,6 @@ protected:
|
|||||||
float fXRatio;
|
float fXRatio;
|
||||||
float fYRatio;
|
float fYRatio;
|
||||||
display_mode fMode;
|
display_mode fMode;
|
||||||
BCursor* fGrabbingCursor;
|
|
||||||
BCursor* fGrabCursor;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user