* just an update to my local playground
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18641 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
#include <Bitmap.h>
|
#include <Bitmap.h>
|
||||||
|
#include <Cursor.h>
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
#include <MessageQueue.h>
|
#include <MessageQueue.h>
|
||||||
#include <Region.h>
|
#include <Region.h>
|
||||||
@@ -15,6 +16,29 @@
|
|||||||
|
|
||||||
#include "ObjectView.h"
|
#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
|
// constructor
|
||||||
ObjectView::ObjectView(BRect frame, const char* name,
|
ObjectView::ObjectView(BRect frame, const char* name,
|
||||||
uint32 resizeFlags, uint32 flags)
|
uint32 resizeFlags, uint32 flags)
|
||||||
@@ -92,15 +116,43 @@ ObjectView::Draw(BRect updateRect)
|
|||||||
BPoint(r.left, r.top + 1), shadow);
|
BPoint(r.left, r.top + 1), shadow);
|
||||||
EndLineArray();*/
|
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);
|
SetHighColor(255, 0, 0, 128);
|
||||||
|
|
||||||
const char* message = "Click and drag to draw an object";
|
const char* message = "Click and drag to draw an object";
|
||||||
float width = StringWidth(message);
|
float width = StringWidth(message);
|
||||||
|
|
||||||
BPoint p(r.Width() / 2.0 - width / 2.0,
|
BPoint p((r.Width() - width) / 2.0, r.Height() / 2.0);
|
||||||
r.Height() / 2.0);
|
|
||||||
|
|
||||||
//Sync();
|
//Sync();
|
||||||
|
//snooze(1000);
|
||||||
|
//
|
||||||
//bigtime_t now = system_time();
|
//bigtime_t now = system_time();
|
||||||
DrawString(message, p);
|
DrawString(message, p);
|
||||||
|
|
||||||
@@ -231,6 +283,9 @@ if (dragMessage) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fScrolling) {
|
if (fScrolling) {
|
||||||
|
BCursor cursor(kGrabCursor);
|
||||||
|
SetViewCursor(&cursor);
|
||||||
|
|
||||||
BPoint offset = fLastMousePos - where;
|
BPoint offset = fLastMousePos - where;
|
||||||
ScrollBy(offset.x, offset.y);
|
ScrollBy(offset.x, offset.y);
|
||||||
fLastMousePos = where + offset;
|
fLastMousePos = where + offset;
|
||||||
@@ -265,6 +320,9 @@ if (dragMessage) {
|
|||||||
fInitiatingDrag = false;
|
fInitiatingDrag = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
BCursor cursor(kMoveCursor);
|
||||||
|
SetViewCursor(&cursor);
|
||||||
|
|
||||||
if (fState && fState->IsTracking()) {
|
if (fState && fState->IsTracking()) {
|
||||||
BRect before = fState->Bounds();
|
BRect before = fState->Bounds();
|
||||||
|
|
||||||
@@ -275,6 +333,7 @@ if (dragMessage) {
|
|||||||
Invalidate(invalid);
|
Invalidate(invalid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// SetViewCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
// MessageReceived
|
// MessageReceived
|
||||||
|
|||||||
@@ -83,10 +83,36 @@ class ObjectListView : public BListView {
|
|||||||
BListView::KeyDown(bytes, numBytes);
|
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 -
|
// #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
|
// constructor
|
||||||
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
||||||
// : BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
// : 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");
|
BMenu* menu = new BMenu("File");
|
||||||
menuBar->AddItem(menu);
|
menuBar->AddItem(menu);
|
||||||
|
|
||||||
|
menu->AddItem(new BMenu("Submenu"));
|
||||||
|
|
||||||
BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
|
BMenuItem* menuItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED),
|
||||||
'Q');
|
'Q');
|
||||||
menu->AddItem(menuItem);
|
menu->AddItem(menuItem);
|
||||||
@@ -322,7 +350,7 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
|||||||
b.right -= B_V_SCROLL_BAR_WIDTH;
|
b.right -= B_V_SCROLL_BAR_WIDTH;
|
||||||
b.bottom = fDrawingModeMF->Frame().top - 5.0;
|
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));
|
fObjectLV->SetSelectionMessage(new BMessage(MSG_OBJECT_SELECTED));
|
||||||
|
|
||||||
// wrap a scroll view around the list view
|
// 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_WILL_DRAW | B_NAVIGABLE_JUMP |
|
||||||
B_FRAME_EVENTS | B_NAVIGABLE);
|
B_FRAME_EVENTS | B_NAVIGABLE);
|
||||||
|
|
||||||
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(new BView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0));
|
tabView->AddTab(tabChild);
|
||||||
tabView->AddTab(new BView(BRect(0, 0, 40, 40), "T", B_FOLLOW_ALL, 0));
|
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);
|
controlGroup->AddChild(tabView);
|
||||||
|
|
||||||
// enforce some size limits
|
// enforce some size limits
|
||||||
|
|||||||
@@ -37,6 +37,9 @@ State::Init(rgb_color color, drawing_mode mode, bool fill, float penSize)
|
|||||||
void
|
void
|
||||||
State::MouseDown(BPoint where)
|
State::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
|
where.x = floorf(where.x + 0.5);
|
||||||
|
where.y = floorf(where.y + 0.5);
|
||||||
|
|
||||||
if (_HitTest(where, fStartPoint)) {
|
if (_HitTest(where, fStartPoint)) {
|
||||||
fTracking = TRACKING_START;
|
fTracking = TRACKING_START;
|
||||||
fClickOffset = fStartPoint - where;
|
fClickOffset = fStartPoint - where;
|
||||||
@@ -61,6 +64,9 @@ State::MouseUp()
|
|||||||
void
|
void
|
||||||
State::MouseMoved(BPoint where)
|
State::MouseMoved(BPoint where)
|
||||||
{
|
{
|
||||||
|
where.x = floorf(where.x + 0.5);
|
||||||
|
where.y = floorf(where.y + 0.5);
|
||||||
|
|
||||||
if (fTracking == TRACKING_START) {
|
if (fTracking == TRACKING_START) {
|
||||||
fStartPoint = where + fClickOffset;
|
fStartPoint = where + fClickOffset;
|
||||||
fValid = true;
|
fValid = true;
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
// main.cpp
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include <Application.h>
|
#include <Application.h>
|
||||||
|
#include <Message.h>
|
||||||
|
|
||||||
#include "ObjectWindow.h"
|
#include "ObjectWindow.h"
|
||||||
|
|
||||||
@@ -10,8 +12,13 @@ main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
BApplication* app = new BApplication("application/x.vnd-Haiku.Objects");
|
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);
|
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();
|
app->Run();
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,17 @@
|
|||||||
#!/bin/sh
|
#!/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
|
if test -f ../../../../../generated/tests/libbe_test/x86/apps/haiku_app_server; then
|
||||||
../../../../../generated/tests/apps/haiku_app_server &
|
../../../../../generated/tests/libbe_test/x86/apps//haiku_app_server &
|
||||||
else
|
else
|
||||||
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sleep 1s
|
sleep 1s
|
||||||
|
|
||||||
#if test -f ../../../../../generated/tests/apps/MiniTerminal; then
|
if test -f ../../../../../generated/tests/libbe_test/x86/apps/Playground; then
|
||||||
# ../../../../../generated/tests/apps/MiniTerminal &
|
../../../../../generated/tests/libbe_test/x86/apps/Playground
|
||||||
#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
|
|
||||||
else
|
else
|
||||||
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
echo "You need to \"TARGET_PLATFORM=libbe_test jam install-test-apps\" first."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user