Weird Morphic layout problem

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Weird Morphic layout problem

Sean P. DeNigris
Administrator
I have MyMorph (TableLayout, h/v resizing: #shrinkWrap)
    with a submorph (TableLayout new, hResizing: #spaceFill, vResizing: #shrinkWrap)
       whose submorphs are TextMorphs (hResizing: #spaceFill)

I can't get the TextMorphs laid out properly.  I want them to fill the horizontal space of the owner morph, but be packed vertically together with no space.  However, TextMorph's with lines that wrap overlap the text of the TextMorph directly below them.

The weird thing is that everything gets laid out properly if I edit any of the TextMorphs.  I tried calling #layoutChanged on various morphs with no effect.

Thanks.
Sean

DoIt the following to see what I mean:
"aMorph := Morph new
        layoutPolicy: TableLayout new;
        layoutInset: 100;
        cellInset: 20;
        hResizing: #shrinkWrap;
        vResizing: #shrinkWrap;
        cellPositioning: #topLeft.
               
titleMorph := Morph new
        layoutPolicy: TableLayout new;
        hResizing: #spaceFill;
        cellPositioning: #topLeft.
        titleMorph addMorphBack: 'a line that the enclosing morph will shrink around' asMorph.
        aMorph addMorphBack: titleMorph.
       
listMorph := Morph new
        color: Color green;
        layoutPolicy: TableLayout new;
        hResizing: #spaceFill;
        vResizing: #shrinkWrap;
        cellPositioning: #topLeft.
        aMorph addMorphBack: listMorph.

itemMorph := TextMorph new
        hResizing: #spaceFill;
        vResizing: #shrinkWrap;
        contents: 'a line that is so long that it wraps to the next line. there is a lot of information here, so the line is long.';
        wrapFlag: true.
        listMorph addMorphBack: itemMorph.

item2Morph := TextMorph new
        hResizing: #spaceFill;
        vResizing: #shrinkWrap;
        contents: 'a short line that will get trampled';
        wrapFlag: true.
        listMorph addMorphBack: item2Morph.
       
aMorph openInWorld."
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Weird Morphic layout problem

Karl Ramberg
If you can fix this you get a star in my book ;-)
Some layout issues seem to not "register" untill the morph is opened in the world. Some issues not even then.

Karl

On Fri, Jan 7, 2011 at 2:57 AM, Sean P. DeNigris <[hidden email]> wrote:

I have MyMorph (TableLayout, h/v resizing: #shrinkWrap)
   with a submorph (TableLayout new, hResizing: #spaceFill, vResizing:
#shrinkWrap)
      whose submorphs are TextMorphs (hResizing: #spaceFill)

I can't get the TextMorphs laid out properly.  I want them to fill the
horizontal space of the owner morph, but be packed vertically together with
no space.  However, TextMorph's with lines that wrap overlap the text of the
TextMorph directly below them.

The weird thing is that everything gets laid out properly if I edit any of
the TextMorphs.  I tried calling #layoutChanged on various morphs with no
effect.

Thanks.
Sean

DoIt the following to see what I mean:
"aMorph := Morph new
       layoutPolicy: TableLayout new;
       layoutInset: 100;
       cellInset: 20;
       hResizing: #shrinkWrap;
       vResizing: #shrinkWrap;
       cellPositioning: #topLeft.

titleMorph := Morph new
       layoutPolicy: TableLayout new;
       hResizing: #spaceFill;
       cellPositioning: #topLeft.
       titleMorph addMorphBack: 'a line that the enclosing morph will shrink
around' asMorph.
       aMorph addMorphBack: titleMorph.

listMorph := Morph new
       color: Color green;
       layoutPolicy: TableLayout new;
       hResizing: #spaceFill;
       vResizing: #shrinkWrap;
       cellPositioning: #topLeft.
       aMorph addMorphBack: listMorph.

itemMorph := TextMorph new
       hResizing: #spaceFill;
       vResizing: #shrinkWrap;
       contents: 'a line that is so long that it wraps to the next line. there is
a lot of information here, so the line is long.';
       wrapFlag: true.
       listMorph addMorphBack: itemMorph.

item2Morph := TextMorph new
       hResizing: #spaceFill;
       vResizing: #shrinkWrap;
       contents: 'a short line that will get trampled';
       wrapFlag: true.
       listMorph addMorphBack: item2Morph.

aMorph openInWorld."

--
View this message in context: http://forum.world.st/Weird-Morphic-layout-problem-tp3178526p3178526.html
Sent from the Squeak - Dev mailing list archive at Nabble.com.




Reply | Threaded
Open this post in threaded view
|

Re: Weird Morphic layout problem

Sean P. DeNigris
Administrator
Karl Ramberg wrote
If you can fix this you get a star in my book ;-)
Some layout issues seem to not "register" untill the morph is opened in the
world. Some issues not even then.
Still hunting down the bug, but I came up with a quick workaround:
WorldState addDeferredUIMessage: [ aMorph layoutChanged ]

Sean
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Weird Morphic layout problem

Chris Muller-3
Hi Sean, I've had to put statements like that into one or two places
in Maui to help with layout, but even then it isn't always perfect.  I
will be very interested if you find a solution!

My perception is that Morph layout has an element of feedback; where
laying-out morphs causes other morphs to need to be laid out (hmm,
I'll just say "formatted").  I've even noticed in Maui that,
sometimes, it takes multiple World cycles for everything to be laid
out correctly.

It's extremely hard to debug since you can't use the debugger (because
pausing in the debugger doesn't stop the world's heartbeat).

Anyway, I wish you luck and I hope you;ll share what you find, I'll be
interested!

  - Chris


On Sat, Jan 8, 2011 at 9:13 PM, Sean P. DeNigris <[hidden email]> wrote:

>
>
> Karl Ramberg wrote:
>>
>> If you can fix this you get a star in my book ;-)
>> Some layout issues seem to not "register" untill the morph is opened in
>> the
>> world. Some issues not even then.
>>
>
> Still hunting down the bug, but I came up with a quick workaround:
> WorldState addDeferredUIMessage: [ aMorph layoutChanged ]
>
> Sean
> --
> View this message in context: http://forum.world.st/Weird-Morphic-layout-problem-tp3178526p3205631.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Weird Morphic layout problem

Sean P. DeNigris
Administrator
Chris Muller-3 wrote
Anyway, I wish you luck and I hope you;ll share what you find, I'll be
interested!
Still hunting, but I found out that if I:
1) set a breakpoint in Morph>>layoutInBounds: for a Morph whose submorphs are not being laid out correctly when first opened (like in the previous example in this thread)
2) set the Morph's fullBounds instVar to nil to force execution of the first block in #layoutInBounds:

Then the Morph's submorphs are laid out correctly when it opens.

I'm still not sure what this means.  I'll be in touch...

Sean
Cheers,
Sean