From 5a2b3bac8288d9ec6fe2ca2c92e319f7cc650d12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Wed, 11 Jan 2006 19:34:57 +0000 Subject: [PATCH] Axel wants to check up on something, and I had added the testbed for that already git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15913 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../servers/app/playground/ObjectView.cpp | 77 +++++++++++++++++-- src/tests/servers/app/playground/ObjectView.h | 2 + .../servers/app/playground/ObjectWindow.cpp | 1 + 3 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/tests/servers/app/playground/ObjectView.cpp b/src/tests/servers/app/playground/ObjectView.cpp index 13cd609b37..8cfbfca782 100644 --- a/src/tests/servers/app/playground/ObjectView.cpp +++ b/src/tests/servers/app/playground/ObjectView.cpp @@ -2,8 +2,10 @@ #include +#include #include #include +#include #include #include #include @@ -49,6 +51,11 @@ ObjectView::ObjectView(BRect frame, const char* name, SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); } +// destructor +ObjectView::~ObjectView() +{ +} + // AttachedToWindow void ObjectView::AttachedToWindow() @@ -56,6 +63,12 @@ ObjectView::AttachedToWindow() SetViewColor(B_TRANSPARENT_COLOR); } +// DetachedFromWindow +void +ObjectView::DetachedFromWindow() +{ +} + // Draw void ObjectView::Draw(BRect updateRect) @@ -137,11 +150,43 @@ ObjectView::MouseDown(BPoint where) { uint32 buttons; int32 clicks; +// +// snooze(1000000); +// BMessageQueue* queue = Window()->MessageQueue(); +// BMessage* msg; +// int32 count = 0; +// for (int32 i = 0; (msg = queue->FindMessage(i)); i++) { +// if (msg->what == B_MOUSE_MOVED) +// count++; +// } +// printf("B_MOUSE_MOVED count before GetMouse(): %ld\n", count); +// +// GetMouse(&where, &buttons); +// +// count = 0; +// for (int32 i = 0; (msg = queue->FindMessage(i)); i++) { +// if (msg->what == B_MOUSE_MOVED) +// count++; +// } +// printf("B_MOUSE_MOVED count after 1st GetMouse(): %ld\n", count); +// +// GetMouse(&where, &buttons); +// +// count = 0; +// for (int32 i = 0; (msg = queue->FindMessage(i)); i++) { +// if (msg->what == B_MOUSE_MOVED) +// count++; +// } +// printf("B_MOUSE_MOVED count after 2nd GetMouse(): %ld\n", count); +// return; + +//be_app->HideCursor(); + Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons); Window()->CurrentMessage()->FindInt32("clicks", &clicks); //printf("ObjectView::MouseDown() - clicks: %ld\n", clicks); - fScrolling = buttons & B_SECONDARY_MOUSE_BUTTON; - fInitiatingDrag = !fScrolling && (buttons & B_TERTIARY_MOUSE_BUTTON); + fInitiatingDrag = buttons & B_SECONDARY_MOUSE_BUTTON; + fScrolling = !fInitiatingDrag && (buttons & B_TERTIARY_MOUSE_BUTTON); SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS); @@ -153,9 +198,7 @@ ObjectView::MouseDown(BPoint where) fFill, fPenSize)); if (fState) { -// Invalidate(fState->Bounds()); fState->MouseDown(where); -// Invalidate(fState->Bounds()); } } } @@ -164,6 +207,8 @@ ObjectView::MouseDown(BPoint where) void ObjectView::MouseUp(BPoint where) { +//be_app->ShowCursor(); + if (fScrolling) { fScrolling = false; } else { @@ -193,8 +238,28 @@ if (dragMessage) { BPoint offset = fLastMousePos - where; if (sqrtf(offset.x * offset.x + offset.y * offset.y) > 5.0) { BMessage dragMessage('drag'); - BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 20, 20), B_RGBA32); - memset(dragBitmap->Bits(), 128, dragBitmap->BitsLength()); + BBitmap* dragBitmap = new BBitmap(BRect(0, 0, 40, 40), B_RGBA32, true); + if (dragBitmap->Lock()) { + BView* helper = new BView(dragBitmap->Bounds(), "offscreen view", + B_FOLLOW_ALL, B_WILL_DRAW); + dragBitmap->AddChild(helper); + helper->SetDrawingMode(B_OP_ALPHA); + helper->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE); + + BRect r(helper->Bounds()); + helper->SetHighColor(0, 0, 0, 128); + helper->StrokeRect(r); + + helper->SetHighColor(200, 200, 200, 100); + r.InsetBy(1, 1); + helper->FillRect(r); + + helper->SetHighColor(0, 0, 0, 255); + const char* text = "Test"; + float pos = (r.Width() - helper->StringWidth(text)) / 2; + helper->DrawString(text, BPoint(pos, 25)); + helper->Sync(); + } DragMessage(&dragMessage, dragBitmap, B_OP_ALPHA, B_ORIGIN, this); fInitiatingDrag = false; diff --git a/src/tests/servers/app/playground/ObjectView.h b/src/tests/servers/app/playground/ObjectView.h index a9e656ecdf..d0bd0ff339 100644 --- a/src/tests/servers/app/playground/ObjectView.h +++ b/src/tests/servers/app/playground/ObjectView.h @@ -17,9 +17,11 @@ class ObjectView : public BView { public: ObjectView(BRect frame, const char* name, uint32 resizeFlags, uint32 flags); + virtual ~ObjectView(); // BView virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); virtual void Draw(BRect updateRect); diff --git a/src/tests/servers/app/playground/ObjectWindow.cpp b/src/tests/servers/app/playground/ObjectWindow.cpp index cf3d8d81c6..96530fc25a 100644 --- a/src/tests/servers/app/playground/ObjectWindow.cpp +++ b/src/tests/servers/app/playground/ObjectWindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include