diff --git a/src/tests/servers/app/playground/Jamfile b/src/tests/servers/app/playground/Jamfile index 59d98eafa0..0560020189 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 da5a113f15..514b91bad1 100644 --- a/src/tests/servers/app/playground/ObjectView.cpp +++ b/src/tests/servers/app/playground/ObjectView.cpp @@ -25,6 +25,12 @@ ObjectView::ObjectView(BRect frame, const char* name, rgb_color bg = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT); SetViewColor(bg); SetLowColor(bg); + + BFont font; + GetFont(&font); + font.SetSize(20.0); + font.SetRotation(6.0); + SetFont(&font, B_FONT_ROTATION | B_FONT_SIZE); } // AttachedToWindow @@ -66,11 +72,12 @@ ObjectView::Draw(BRect updateRect) message = "to draw an object!"; width = StringWidth(message); p.x = r.left + r.Width() / 2.0 - width / 2.0; - p.y += 20; + p.y += 25; DrawString(message, p); SetDrawingMode(B_OP_ALPHA); +// SetDrawingMode(B_OP_OVER); for (int32 i = 0; State* state = (State*)fStateList.ItemAt(i); i++) state->Draw(this); diff --git a/src/tests/servers/app/playground/ObjectWindow.cpp b/src/tests/servers/app/playground/ObjectWindow.cpp index 579590e541..e678639d5a 100644 --- a/src/tests/servers/app/playground/ObjectWindow.cpp +++ b/src/tests/servers/app/playground/ObjectWindow.cpp @@ -10,7 +10,9 @@ #include #include #include +#include #include +#include #include #include #include @@ -26,6 +28,7 @@ enum { MSG_SET_FILL_OR_STROKE = 'stfs', MSG_SET_COLOR = 'stcl', MSG_SET_PEN_SIZE = 'stps', + MSG_SET_DRAWING_MODE = 'stdm', MSG_NEW_OBJECT = 'nobj', @@ -123,6 +126,25 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name) radioButton = new BRadioButton(b, "radio 4", "Ellipse", message); controlGroup->AddChild(radioButton); + // drawing mode +/* BPopUpMenu* popupMenu = new BPopUpMenu(""); + + message = new BMessage(MSG_SET_DRAWING_MODE); + message->AddInt32("mode", B_OP_COPY); + popupMenu->AddItem(new BMenuItem("B_OP_COPY", message)); + + message = new BMessage(MSG_SET_DRAWING_MODE); + message->AddInt32("mode", B_OP_OVER); + popupMenu->AddItem(new BMenuItem("B_OP_OVER", message)); + + b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); + fDrawingModeMF = new BMenuField(b, "drawing mode field", "Mode", + popupMenu); + + controlGroup->AddChild(fDrawingModeMF); + + fDrawingModeMF->SetDivider(fDrawingModeMF->StringWidth(fDrawingModeMF->Label()) + 10.0); +*/ // red text control b.OffsetBy(0, radioButton->Bounds().Height() + 5.0); fRedTC = new BTextControl(b, "red text control", "Red", "", @@ -217,6 +239,7 @@ ObjectWindow::MessageReceived(BMessage* message) } case MSG_SET_COLOR: fObjectView->SetStateColor(_GetColor()); + _UpdateColorControls(); break; case MSG_OBJECT_COUNT_CHANGED: fClearB->SetEnabled(fObjectView->CountObjects() > 0); @@ -225,8 +248,8 @@ ObjectWindow::MessageReceived(BMessage* message) fObjectView->SetState(NULL); break; case MSG_CLEAR: { - BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes"); - if (alert->Go() == 1) +// BAlert *alert = new BAlert("Playground", "Do you really want to clear all drawing objects?", "No", "Yes"); +// if (alert->Go() == 1) fObjectView->MakeEmpty(); break; } @@ -241,6 +264,29 @@ ObjectWindow::MessageReceived(BMessage* message) // _UpdateControls void ObjectWindow::_UpdateControls() const +{ + _UpdateColorControls(); + + // update buttons + fClearB->SetEnabled(fObjectView->CountObjects() > 0); + + fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE); + + // pen size + char string[32]; + sprintf(string, "%.1f", fObjectView->StatePenSize()); + fPenSizeTC->SetText(string); + + // disable penSize if fill is on + if (!fFillCB->IsEnabled()) + fPenSizeTC->SetEnabled(true); + else + fPenSizeTC->SetEnabled(fFillCB->Value() == B_CONTROL_OFF); +} + +// _UpdateColorControls +void +ObjectWindow::_UpdateColorControls() const { // update color rgb_color c = fObjectView->StateColor(); @@ -257,20 +303,6 @@ ObjectWindow::_UpdateControls() const sprintf(string, "%d", c.alpha); fAlphaTC->SetText(string); - - - // update buttons - fClearB->SetEnabled(fObjectView->CountObjects() > 0); - - fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE); - - // disable penSize if fill is on - sprintf(string, "%.1f", fObjectView->StatePenSize()); - fPenSizeTC->SetText(string); - if (!fFillCB->IsEnabled()) - fPenSizeTC->SetEnabled(true); - else - fPenSizeTC->SetEnabled(fFillCB->Value() == B_CONTROL_OFF); } // _GetColor diff --git a/src/tests/servers/app/playground/ObjectWindow.h b/src/tests/servers/app/playground/ObjectWindow.h index b57e25875a..cc79fd7d38 100644 --- a/src/tests/servers/app/playground/ObjectWindow.h +++ b/src/tests/servers/app/playground/ObjectWindow.h @@ -5,16 +5,9 @@ #include -/* -class Box; -class Button; -class CheckBox; -class Menu; -class MenuBar; -class RadioButton; -class TextView;*/ class BButton; class BCheckBox; +class BMenuField; class BTextControl; class ObjectView; @@ -29,6 +22,7 @@ class ObjectWindow : public BWindow { private: void _UpdateControls() const; + void _UpdateColorControls() const; rgb_color _GetColor() const; ObjectView* fObjectView; @@ -36,6 +30,11 @@ class ObjectWindow : public BWindow { BButton* fNewB; BButton* fClearB; + BButton* fUndoB; + BButton* fRedoB; + + BMenuField* fDrawingModeMF; + BTextControl* fRedTC; BTextControl* fGreenTC; BTextControl* fBlueTC; diff --git a/src/tests/servers/app/playground/States.cpp b/src/tests/servers/app/playground/States.cpp index bdd726676c..bc9d6d4090 100644 --- a/src/tests/servers/app/playground/States.cpp +++ b/src/tests/servers/app/playground/States.cpp @@ -143,7 +143,7 @@ class RoundRectState : public State { if (fValid) { view->SetHighColor(fColor); BRect r = _ValidRect(); - float radius = min_c(r.Width() / 4.0, r.Height() / 4.0); + float radius = min_c(r.Width() / 3.0, r.Height() / 3.0); if (fFill) view->FillRoundRect(r, radius, radius); else { diff --git a/src/tests/servers/app/playground/main.cpp b/src/tests/servers/app/playground/main.cpp index 046a1d373a..36bcd68596 100644 --- a/src/tests/servers/app/playground/main.cpp +++ b/src/tests/servers/app/playground/main.cpp @@ -10,7 +10,7 @@ main(int argc, char** argv) { BApplication* app = new BApplication("application/x.vnd-Haiku.Objects"); - BRect frame(50.0, 50.0, 450.0, 430.0); + BRect frame(50.0, 50.0, 450.0, 450.0); (new ObjectWindow(frame, "Playground"))->Show(); app->Run();