From 1fd87770e98aa98228903756380f1596b726b84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 18 May 2005 23:42:58 +0000 Subject: [PATCH] added scrolling with the right mouse button git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12728 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/tests/servers/app/playground/Jamfile | 4 +- .../servers/app/playground/ObjectView.cpp | 58 +++++++++++++------ src/tests/servers/app/playground/ObjectView.h | 3 + 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/src/tests/servers/app/playground/Jamfile b/src/tests/servers/app/playground/Jamfile index 0560020189..59d98eafa0 100644 --- a/src/tests/servers/app/playground/Jamfile +++ b/src/tests/servers/app/playground/Jamfile @@ -17,7 +17,7 @@ if ( $(TARGET_PLATFORM) = haiku ) { } else { # for running in the Haiku app_server under R5: LinkSharedOSLibs Playground : - libopenbeos.so ; -# be ; +# libopenbeos.so ; + be ; } diff --git a/src/tests/servers/app/playground/ObjectView.cpp b/src/tests/servers/app/playground/ObjectView.cpp index 7f690a29b5..da5a113f15 100644 --- a/src/tests/servers/app/playground/ObjectView.cpp +++ b/src/tests/servers/app/playground/ObjectView.cpp @@ -18,7 +18,9 @@ ObjectView::ObjectView(BRect frame, const char* name, fStateList(20), fColor((rgb_color){ 0, 80, 255, 100 }), fFill(false), - fPenSize(10.0) + fPenSize(10.0), + fScrolling(false), + fLastMousePos(0.0, 0.0) { rgb_color bg = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT); SetViewColor(bg); @@ -41,7 +43,7 @@ ObjectView::Draw(BRect updateRect) BRect r(Bounds()); - BeginLineArray(4); +/* BeginLineArray(4); AddLine(BPoint(r.left, r.top), BPoint(r.right, r.top), shadow); AddLine(BPoint(r.right, r.top + 1), @@ -50,7 +52,7 @@ ObjectView::Draw(BRect updateRect) BPoint(r.left, r.bottom), light); AddLine(BPoint(r.left, r.bottom - 1), BPoint(r.left, r.top + 1), shadow); - EndLineArray(); + EndLineArray();*/ SetHighColor(255, 0, 0, 128); @@ -82,13 +84,21 @@ SetDrawingMode(B_OP_COPY); void ObjectView::MouseDown(BPoint where) { - if (!fState) - SetState(State::StateFor(fObjectType, fColor, fFill, fPenSize)); + uint32 buttons; + Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); + fScrolling = buttons & B_SECONDARY_MOUSE_BUTTON; - if (fState) { - Invalidate(fState->Bounds()); - fState->MouseDown(where); - Invalidate(fState->Bounds()); + if (fScrolling) { + fLastMousePos = where; + } else { + if (!fState) + SetState(State::StateFor(fObjectType, fColor, fFill, fPenSize)); + + if (fState) { + Invalidate(fState->Bounds()); + fState->MouseDown(where); + Invalidate(fState->Bounds()); + } } } @@ -96,8 +106,12 @@ ObjectView::MouseDown(BPoint where) void ObjectView::MouseUp(BPoint where) { - if (fState) { - fState->MouseUp(where); + if (fScrolling) { + fScrolling = false; + } else { + if (fState) { + fState->MouseUp(where); + } } } @@ -106,14 +120,20 @@ void ObjectView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage) { - if (fState && fState->IsTracking()) { - BRect before = fState->Bounds(); - - fState->MouseMoved(where); - - BRect after = fState->Bounds(); - BRect invalid(before | after); - Invalidate(invalid); + if (fScrolling) { + BPoint offset = fLastMousePos - where; + ScrollBy(offset.x, offset.y); + fLastMousePos = where + offset; + } else { + if (fState && fState->IsTracking()) { + BRect before = fState->Bounds(); + + fState->MouseMoved(where); + + BRect after = fState->Bounds(); + BRect invalid(before | after); + Invalidate(invalid); + } } } diff --git a/src/tests/servers/app/playground/ObjectView.h b/src/tests/servers/app/playground/ObjectView.h index 7c47767773..28add12a59 100644 --- a/src/tests/servers/app/playground/ObjectView.h +++ b/src/tests/servers/app/playground/ObjectView.h @@ -59,6 +59,9 @@ class ObjectView : public BView { rgb_color fColor; bool fFill; float fPenSize; + + bool fScrolling; + BPoint fLastMousePos; }; #endif // OBJECT_VIEW_H