Excellent!

It would be great to build on this.

Cheers,
Doru




On Sat, Dec 28, 2013 at 12:51 PM, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Just to share a 10 min coding session, just before lunch.

Result here:
https://www.facebook.com/photo.php?fbid=564129843673617&set=a.341189379300999.82969.340543479365589&type=1&theater

code:
-=-=-=-=-=-=-=-=
| view stack selected statusBar |
stack := ROViewStack new.
view := ROView new.
selected := nil.
statusBar := nil.

view on: ROMouseClick do: [ :evt |
        selected == #line ifTrue: [
                | ex1 ex2 line |
                ex1 := (ROBox new size: 10; color: (Color purple alpha: 0.2)) element.
                ex2 := (ROBox new size: 10; color: (Color purple alpha: 0.2)) element.
                ex1 translateTo: evt position.
                ex2 translateTo: evt position + (100 @ 60).
                ex1 @ ROLightlyHighlightable.
                ex2 @ ROLightlyHighlightable.
                ex1 @ RODraggable.
                ex2 @ RODraggable.
                line := (ROLine new width: 3; color: (Color blue alpha: 0.2)) elementFrom: ex1 to: ex2.
                view addAll: { ex1 . ex2 . line }.
        ].

        selected == #circle ifTrue: [
                | ellipse |
                ellipse := (ROEllipse new size: 40; color: (Color yellow alpha: 0.2)) element.
                ellipse translateTo: evt position.
                ellipse @ RODraggable.
                view add: ellipse.
        ].


        selected == #rectangle ifTrue: [
                | box |
                box := (ROBox new width: 40; height: 30; color: (Color blue alpha: 0.2)) element.
                box translateTo: evt position.
                box @ RODraggable.
                view add: box.
        ].
        view signalUpdate.
].



view @ RODraggable.

stack zoomInButton; zoomOutButton.
stack addMenu: '+ line' callBack: [ :evt | selected := #line. statusBar model: 'line' ].
stack addMenu: '+ rectangle' callBack: [ :evt | selected := #rectangle. statusBar model: 'rectangle' ].
stack addMenu: '+ circle' callBack: [ :evt | selected := #circle. statusBar model: 'circle' ].
stack addMenu: 'Info' callBack: [ :evt | UIManager default inform: 'Vectorial editing is hyper cool' ].

stack addView: view.
stack title: 'Vectorial edition'.

"Status bar at the bottom of the window"
statusBar := (ROElement new) + ROLabel + ROBox white.
stack add: statusBar.
ROConstraint stickAtTheBottomOfTheWindow: statusBar.

stack open
-=-=-=-=-=-=-=-=

Cheers,
Alexandre
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.







--
www.tudorgirba.com

"Every thing has its own flow"