[Cuis] How to center a submorph in its owner morph?

H. Hirzel hannes.hirzel at gmail.com
Wed Jan 1 06:40:43 CST 2014


Hello

I currently encounter some problems with Morph layout and I would like
to ask for help.

The code [1]  works fine in Cuis 4.1.

A slightly adapted version (just below) in Cuis 4.1 gives the morph as
shown in file
Cuis4.1-green-LayoutMorph-with-red-BorderedMorph

| row b |
row := LayoutMorph newRow.
b := BorderedRectMorph new color: Color red.
b morphExtent: 120 at 120.
row
    color: Color green;
    addMorph: b.
row padding: #center.
row morphExtent:  200 @ 200.
row morphPosition: 150 at 130.
row openInWorld.
b inspect

However the extent of morph b is wrong. After setting it manually in
the inspector it looks as shown in picture 'Cuis4.1-green-red120.png'.
This means setting the extent works here.

In Cuis 4.2 the result of the same code looks as shown in the picture
'Cuis4.2-initial.jpeg'.

And it refuses to resize the morph b even if done manually.

Any suggestions to help to fix these bugs are welcome.

Regards
Hannes



[1]
On 2/8/13, Juan Vuletich <juan at jvuletich.org> wrote:
> Hi Hannes,
>
> Something like:
>
> | row |
> row := LayoutMorph newRow.
> row
>      color: Color green;
>      addMorph: (BorderedRectMorph new color: (Color h: 60 s: 0.6 v: 0.6)).
> row padding: #center.
> row openInWorld.
> row morphPosition: 150 at 130
>
> If you use a Column and not a Row, you don't even need to specify the
> #padding:, as it defaults to #center.
>
> Cheers,
> Juan Vuletich
>
> On 2/7/2013 12:32 PM, H. Hirzel wrote:
>> Hello
>>
>> I want to add an instance of ImageMorph to an instance of  Morph and
>> center it there?
>>
>> How do I do that?
>>
>> I have done experiments with newRow and newColumn layout, see
>>    https://github.com/hhzl/Cuis-Add-Ons
>>
>> But I do not have examples yet of centering.
>>
>> Thank you for the answer in advance.
>>
>> Hannes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cuis4.1-green-LayoutMorph-with-red-BorderedMorph
Type: application/octet-stream
Size: 976 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20140101/0264d8c2/attachment-0003.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cuis4.1-green-red120.png
Type: image/png
Size: 1052 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20140101/0264d8c2/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Cuis4.2-initial.jpeg
Type: image/jpeg
Size: 3269 bytes
Desc: not available
URL: <http://jvuletich.org/pipermail/cuis_jvuletich.org/attachments/20140101/0264d8c2/attachment-0003.jpeg>


More information about the Cuis mailing list