In my opinion, this shape is not really a shape but more a kind of shapeBuilder and it's strange that an element still know such kind of builder.

I have the same feeling that you. It is a kind of reflexion mechanism (a bit like the #class message you can send to any object). This should not be used normally.

The roassal api is good on that point because to change the color of an element you should call "e color: aColor" and not "e shape color: aColor”.

Yes, there is the method:
RTElement(RTShapeObject)>>color: aColor 
^ trachelShape color: aColor


However it can be disturbing because what Leo wrote seems correct.

What is the reason to keep the RTShape in each RTElement?

It may append that you want to “refresh” the element, from its shape. I have seen couple of case like that.

Alexandre




2014-07-03 0:06 GMT+02:00 Leo Perard <leo.perard@gmail.com>:
I understand that a shape is shared by elements but what I do not is why ?

For example

shape := RTBox new color: Color red.
els := shape elementsOn: (1 to: 10).

els do: [ :e | 
e on: TRMouseLeftClick do: [ :event | e shape color: Color random. e update. view signalUpdate ].
e on: TRMouseRightClick do: [ :event | e shape borderColor: Color random. e update. view signalUpdate ]
]

In this example if I change an element with a left click its color will change so it is ok.
But after, I change the border color wiht a right click, the border will be change AND the color too. But I did not want that, just the border.

Do you see my point ? I do not understant why shape should be shared ?


On Wed, Jul 2, 2014 at 10:26 PM, Alexandre Bergel <alexandre.bergel@me.com> wrote:
Hi Leo,

Sorry to reply so late.

Your script does exactly what it is supposed to do. Maybe part of the shape semantic is not clear.

Consider this part of the script:

> e on: TRMouseClick do: [ :event |
>               e shape color: Color random. e update. els atRandom update. view signalUpdate ]

You click on an element e, which means you change the shape of the element. You update the element itself, it therefore changes its color. But with "els atRandom update” you also update another element. Since the shape is shared by all the elements, the behavior is indeed correct.

A shape is shared with all the objects. What is not shared are Trachel shapes.

You have the following relations:

shape := RTBox new size: 10.
e1 := shape elementOn: 'hello'.
e2 := shape elementOn: 'world'.

self assert: e1 shape == e2 shape.

self assert: e1 shape ~~ e1 trachelShape.
self assert: (e1 shape isKindOf: RTBox).
self assert: (e1 trachelShape isKindOf: TRBoxShape).

self assert: e1 trachelShape ~~ e2 trachelShape.

Let me know if something is not clear. I have written this in the class comment of RTShape.

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



On Jun 25, 2014, at 5:37 AM, Leo Perard <leo.perard@gmail.com> wrote:

> Hi,
>
> I'm not sure it is but I think I have found a bug where elements share the same instance of a shape.
>
> Here an example:
>
> view := RTView new.
>
> els := (RTBox new size: 20) elementsOn: (1 to: 10).
> view addAll: els.
>
> els do: [ :e |
>       e on: TRMouseClick do: [ :event |
>               e shape color: Color random. e update. els atRandom update. view signalUpdate ]
>       ].
>
> RTHorizontalLineLayout on: els.
> view open
>
> It should only change the color of one element but it doesn't.
> So I don't know if it is wanted or not.
> --
> Cheers,
> Leo Perard
> University of Lille 1
> _______________________________________________
> Moose-dev mailing list
> Moose-dev@iam.unibe.ch
> https://www.iam.unibe.ch/mailman/listinfo/moose-dev


_______________________________________________
Moose-dev mailing list
Moose-dev@iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev



--
Cheers,
Leo Perard
University of Lille 1

_______________________________________________
Moose-dev mailing list
Moose-dev@iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev




--
Guillaume Larcheveque

_______________________________________________
Moose-dev mailing list
Moose-dev@iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev