From 778e3c640d3f8f0e04e15303871b7d1a7b8a86c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Sat, 26 Aug 2006 14:11:39 +0000 Subject: [PATCH] * just an update to my local playground git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18641 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../servers/app/playground/ObjectView.cpp | 63 ++++++++++++++++++- .../servers/app/playground/ObjectWindow.cpp | 39 ++++++++++-- src/tests/servers/app/playground/States.cpp | 6 ++ src/tests/servers/app/playground/main.cpp | 11 +++- src/tests/servers/app/playground/run | 16 ++--- 5 files changed, 116 insertions(+), 19 deletions(-) diff --git a/src/tests/servers/app/playground/ObjectView.cpp b/src/tests/servers/app/playground/ObjectView.cpp index 8cfbfca782..536de5a4bf 100644 --- a/src/tests/servers/app/playground/ObjectView.cpp +++ b/src/tests/servers/app/playground/ObjectView.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -15,6 +16,29 @@ #include "ObjectView.h" +const unsigned char kMoveCursor[] = { 16, 1, 8, 8, + 0x01, 0x80, 0x02, 0x40, 0x04, 0x20, 0x08, 0x10, + 0x1e, 0x78, 0x2a, 0x54, 0x4e, 0x72, 0x80, 0x01, + 0x80, 0x01, 0x4e, 0x72, 0x2a, 0x54, 0x1e, 0x78, + 0x08, 0x10, 0x04, 0x20, 0x02, 0x40, 0x01, 0x80, + + 0x01, 0x80, 0x03, 0xc0, 0x07, 0xe0, 0x0f, 0xf0, + 0x1f, 0xf8, 0x3b, 0xdc, 0x7f, 0xfe, 0xff, 0xff, + 0xff, 0xff, 0x7f, 0xfe, 0x3b, 0xdc, 0x1f, 0xf8, + 0x0f, 0xf0, 0x07, 0xe0, 0x03, 0xc0, 0x01, 0x80 }; + +const unsigned char kGrabCursor[] = { 16, 1, 8, 9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0xb0, 0x12, 0x4c, 0x10, 0x0a, 0x08, 0x02, + 0x18, 0x02, 0x20, 0x02, 0x20, 0x02, 0x20, 0x04, + 0x10, 0x04, 0x08, 0x08, 0x04, 0x08, 0x04, 0x08, + + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0d, 0xb0, 0x1f, 0xfc, 0x1f, 0xfe, 0x0f, 0xfe, + 0x1f, 0xfe, 0x3f, 0xfe, 0x3f, 0xfe, 0x3f, 0xfc, + 0x1f, 0xfc, 0x0f, 0xf8, 0x07, 0xf8, 0x07, 0xf8 }; + + // constructor ObjectView::ObjectView(BRect frame, const char* name, uint32 resizeFlags, uint32 flags) @@ -92,15 +116,43 @@ ObjectView::Draw(BRect updateRect) BPoint(r.left, r.top + 1), shadow); EndLineArray();*/ +//Sync(); +// SetHighColor(200, 200, 200, 255); +//// BRect rect(0.0, 0.0, 10.0, 11.0); +// int32 counter = 0; +// BRegion region; +//// while (rect.top < r.bottom) { +//// while (rect.left < r.right) { +//// region.Include(rect); +//// rect.OffsetBy(rect.Width() + 2, 0.0); +//// +//// counter++; +//// } +//// rect.OffsetTo(0.0, rect.top + rect.Height() + 2); +//// } +// BRect rect(0.0, 0.0, 0.0, 10.0); +// for (int32 i = 0; i < 100; i++) { +// region.Include(rect); +// rect.OffsetBy(rect.Width() + 1, 1.0); +// counter++; +// } +//bigtime_t now = system_time(); +// FillRegion(®ion); +//Sync(); +//printf("rendering %ld small rects (region: %ld): %lld\n", counter, +//region.CountRects(), system_time() - now); + + SetDrawingMode(B_OP_COPY); SetHighColor(255, 0, 0, 128); const char* message = "Click and drag to draw an object"; float width = StringWidth(message); - BPoint p(r.Width() / 2.0 - width / 2.0, - r.Height() / 2.0); + BPoint p((r.Width() - width) / 2.0, r.Height() / 2.0); //Sync(); +//snooze(1000); +// //bigtime_t now = system_time(); DrawString(message, p); @@ -231,6 +283,9 @@ if (dragMessage) { } if (fScrolling) { + BCursor cursor(kGrabCursor); + SetViewCursor(&cursor); + BPoint offset = fLastMousePos - where; ScrollBy(offset.x, offset.y); fLastMousePos = where + offset; @@ -265,6 +320,9 @@ if (dragMessage) { fInitiatingDrag = false; } } else { + BCursor cursor(kMoveCursor); + SetViewCursor(&cursor); + if (fState && fState->IsTracking()) { BRect before = fState->Bounds(); @@ -275,6 +333,7 @@ if (dragMessage) { Invalidate(invalid); } } +// SetViewCursor(); } // MessageReceived diff --git a/src/tests/servers/app/playground/ObjectWindow.cpp b/src/tests/servers/app/playground/ObjectWindow.cpp index 96530fc25a..0216e4bd88 100644 --- a/src/tests/servers/app/playground/ObjectWindow.cpp +++ b/src/tests/servers/app/playground/ObjectWindow.cpp @@ -83,10 +83,36 @@ class ObjectListView : public BListView { BListView::KeyDown(bytes, numBytes); } } + + virtual bool InitiateDrag(BPoint point, int32 itemIndex, bool wasSelected) + { + printf("InitiateDrag(BPoint(%.1f, %.1f), itemIndex: %ld, wasSelected: %d)\n", + point.x, point.y, itemIndex, wasSelected); + SwapItems(itemIndex, itemIndex + 1); + return true; + } + + virtual void SelectionChanged() + { + printf("SelectionChanged() - first selected: %ld\n", CurrentSelection(0)); + } }; // #pragma mark - +class TestView : public BView { +public: + TestView(BRect frame, const char* name, uint32 resizeMode, uint32 flags) + : BView(frame, name, resizeMode, flags) + { + } + + void AttachedToWindow() + { + SetViewColor(255, 0, 0); + } +}; + // constructor ObjectWindow::ObjectWindow(BRect frame, const char* name) // : BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, @@ -111,6 +137,8 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name) BMenu* menu = new BMenu("File"); menuBar->AddItem(menu); + menu->AddItem(new BMenu("Submenu")); + BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'); menu->AddItem(menuItem); @@ -322,7 +350,7 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name) b.right -= B_V_SCROLL_BAR_WIDTH; b.bottom = fDrawingModeMF->Frame().top - 5.0; - fObjectLV = new ObjectListView(b, "object list", B_MULTIPLE_SELECTION_LIST); + fObjectLV = new ObjectListView(b, "object list", B_SINGLE_SELECTION_LIST); fObjectLV->SetSelectionMessage(new BMessage(MSG_OBJECT_SELECTED)); // wrap a scroll view around the list view @@ -340,9 +368,12 @@ b.bottom = fDrawingModeMF->Frame().top - 5.0; B_WILL_DRAW | B_NAVIGABLE_JUMP | B_FRAME_EVENTS | B_NAVIGABLE); - tabView->AddTab(new BView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0)); - tabView->AddTab(new BView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0)); - tabView->AddTab(new BView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0)); + BView* tabChild = new TestView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0); + tabView->AddTab(tabChild); + tabChild = new TestView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0); + tabView->AddTab(tabChild); + tabChild = new BTextControl(BRect(0, 0, 80, 40), "T", "Test", "Text", NULL); + tabView->AddTab(tabChild); controlGroup->AddChild(tabView); // enforce some size limits diff --git a/src/tests/servers/app/playground/States.cpp b/src/tests/servers/app/playground/States.cpp index 0d97bc34cb..f8b508fd8e 100644 --- a/src/tests/servers/app/playground/States.cpp +++ b/src/tests/servers/app/playground/States.cpp @@ -37,6 +37,9 @@ State::Init(rgb_color color, drawing_mode mode, bool fill, float penSize) void State::MouseDown(BPoint where) { + where.x = floorf(where.x + 0.5); + where.y = floorf(where.y + 0.5); + if (_HitTest(where, fStartPoint)) { fTracking = TRACKING_START; fClickOffset = fStartPoint - where; @@ -61,6 +64,9 @@ State::MouseUp() void State::MouseMoved(BPoint where) { + where.x = floorf(where.x + 0.5); + where.y = floorf(where.y + 0.5); + if (fTracking == TRACKING_START) { fStartPoint = where + fClickOffset; fValid = true; diff --git a/src/tests/servers/app/playground/main.cpp b/src/tests/servers/app/playground/main.cpp index 40a53be999..325d8ed1af 100644 --- a/src/tests/servers/app/playground/main.cpp +++ b/src/tests/servers/app/playground/main.cpp @@ -1,6 +1,8 @@ -// main.cpp +#include +#include #include +#include #include "ObjectWindow.h" @@ -10,8 +12,13 @@ main(int argc, char** argv) { BApplication* app = new BApplication("application/x.vnd-Haiku.Objects"); + BRect a(LONG_MAX, LONG_MAX, LONG_MIN, LONG_MIN); + a.PrintToStream(); + BRect frame(50.0, 50.0, 600.0, 400.0); - (new ObjectWindow(frame, "Playground"))->Show(); + BWindow* window = new ObjectWindow(frame, "Playground"); + + window->Show(); app->Run(); diff --git a/src/tests/servers/app/playground/run b/src/tests/servers/app/playground/run index 3bb8d9a5d1..9a098245f6 100755 --- a/src/tests/servers/app/playground/run +++ b/src/tests/servers/app/playground/run @@ -1,23 +1,17 @@ #!/bin/sh -../../../../../generated/tests/apps/run_haiku_registrar || exit +../../../../../generated/tests/libbe_test/x86/apps/run_haiku_registrar || exit -if test -f ../../../../../generated/tests/apps/haiku_app_server; then - ../../../../../generated/tests/apps/haiku_app_server & +if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then + ../../../../../generated/tests/libbe_test/x86/apps//haiku_app_server & else echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first." fi sleep 1s -#if test -f ../../../../../generated/tests/apps/MiniTerminal; then -# ../../../../../generated/tests/apps/MiniTerminal & -#else -# echo "You need to \"TARGET_PLATFORM=r5 jam install-test-apps\" first." -#fi - -if test -f ../../../../../generated/tests/apps/Playground; then - ../../../../../generated/tests/apps/Playground +if test -f ../../../../../generated/tests/libbe_test/x86/apps/Playground; then + ../../../../../generated/tests/libbe_test/x86/apps/Playground else echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first." fi