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:
Philippe Houdoin
2010-09-07 12:14:20 +00:00
parent fae87f406e
commit df9bb1df97
4 changed files with 18 additions and 29 deletions
+8 -8
View File
@@ -166,9 +166,6 @@ ObjectView::ObjectView(BRect rect, const char *name, ulong resizingMode,
quittingSem = create_sem(1, "quitting sem");
drawEvent = create_sem(0, "draw event");
fGrabbingCursor = new BCursor(B_CURSOR_ID_GRABBING);
fGrabCursor = new BCursor(B_CURSOR_ID_GRAB);
char findDir[PATH_MAX];
find_directory(B_SYSTEM_DATA_DIRECTORY, -1, true, findDir, PATH_MAX);
sprintf(teapotPath, "%s/%s", findDir, teapotData);
@@ -182,8 +179,6 @@ ObjectView::~ObjectView()
{
delete_sem(quittingSem);
delete_sem(drawEvent);
delete fGrabCursor;
delete fGrabbingCursor;
}
@@ -439,7 +434,9 @@ ObjectView::MouseDown(BPoint point)
SetMouseEventMask(B_POINTER_EVENTS,
B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
SetViewCursor(fGrabbingCursor);
BCursor grabbingCursor(B_CURSOR_ID_GRABBING);
SetViewCursor(&grabbingCursor);
} else {
ConvertToScreen(&point);
object->MenuInvoked(point);
@@ -473,7 +470,8 @@ ObjectView::MouseUp(BPoint point)
fTrackingInfo.lastDx = 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 {
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);
}
}
-3
View File
@@ -40,7 +40,6 @@ enum lights {
class ResScroll;
class GLObject;
class BCursor;
struct TrackingInfo {
float lastX;
@@ -91,8 +90,6 @@ class ObjectView : public BGLView {
float fLastYXRatio, fYxRatio, fFpsHistory[HISTSIZE];
float fObjectDistance, fLastObjectDistance;
TrackingInfo fTrackingInfo;
BCursor* fGrabCursor;
BCursor* fGrabbingCursor;
};
#endif // OBJECT_VIEW_H
+10 -15
View File
@@ -1146,9 +1146,7 @@ BackgroundsView::FoundPositionSetting()
PreView::PreView()
:
BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE),
fGrabbingCursor(new BCursor(B_CURSOR_ID_GRABBING)),
fGrabCursor(new BCursor(B_CURSOR_ID_GRAB))
BControl("PreView", NULL, NULL, B_WILL_DRAW | B_SUBPIXEL_PRECISE)
{
float aspectRatio = BScreen().Frame().Width() / BScreen().Frame().Height();
float previewWidth = 120.0f;
@@ -1160,13 +1158,6 @@ PreView::PreView()
}
PreView::~PreView()
{
delete fGrabbingCursor;
delete fGrabCursor;
}
void
PreView::AttachedToWindow()
{
@@ -1190,7 +1181,9 @@ PreView::MouseDown(BPoint point)
fYRatio = Bounds().Height() / fMode.virtual_height;
SetMouseEventMask(B_POINTER_EVENTS,
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()) {
SetTracking(false);
SetViewCursor(fGrabCursor);
BCursor grabCursor(B_CURSOR_ID_GRAB);
SetViewCursor(&grabCursor);
}
}
@@ -1209,9 +1203,10 @@ PreView::MouseUp(BPoint point)
void
PreView::MouseMoved(BPoint point, uint32 transit, const BMessage* message)
{
if (!IsTracking())
SetViewCursor(IsEnabled() ? fGrabCursor : B_CURSOR_SYSTEM_DEFAULT);
else {
if (!IsTracking()) {
BCursor cursor(IsEnabled() ? B_CURSOR_ID_GRAB : B_CURSOR_ID_SYSTEM_DEFAULT);
SetViewCursor(&cursor);
} else {
float x, y;
x = fPoint.x + (point.x - fOldPoint.x) / fXRatio;
y = fPoint.y + (point.y - fOldPoint.y) / fYRatio;
@@ -81,7 +81,6 @@ private:
class PreView : public BControl {
public:
PreView();
virtual ~PreView();
BPoint fPoint;
BRect fImageBounds;
@@ -97,8 +96,6 @@ protected:
float fXRatio;
float fYRatio;
display_mode fMode;
BCursor* fGrabbingCursor;
BCursor* fGrabCursor;
};