diff --git a/src/tests/servers/app/newClipping/Clipping.proj b/src/tests/servers/app/newClipping/Clipping.proj index e9bbc98327..1ebb697a9b 100644 Binary files a/src/tests/servers/app/newClipping/Clipping.proj and b/src/tests/servers/app/newClipping/Clipping.proj differ diff --git a/src/tests/servers/app/newClipping/Layer.cpp b/src/tests/servers/app/newClipping/Layer.cpp index 197451c43f..3d3b40c3ce 100644 --- a/src/tests/servers/app/newClipping/Layer.cpp +++ b/src/tests/servers/app/newClipping/Layer.cpp @@ -355,11 +355,14 @@ void Layer::ResizeBy(float dx, float dy) void Layer::MoveBy(float dx, float dy) { - fFrame.Set(fFrame.left+dx, fFrame.top+dy, fFrame.right+dx, fFrame.bottom+dy); + if (dx == 0.0f && dy == 0.0f) + return; + +// fFrame.Set(fFrame.left+dx, fFrame.top+dy, fFrame.right+dx, fFrame.bottom+dy); + fFrame.OffsetBy(dx, dy); // call hook function - if (dx != 0.0f || dy != 0.0f) - MovedByHook(dx, dy); + MovedByHook(dx, dy); if (!IsVisuallyHidden() && GetRootLayer()) { diff --git a/src/tests/servers/app/newClipping/MyView.cpp b/src/tests/servers/app/newClipping/MyView.cpp index 621e4da5d6..cd98c12268 100644 --- a/src/tests/servers/app/newClipping/MyView.cpp +++ b/src/tests/servers/app/newClipping/MyView.cpp @@ -15,6 +15,7 @@ MyView::MyView(BRect frame, const char *name, uint32 resizingMode, uint32 flags) SetViewColor(B_TRANSPARENT_COLOR); fTracking = false; fIsResize = false; + fIs2ndButton= false; fMovingLayer = NULL; rgb_color col; @@ -49,27 +50,41 @@ Layer* MyView::FindLayer(Layer *lay, BPoint &where) const void MyView::MouseDown(BPoint where) { - fTracking = true; SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); + int32 buttons; + Looper()->CurrentMessage()->FindInt32("buttons", &buttons); fLastPos = where; - fMovingLayer = FindLayer(topLayer, where); - if (fMovingLayer == topLayer) - fMovingLayer = NULL; - if (fMovingLayer) + if (buttons == B_PRIMARY_MOUSE_BUTTON) { - BRect bounds(fMovingLayer->Bounds()); - fMovingLayer->ConvertToScreen2(&bounds); - BRect resizeRect(bounds.right-10, bounds.bottom-10, bounds.right, bounds.bottom); - if (resizeRect.Contains(where)) - fIsResize = true; - else - fIsResize = false; + fTracking = true; + fMovingLayer = FindLayer(topLayer, where); + if (fMovingLayer == topLayer) + fMovingLayer = NULL; + if (fMovingLayer) + { + BRect bounds(fMovingLayer->Bounds()); + fMovingLayer->ConvertToScreen2(&bounds); + BRect resizeRect(bounds.right-10, bounds.bottom-10, bounds.right, bounds.bottom); + if (resizeRect.Contains(where)) + fIsResize = true; + else + fIsResize = false; + } + } + else if (buttons == B_SECONDARY_MOUSE_BUTTON) + { + fIs2ndButton = true; + } + else if (buttons == B_TERTIARY_MOUSE_BUTTON) + { + DrawSubTree(topLayer); } } void MyView::MouseUp(BPoint where) { fTracking = false; + fIs2ndButton = false; fMovingLayer = NULL; } @@ -93,27 +108,67 @@ void MyView::MouseMoved(BPoint where, uint32 code, const BMessage *a_message) } } } + else if (fIs2ndButton) + { + SetHighColor(0,0,0); + StrokeLine(fLastPos, where); + Flush(); + fLastPos = where; + } +} + +void MyView::MessageReceived(BMessage *msg) +{ + switch(msg->what) + { + case B_MOUSE_WHEEL_CHANGED: + { + float dy; + msg->FindFloat("be:wheel_delta_y", &dy); + + BPoint pt; + uint32 buttons; + Layer *lay; + GetMouse(&pt, &buttons, false); + if ((lay = FindLayer(topLayer, pt))) + lay->ScrollBy(0, dy*5); + break; + } + default: + BView::MessageReceived(msg); + } } void MyView::CopyRegion(BRegion *reg, float dx, float dy) { // Yes... in this sandbox app, do a redraw. + reg->OffsetBy(dx, dy); wind->Lock(); ConstrainClippingRegion(reg); + PushState(); DrawSubTree(topLayer); - Flush(); + PopState(); + ConstrainClippingRegion(NULL); wind->Unlock(); } void MyView::RequestRedraw() { wind->Lock(); - Invalidate(); + ConstrainClippingRegion(&fRedrawReg); + PushState(); + DrawSubTree(topLayer); + PopState(); + ConstrainClippingRegion(NULL); + + fRedrawReg.MakeEmpty(); + wind->Unlock(); } void MyView::Draw(BRect area) { +/* ConstrainClippingRegion(&fRedrawReg); //FillRect(Bounds()); //Flush(); @@ -123,6 +178,7 @@ void MyView::Draw(BRect area) PopState(); ConstrainClippingRegion(NULL); fRedrawReg.MakeEmpty(); +*/ } void MyView::DrawSubTree(Layer* lay) diff --git a/src/tests/servers/app/newClipping/MyView.h b/src/tests/servers/app/newClipping/MyView.h index 637d192200..ce2e53bd93 100644 --- a/src/tests/servers/app/newClipping/MyView.h +++ b/src/tests/servers/app/newClipping/MyView.h @@ -14,6 +14,7 @@ public: virtual void MouseDown(BPoint where); virtual void MouseUp(BPoint where); virtual void MouseMoved(BPoint where, uint32 code, const BMessage *a_message); + virtual void MessageReceived(BMessage*); void CopyRegion(BRegion *reg, float dx, float dy); void RequestRedraw(); @@ -29,4 +30,5 @@ private: BPoint fLastPos; Layer *fMovingLayer; bool fIsResize; + bool fIs2ndButton; }; \ No newline at end of file diff --git a/src/tests/servers/app/newClipping/main.cpp b/src/tests/servers/app/newClipping/main.cpp index 1bbfa63372..ed2852a9c5 100644 --- a/src/tests/servers/app/newClipping/main.cpp +++ b/src/tests/servers/app/newClipping/main.cpp @@ -66,6 +66,7 @@ clsMainWindow::clsMainWindow(const char *uWindowTitle) wind = this; fView = new MyView(Bounds(), "emu", B_FOLLOW_ALL, B_WILL_DRAW); AddChild(fView); + fView->MakeFocus(true); } clsMainWindow::~clsMainWindow() @@ -157,15 +158,13 @@ void clsMainWindow::test1() wb2->GetWantedRegion(temp); topLayer->RebuildVisibleRegions(temp, wb2); - wind->Lock(); - fView->Invalidate(); - wind->Unlock(); + fView->RequestRedraw(); - snooze(2000000); + snooze(1000000); wb1->Hide(); - snooze(2000000); + snooze(1000000); wb1->Show();