uses a slider now, uses SetSizeLimits, objects can now be edited after they have been created
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12940 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
45ca1c948c
commit
b7f478e26d
@ -17,7 +17,7 @@ if ( $(TARGET_PLATFORM) = haiku ) {
|
|||||||
} else {
|
} else {
|
||||||
# for running in the Haiku app_server under R5:
|
# for running in the Haiku app_server under R5:
|
||||||
LinkSharedOSLibs Playground :
|
LinkSharedOSLibs Playground :
|
||||||
<boot!home!config!lib>libopenbeos.so ;
|
# <boot!home!config!lib>libopenbeos.so ;
|
||||||
# be ;
|
be ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
#include <Message.h>
|
#include <Message.h>
|
||||||
|
#include <String.h>
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
#include "States.h"
|
#include "States.h"
|
||||||
@ -22,9 +23,8 @@ ObjectView::ObjectView(BRect frame, const char* name,
|
|||||||
fScrolling(false),
|
fScrolling(false),
|
||||||
fLastMousePos(0.0, 0.0)
|
fLastMousePos(0.0, 0.0)
|
||||||
{
|
{
|
||||||
rgb_color bg = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT);
|
|
||||||
SetViewColor(bg);
|
SetLowColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_1_TINT));
|
||||||
SetLowColor(bg);
|
|
||||||
|
|
||||||
BFont font;
|
BFont font;
|
||||||
GetFont(&font);
|
GetFont(&font);
|
||||||
@ -37,12 +37,15 @@ ObjectView::ObjectView(BRect frame, const char* name,
|
|||||||
void
|
void
|
||||||
ObjectView::AttachedToWindow()
|
ObjectView::AttachedToWindow()
|
||||||
{
|
{
|
||||||
|
SetViewColor(B_TRANSPARENT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
void
|
void
|
||||||
ObjectView::Draw(BRect updateRect)
|
ObjectView::Draw(BRect updateRect)
|
||||||
{
|
{
|
||||||
|
FillRect(updateRect, B_SOLID_LOW);
|
||||||
|
|
||||||
rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
|
rgb_color noTint = ui_color(B_PANEL_BACKGROUND_COLOR);
|
||||||
rgb_color shadow = tint_color(noTint, B_DARKEN_2_TINT);
|
rgb_color shadow = tint_color(noTint, B_DARKEN_2_TINT);
|
||||||
rgb_color light = tint_color(noTint, B_LIGHTEN_MAX_TINT);
|
rgb_color light = tint_color(noTint, B_LIGHTEN_MAX_TINT);
|
||||||
@ -95,16 +98,18 @@ ObjectView::MouseDown(BPoint where)
|
|||||||
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
|
Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons);
|
||||||
fScrolling = buttons & B_SECONDARY_MOUSE_BUTTON;
|
fScrolling = buttons & B_SECONDARY_MOUSE_BUTTON;
|
||||||
|
|
||||||
|
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
|
||||||
|
|
||||||
if (fScrolling) {
|
if (fScrolling) {
|
||||||
fLastMousePos = where;
|
fLastMousePos = where;
|
||||||
} else {
|
} else {
|
||||||
if (!fState)
|
if (!fState)
|
||||||
SetState(State::StateFor(fObjectType, fColor, fFill, fPenSize));
|
AddObject(State::StateFor(fObjectType, fColor, fFill, fPenSize));
|
||||||
|
|
||||||
if (fState) {
|
if (fState) {
|
||||||
Invalidate(fState->Bounds());
|
// Invalidate(fState->Bounds());
|
||||||
fState->MouseDown(where);
|
fState->MouseDown(where);
|
||||||
Invalidate(fState->Bounds());
|
// Invalidate(fState->Bounds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,11 +153,18 @@ ObjectView::MouseMoved(BPoint where, uint32 transit,
|
|||||||
void
|
void
|
||||||
ObjectView::SetState(State* state)
|
ObjectView::SetState(State* state)
|
||||||
{
|
{
|
||||||
fState = state;
|
if (fState != state) {
|
||||||
|
if (fState) {
|
||||||
if (fState) {
|
fState->SetEditing(false);
|
||||||
Invalidate(fState->Bounds());
|
Invalidate(fState->Bounds());
|
||||||
AddObject(fState);
|
}
|
||||||
|
|
||||||
|
fState = state;
|
||||||
|
|
||||||
|
if (fState) {
|
||||||
|
fState->SetEditing(true);
|
||||||
|
Invalidate(fState->Bounds());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,6 +185,8 @@ ObjectView::AddObject(State* state)
|
|||||||
if (state) {
|
if (state) {
|
||||||
fStateList.AddItem((void*)state);
|
fStateList.AddItem((void*)state);
|
||||||
Window()->PostMessage(MSG_OBJECT_COUNT_CHANGED);
|
Window()->PostMessage(MSG_OBJECT_COUNT_CHANGED);
|
||||||
|
|
||||||
|
SetState(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
#include <MenuField.h>
|
#include <MenuField.h>
|
||||||
#include <MenuItem.h>
|
#include <MenuItem.h>
|
||||||
#include <PopUpMenu.h>
|
#include <PopUpMenu.h>
|
||||||
|
#include <Slider.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
#include <RadioButton.h>
|
#include <RadioButton.h>
|
||||||
#include <TextControl.h>
|
#include <TextControl.h>
|
||||||
@ -40,7 +41,16 @@ enum {
|
|||||||
|
|
||||||
// constructor
|
// constructor
|
||||||
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
||||||
: BWindow(frame, name, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS)
|
: BWindow(frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
|
B_ASYNCHRONOUS_CONTROLS)
|
||||||
|
// : BWindow(frame, name, B_DOCUMENT_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
|
// B_ASYNCHRONOUS_CONTROLS)
|
||||||
|
// : BWindow(frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
|
// B_ASYNCHRONOUS_CONTROLS)
|
||||||
|
// : BWindow(frame, name, B_BORDERED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
|
// B_ASYNCHRONOUS_CONTROLS)
|
||||||
|
// : BWindow(frame, name, B_NO_BORDER_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
|
||||||
|
// B_ASYNCHRONOUS_CONTROLS)
|
||||||
{
|
{
|
||||||
BRect b(Bounds());
|
BRect b(Bounds());
|
||||||
|
|
||||||
@ -192,9 +202,23 @@ ObjectWindow::ObjectWindow(BRect frame, const char* name)
|
|||||||
|
|
||||||
// pen size text control
|
// pen size text control
|
||||||
b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
|
b.OffsetBy(0, radioButton->Bounds().Height() + 5.0);
|
||||||
fPenSizeTC = new BTextControl(b, "width text control", "Width", "",
|
b.bottom = b.top + 10.0;//35;
|
||||||
new BMessage(MSG_SET_PEN_SIZE));
|
fPenSizeS = new BSlider(b, "width slider", "Width",
|
||||||
controlGroup->AddChild(fPenSizeTC);
|
NULL, 1, 100, B_TRIANGLE_THUMB);
|
||||||
|
fPenSizeS->SetLimitLabels("1", "100");
|
||||||
|
fPenSizeS->SetModificationMessage(new BMessage(MSG_SET_PEN_SIZE));
|
||||||
|
fPenSizeS->SetHashMarks(B_HASH_MARKS_BOTTOM);
|
||||||
|
fPenSizeS->SetHashMarkCount(10);
|
||||||
|
|
||||||
|
controlGroup->AddChild(fPenSizeS);
|
||||||
|
|
||||||
|
// enforce some size limits
|
||||||
|
float minWidth = controlGroup->Frame().Width() + 30.0;
|
||||||
|
float minHeight = fPenSizeS->Frame().bottom +
|
||||||
|
menuBar->Bounds().Height() + 15.0;
|
||||||
|
float maxWidth = minWidth * 4.0;
|
||||||
|
float maxHeight = minHeight;
|
||||||
|
SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
|
||||||
|
|
||||||
_UpdateControls();
|
_UpdateControls();
|
||||||
}
|
}
|
||||||
@ -223,9 +247,9 @@ ObjectWindow::MessageReceived(BMessage* message)
|
|||||||
fObjectView->SetObjectType(type);
|
fObjectView->SetObjectType(type);
|
||||||
fFillCB->SetEnabled(type != OBJECT_LINE);
|
fFillCB->SetEnabled(type != OBJECT_LINE);
|
||||||
if (!fFillCB->IsEnabled())
|
if (!fFillCB->IsEnabled())
|
||||||
fPenSizeTC->SetEnabled(true);
|
fPenSizeS->SetEnabled(true);
|
||||||
else
|
else
|
||||||
fPenSizeTC->SetEnabled(fFillCB->Value() == B_CONTROL_OFF);
|
fPenSizeS->SetEnabled(fFillCB->Value() == B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -233,7 +257,7 @@ ObjectWindow::MessageReceived(BMessage* message)
|
|||||||
int32 value;
|
int32 value;
|
||||||
if (message->FindInt32("be:value", &value) >= B_OK) {
|
if (message->FindInt32("be:value", &value) >= B_OK) {
|
||||||
fObjectView->SetStateFill(value);
|
fObjectView->SetStateFill(value);
|
||||||
fPenSizeTC->SetEnabled(value == B_CONTROL_OFF);
|
fPenSizeS->SetEnabled(value == B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -254,7 +278,7 @@ ObjectWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_SET_PEN_SIZE:
|
case MSG_SET_PEN_SIZE:
|
||||||
fObjectView->SetStatePenSize(atof(fPenSizeTC->Text()));
|
fObjectView->SetStatePenSize((float)fPenSizeS->Value());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
@ -273,15 +297,13 @@ ObjectWindow::_UpdateControls() const
|
|||||||
fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE);
|
fFillCB->SetEnabled(fObjectView->ObjectType() != OBJECT_LINE);
|
||||||
|
|
||||||
// pen size
|
// pen size
|
||||||
char string[32];
|
fPenSizeS->SetValue((int32)fObjectView->StatePenSize());
|
||||||
sprintf(string, "%.1f", fObjectView->StatePenSize());
|
|
||||||
fPenSizeTC->SetText(string);
|
|
||||||
|
|
||||||
// disable penSize if fill is on
|
// disable penSize if fill is on
|
||||||
if (!fFillCB->IsEnabled())
|
if (!fFillCB->IsEnabled())
|
||||||
fPenSizeTC->SetEnabled(true);
|
fPenSizeS->SetEnabled(true);
|
||||||
else
|
else
|
||||||
fPenSizeTC->SetEnabled(fFillCB->Value() == B_CONTROL_OFF);
|
fPenSizeS->SetEnabled(fFillCB->Value() == B_CONTROL_OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
// _UpdateColorControls
|
// _UpdateColorControls
|
||||||
|
@ -9,6 +9,7 @@ class BButton;
|
|||||||
class BCheckBox;
|
class BCheckBox;
|
||||||
class BMenuField;
|
class BMenuField;
|
||||||
class BTextControl;
|
class BTextControl;
|
||||||
|
class BSlider;
|
||||||
class ObjectView;
|
class ObjectView;
|
||||||
|
|
||||||
class ObjectWindow : public BWindow {
|
class ObjectWindow : public BWindow {
|
||||||
@ -41,7 +42,7 @@ class ObjectWindow : public BWindow {
|
|||||||
BTextControl* fAlphaTC;
|
BTextControl* fAlphaTC;
|
||||||
|
|
||||||
BCheckBox* fFillCB;
|
BCheckBox* fFillCB;
|
||||||
BTextControl* fPenSizeTC;
|
BSlider* fPenSizeS;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OBJECT_WINDOW_H
|
#endif // OBJECT_WINDOW_H
|
||||||
|
@ -7,9 +7,10 @@
|
|||||||
// constructor
|
// constructor
|
||||||
State::State(rgb_color color, bool fill, float penSize)
|
State::State(rgb_color color, bool fill, float penSize)
|
||||||
: fValid(false),
|
: fValid(false),
|
||||||
fTracking(false),
|
fEditing(true),
|
||||||
fTrackingStart(-1.0, -1.0),
|
fTracking(TRACKING_NONE),
|
||||||
fLastMousePos(-1.0, -1.0),
|
fStartPoint(-1.0, -1.0),
|
||||||
|
fEndPoint(-1.0, -1.0),
|
||||||
fColor(color),
|
fColor(color),
|
||||||
fFill(fill),
|
fFill(fill),
|
||||||
fPenSize(penSize)
|
fPenSize(penSize)
|
||||||
@ -20,23 +21,35 @@ State::State(rgb_color color, bool fill, float penSize)
|
|||||||
void
|
void
|
||||||
State::MouseDown(BPoint where)
|
State::MouseDown(BPoint where)
|
||||||
{
|
{
|
||||||
fTracking = true;
|
if (_HitTest(where, fStartPoint)) {
|
||||||
fTrackingStart = fLastMousePos = where;
|
fTracking = TRACKING_START;
|
||||||
|
fClickOffset = fStartPoint - where;
|
||||||
|
} else if (_HitTest(where, fEndPoint)) {
|
||||||
|
fTracking = TRACKING_END;
|
||||||
|
fClickOffset = fEndPoint - where;
|
||||||
|
} else if (!fValid) {
|
||||||
|
fTracking = TRACKING_END;
|
||||||
|
fStartPoint = fEndPoint = where;
|
||||||
|
fClickOffset.Set(0.0, 0.0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MouseUp
|
// MouseUp
|
||||||
void
|
void
|
||||||
State::MouseUp(BPoint where)
|
State::MouseUp(BPoint where)
|
||||||
{
|
{
|
||||||
fTracking = false;
|
fTracking = TRACKING_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// MouseMoved
|
// MouseMoved
|
||||||
void
|
void
|
||||||
State::MouseMoved(BPoint where)
|
State::MouseMoved(BPoint where)
|
||||||
{
|
{
|
||||||
if (fTracking) {
|
if (fTracking == TRACKING_START) {
|
||||||
fLastMousePos = where;
|
fStartPoint = where + fClickOffset;
|
||||||
|
fValid = true;
|
||||||
|
} else if (fTracking == TRACKING_END) {
|
||||||
|
fEndPoint = where + fClickOffset;
|
||||||
fValid = true;
|
fValid = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -62,29 +75,86 @@ State::SetPenSize(float penSize)
|
|||||||
fPenSize = penSize;
|
fPenSize = penSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetEditing
|
||||||
|
void
|
||||||
|
State::SetEditing(bool editing)
|
||||||
|
{
|
||||||
|
fEditing = editing;
|
||||||
|
}
|
||||||
|
|
||||||
// Bounds
|
// Bounds
|
||||||
BRect
|
BRect
|
||||||
State::Bounds() const
|
State::Bounds() const
|
||||||
{
|
{
|
||||||
if (fValid) {
|
if (fValid) {
|
||||||
BRect r = _ValidRect();
|
BRect r = _ValidRect();
|
||||||
if (!fFill) {
|
float inset = -2.0; // for the dots
|
||||||
float inset = -ceilf(fPenSize / 2.0);
|
if (!SupportsFill() || !fFill) {
|
||||||
r.InsetBy(inset, inset);
|
inset = min_c(inset, -ceilf(fPenSize / 2.0));
|
||||||
}
|
}
|
||||||
|
r.InsetBy(inset, inset);
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
return BRect(0.0, 0.0, -1.0, -1.0);
|
return BRect(0.0, 0.0, -1.0, -1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Draw
|
||||||
|
void
|
||||||
|
State::Draw(BView* view) const
|
||||||
|
{
|
||||||
|
if (fValid && fEditing) {
|
||||||
|
_RenderDot(view, fStartPoint);
|
||||||
|
_RenderDot(view, fEndPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// _ValidRect
|
// _ValidRect
|
||||||
BRect
|
BRect
|
||||||
State::_ValidRect() const
|
State::_ValidRect() const
|
||||||
{
|
{
|
||||||
return BRect(min_c(fTrackingStart.x, fLastMousePos.x),
|
return BRect(min_c(fStartPoint.x, fEndPoint.x),
|
||||||
min_c(fTrackingStart.y, fLastMousePos.y),
|
min_c(fStartPoint.y, fEndPoint.y),
|
||||||
max_c(fTrackingStart.x, fLastMousePos.x),
|
max_c(fStartPoint.x, fEndPoint.x),
|
||||||
max_c(fTrackingStart.y, fLastMousePos.y));
|
max_c(fStartPoint.y, fEndPoint.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
// _RenderDot
|
||||||
|
void
|
||||||
|
State::_RenderDot(BView* view, BPoint where) const
|
||||||
|
{
|
||||||
|
view->SetHighColor(0, 0, 0, 255);
|
||||||
|
view->SetPenSize(1.0);
|
||||||
|
view->SetDrawingMode(B_OP_COPY);
|
||||||
|
BRect r(where, where);
|
||||||
|
r.InsetBy(-2.0, -2.0);
|
||||||
|
view->StrokeRect(r);
|
||||||
|
view->SetHighColor(255, 255, 255, 255);
|
||||||
|
r.InsetBy(1.0, 1.0);
|
||||||
|
view->FillRect(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _AdjustViewState
|
||||||
|
void
|
||||||
|
State::_AdjustViewState(BView* view) const
|
||||||
|
{
|
||||||
|
if (fColor.alpha < 255)
|
||||||
|
view->SetDrawingMode(B_OP_ALPHA);
|
||||||
|
else
|
||||||
|
view->SetDrawingMode(B_OP_OVER);
|
||||||
|
|
||||||
|
view->SetHighColor(fColor);
|
||||||
|
|
||||||
|
if (!SupportsFill() || !fFill)
|
||||||
|
view->SetPenSize(fPenSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
// _HitTest
|
||||||
|
bool
|
||||||
|
State::_HitTest(BPoint where, BPoint point) const
|
||||||
|
{
|
||||||
|
BRect r(point, point);
|
||||||
|
r.InsetBy(-8.0, -8.0);
|
||||||
|
return r.Contains(where);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LineState
|
// LineState
|
||||||
@ -93,22 +163,17 @@ class LineState : public State {
|
|||||||
LineState(rgb_color color, bool fill, float penSize)
|
LineState(rgb_color color, bool fill, float penSize)
|
||||||
: State(color, fill, penSize) {}
|
: State(color, fill, penSize) {}
|
||||||
|
|
||||||
virtual BRect Bounds() const
|
|
||||||
{
|
|
||||||
if (fValid) {
|
|
||||||
BRect r = _ValidRect();
|
|
||||||
r.InsetBy(-fPenSize, -fPenSize);
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
return BRect(0.0, 0.0, -1.0, -1.0);
|
|
||||||
}
|
|
||||||
virtual void Draw(BView* view) const
|
virtual void Draw(BView* view) const
|
||||||
{
|
{
|
||||||
if (fValid) {
|
if (fValid) {
|
||||||
view->SetHighColor(fColor);
|
_AdjustViewState(view);
|
||||||
view->SetPenSize(fPenSize);
|
view->StrokeLine(fStartPoint, fEndPoint);
|
||||||
view->StrokeLine(fTrackingStart, fLastMousePos);
|
|
||||||
}
|
}
|
||||||
|
State::Draw(view);
|
||||||
|
}
|
||||||
|
virtual bool SupportsFill() const
|
||||||
|
{
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -121,14 +186,13 @@ class RectState : public State {
|
|||||||
virtual void Draw(BView* view) const
|
virtual void Draw(BView* view) const
|
||||||
{
|
{
|
||||||
if (fValid) {
|
if (fValid) {
|
||||||
view->SetHighColor(fColor);
|
_AdjustViewState(view);
|
||||||
if (fFill)
|
if (fFill)
|
||||||
view->FillRect(_ValidRect());
|
view->FillRect(_ValidRect());
|
||||||
else {
|
else
|
||||||
view->SetPenSize(fPenSize);
|
|
||||||
view->StrokeRect(_ValidRect());
|
view->StrokeRect(_ValidRect());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
State::Draw(view);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -141,16 +205,15 @@ class RoundRectState : public State {
|
|||||||
virtual void Draw(BView* view) const
|
virtual void Draw(BView* view) const
|
||||||
{
|
{
|
||||||
if (fValid) {
|
if (fValid) {
|
||||||
view->SetHighColor(fColor);
|
_AdjustViewState(view);
|
||||||
BRect r = _ValidRect();
|
BRect r = _ValidRect();
|
||||||
float radius = min_c(r.Width() / 3.0, r.Height() / 3.0);
|
float radius = min_c(r.Width() / 3.0, r.Height() / 3.0);
|
||||||
if (fFill)
|
if (fFill)
|
||||||
view->FillRoundRect(r, radius, radius);
|
view->FillRoundRect(r, radius, radius);
|
||||||
else {
|
else
|
||||||
view->SetPenSize(fPenSize);
|
|
||||||
view->StrokeRoundRect(r, radius, radius);
|
view->StrokeRoundRect(r, radius, radius);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
State::Draw(view);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -163,14 +226,13 @@ class EllipseState : public State {
|
|||||||
virtual void Draw(BView* view) const
|
virtual void Draw(BView* view) const
|
||||||
{
|
{
|
||||||
if (fValid) {
|
if (fValid) {
|
||||||
view->SetHighColor(fColor);
|
_AdjustViewState(view);
|
||||||
if (fFill)
|
if (fFill)
|
||||||
view->FillEllipse(_ValidRect());
|
view->FillEllipse(_ValidRect());
|
||||||
else {
|
else
|
||||||
view->SetPenSize(fPenSize);
|
|
||||||
view->StrokeEllipse(_ValidRect());
|
view->StrokeEllipse(_ValidRect());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
State::Draw(view);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,8 +32,12 @@ class State {
|
|||||||
void SetFill(bool fill);
|
void SetFill(bool fill);
|
||||||
void SetPenSize(float penSize);
|
void SetPenSize(float penSize);
|
||||||
|
|
||||||
virtual BRect Bounds() const;
|
void SetEditing(bool editing);
|
||||||
virtual void Draw(BView* view) const = 0;
|
|
||||||
|
BRect Bounds() const;
|
||||||
|
virtual void Draw(BView* view) const;
|
||||||
|
virtual bool SupportsFill() const
|
||||||
|
{ return true; }
|
||||||
|
|
||||||
static State* StateFor(int32 objectType,
|
static State* StateFor(int32 objectType,
|
||||||
rgb_color color,
|
rgb_color color,
|
||||||
@ -41,12 +45,26 @@ class State {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
BRect _ValidRect() const;
|
BRect _ValidRect() const;
|
||||||
|
void _RenderDot(BView* view, BPoint where) const;
|
||||||
|
void _AdjustViewState(BView* view) const;
|
||||||
|
|
||||||
|
bool _HitTest(BPoint where, BPoint point) const;
|
||||||
|
|
||||||
bool fValid;
|
bool fValid;
|
||||||
|
|
||||||
bool fTracking;
|
bool fEditing;
|
||||||
BPoint fTrackingStart;
|
|
||||||
BPoint fLastMousePos;
|
enum {
|
||||||
|
TRACKING_NONE = 0,
|
||||||
|
TRACKING_START,
|
||||||
|
TRACKING_END
|
||||||
|
};
|
||||||
|
|
||||||
|
uint32 fTracking;
|
||||||
|
BPoint fClickOffset;
|
||||||
|
|
||||||
|
BPoint fStartPoint;
|
||||||
|
BPoint fEndPoint;
|
||||||
|
|
||||||
rgb_color fColor;
|
rgb_color fColor;
|
||||||
bool fFill;
|
bool fFill;
|
||||||
|
@ -4,4 +4,5 @@
|
|||||||
sleep 1s
|
sleep 1s
|
||||||
../../../../../distro/x86.R1/beos/system/servers/obos_registrar &
|
../../../../../distro/x86.R1/beos/system/servers/obos_registrar &
|
||||||
sleep 1s
|
sleep 1s
|
||||||
|
#../../../../../distro/x86.R1/beos/apps/MiniTerminal
|
||||||
../../../../../distro/x86.R1/beos/apps/Playground
|
../../../../../distro/x86.R1/beos/apps/Playground
|
||||||
|
Loading…
Reference in New Issue
Block a user