I have added the translating shape in the core of Roassal. Let see how it evolves.
You can now specific a one-arg block as an offset. This solves the problem you
experienced.
Regarding the mouse events, you are absolutely right. I will try to fix this today.
Cheers,
Alexandre
On Sep 16, 2012, at 3:17 AM, Ben Coman <btc(a)openInWorld.com> wrote:
Thanks for looking at this Alexandre. That is an
interesting approach. I had been considering that each shape might just store an offset
internally that cold be set.
Attached is "ShapeTranslation-20120916a-bencoman.st" containing some simple use
cases for ROTranslatingShape
as well as "ROTranslatingShape-usecases.png" containing compiled screenshots.
Having worked through those use cases, it seems that how the offset shapes affect the
element extent needs to be considered - particular in relation to mouse events. For
example, if an element is made up of two shapes at opposite corners, then the blank space
at the other two corners remains selectable to drag the element, which might not be quite
right. So as wild and uninformed speculation... I wonder if rather than the element
registering for events, the individual shapes might register for events and forward them
on to the element for processing.
cheers -ben
Alexandre Bergel wrote:
Hi Ben!
...where the two labels overlap. I think you
would gain a lot if you could do something like the following...
n1 := ROElement spriteOn: 'XX___'.
n1 + (shape1 := ROLabel new text: #model).
n1 + (ROLabel new text: #bounds; offset: [ shape1 bottomLeftCorner ] ).
rawView add: n1.
I have improved the way shapes are drawn. If you update, you can then create the
following class:
-=-=-=-=-=-=-=-=-=-=-=-=
ROShape subclass: #ROTranslatingShape
instanceVariableNames: 'offset'
initialize
super initialize.
offset := 0 @ 0
chainedDrawOn: aCanvas for: aROElement
aROElement translateBy: offset negated.
super chainedDrawOn: aCanvas for: aROElement.
aROElement translateBy: offset.
offset: aPoint
offset := aPoint
-=-=-=-=-=-=-=-=-=-=-=-=
I've attached the .cs for convenience.
You can then do the following:
el := ROElement new + ROBorder + (ROTranslatingShape new offset: 20 @ 20) + ROBox .
el extent: 50 @ 50.
el @ RODraggable.
rawView add: el.
<Mail Attachment.png>
Without the translation, you have
el := ROElement new + ROBorder + ROBox .
el extent: 50 @ 50.
el @ RODraggable @ ROPopup.
rawView add: el.
<Mail Attachment.png>
I haven't included ROTranslatingShape in Roassal. I first would like to see use cases
of it.
Let me know how it goes.
Cheers,
Alexandre
> Alexandre Bergel wrote:
>
>
>> Hi Ben,
>>
>> Currently no. We definitely need a better way to specific layouts and their
composition. However this will take time before we have this.
>>
>> How would you like to specific the layout?
>>
>> Cheers,
>> Alexandre
>>
>>
>> On Aug 30, 2012, at 6:10 PM, Ben Coman
>>
>> <btc(a)openInWorld.com>
>>
>> wrote:
>>
>>
>>
>>
>>
>>> I have been looking at the ROExample "Nesting" examples and
expanded #nesting2 with another level as shown in the code below, such that there is the
outer view, middle "#1" nodes and inner "#2" nodes. However the
initial state of this has much of the middle node1 and inner node2 nodes overlapping.
>>> How can these be made for the circle layout to leave spacing between the
middle node1 nodes?
>>>
>>> cheers -ben
>>>
>>> --------------------
>>> | view nodes1 |
>>> view := ROView new.
>>> view add: (ROElement sprite addAll: (nodes1 := ROElement spritesOn: (1 to:
10))).
>>> nodes1 do: [:n | n addShape: ROLabel].
>>> nodes1 do:
>>> [ :node1 |
>>> ( (node1 model) *100+1 to: (node1 model)*100+5 ) do:
>>> [ :x |
>>> node1 add: ( (ROElement spriteOn: x) addShape: ROLabel).
>>> ].
>>> ROGridLayout on: node1 elements.
>>> ].
>>>
>>> ROCircleLayout on: nodes1.
>>> view openInWindow.
>>> _______________________________________________
>>>
>>>
<ROTranslatingShape-usecases.png>ROShape subclass: #ROTranslatingShape
instanceVariableNames: 'offset'
classVariableNames: ''
poolDictionaries: ''
category: 'RoassalTest'!
!ROTranslatingShape methodsFor: 'rendering' stamp: 'BenComan 9/16/2012
13:35'!
chainedDrawOn: aCanvas for: aROElement
aROElement translateBy: self offset negated.
super chainedDrawOn: aCanvas for: aROElement.
aROElement translateBy: self offset.
! !
!ROTranslatingShape methodsFor: 'initialize' stamp: 'AlexandreBergel
9/15/2012 09:51'!
initialize
super initialize.
offset := 0 @ 0! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
11:24'!
offset
^ offset value! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
11:24'!
offset: aBlockReturningPoint
offset := aBlockReturningPoint! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
12:35'!
usecase1
"
self new usecase1
"
"
More showing how it operates than a use case. Showing that all shapes to the right of
ROTranslatingShape are shifted.
However cannot drag element using the point just below top border.
"
| rawView el |
rawView := ROView new.
el := ROElement new + ROBorder + (ROTranslatingShape new offset: 20 @ 20) + (ROCircle
color: Color blue) + (ROBox) .
el extent: 50 @ 50.
el @ RODraggable.
rawView add: el.
rawView open! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
13:19'!
usecase2
"
self new usecase2
"
"
At the moment, the prime need for offset capability is showing the parent label above
child elements.
It is good that when dragging a child element upwards the label also moves up.
However the dragging of elements is offset, eg the point just above bottom border does
not drag the element.
Note the ROBorder that is commented out. Not critical, but it would be good to put
border around the ROLabel where it sits above the ROChildrenContainer, except without the
bottom of it cutting across child container.
Might be useful to be able to re-use that Shape>>draw:For: methods with a custom
bounds rather than getting it from the element.
"
| rawView outer outerLabel |
rawView := ROView new.
outer := (ROElement on: 'Child nodes should not overlap this heading text') +
ROBorder + (ROTranslatingShape new offset: 0 @ -20) + ROLabel "+ ROBorder".
1 to: 6 do:
[ :n |
outer add: (ROElement spriteOn: n).
].
outer extent: 50 @ 50.
outer @ RODraggable.
rawView add: outer.
ROGridLayout new applyOn: outer elements.
rawView open! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
13:27'!
usecase3
"
self new usecase3
"
"
Also later may want to put put labels below the child element area.
"
| view outer outerLabel |
view := ROView new.
outer := (ROElement on: 'Child nodes should not overlap this HEADER text. Try menu on
view background.').
outerLabel := ROLabel new.
outer + ROBorder + (ROTranslatingShape new offset: [ 0 @ (outerLabel heightFor: outer)
negated ] ) + (ROLabel new text: [ :el | el model asString]) .
1 to: 2 do:
[ :n |
outer add: (ROElement spriteOn: n).
].
outer extent: 50 @ 50.
outer @ RODraggable.
view add: outer.
view @ (ROMenuActivable new item: 'Change text' action: [
outer model: 'Child nodes should not overlap this HEADER text
even when
it dynamically changes
to multiple lines'.
outer signalUpdate] ).
ROVerticalLineLayout new applyOn: outer elements.
view open.! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
13:27'!
usecase4
"
self new usecase4
"
"
Dragging elements 1 & 2 upwards moves doesn't overlap labels with outer label -
good.
However inital layout has element 2 label overlapped by bottoms of element 1.
"
| view outer outerLabel |
view := ROView new.
outer := (ROElement on: 'Child nodes should not overlap this HEADER text').
outerLabel := ROLabel new.
outer + ROBorder + (ROTranslatingShape new offset: [ 0 @ (outerLabel heightFor: outer)
negated ] ) + (ROLabel new text: [ :el | el model asString]) .
1 to: 2 do:
[ :n | | el |
el := (ROElement spriteOn: n).
el + (ROTranslatingShape new offset: [ 0 @ (ROLabel new heightFor: el) negated ] ) +
(ROLabel new text: [ :el3 | el3 model asString, ' should not be overlapped' ]).
outer add: el.
1 to: 2 do:
[ :n2 | | el2 |
el2 := (ROElement spriteOn: n*n2).
el add: el2.
].
ROHorizontalLineLayout new applyOn: el elements.
].
outer extent: 50 @ 50.
outer @ RODraggable.
view add: outer.
view @ (ROMenuActivable new item: 'Change text' action: [
outer model: outer model, '
even when
it dynamically changes
to multiple lines'.
outer signalUpdate] ).
ROVerticalLineLayout new applyOn: outer elements.
view open.! !
!ROTranslatingShape methodsFor: 'accessing' stamp: 'BenComan 9/16/2012
13:37'!
usecase5
"
self new usecase5
"
"
Maybe later want to put labels below the child element area.
Probably want to reference 'ROChildrenShape>>extent' rather than
'outer extent' since other shaps translations may alter the extent of the
element.
This doesn't opearte as expected, which should be to have three elements laid out in
the column
"
| view outer outerLabel |
view := ROView new.
outer := (ROElement on: 'Child nodes should not overlap this FOOTER text, even when
nodes are added - see menu. ').
outerLabel := ROLabel new.
outer + ROBorder + (ROTranslatingShape new offset: [ 0 @ (outer extent y) ] ) + (ROLabel
new text: [ :el | el model asString]) .
1 to: 2 do:
[ :n |
outer add: (ROElement spriteOn: n) + ROLabel.
].
outer extent: 50 @ 50.
outer @ RODraggable.
view add: outer.
view @ (ROMenuActivable new item: 'Add node' action:
[ outer add: (ROElement spriteOn: 'extra') + ROBorder + ROLabel.
ROVerticalLineLayout new applyOn: outer elements.
outer signalUpdate
] ).
ROVerticalLineLayout new applyOn: outer elements.
view open.! !
_______________________________________________
Moose-dev mailing list
Moose-dev(a)iam.unibe.ch
https://www.iam.unibe.ch/mailman/listinfo/moose-dev
--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel
http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.