Proportional Layout does not work for me

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

Proportional Layout does not work for me

kmo
I was just experimenting with creating a user interface in Pharo using Morphic. I wanted to create a sub-morph that fills its parent with a 50 pixel gap at the top and a 50 pixel gap at the bottom (leaving space for a toolbar at the top and a status bar at the bottom).

This code works in pharo 3 but does not work in pharo 4 or 5:

Morph>>>initialize
|frame sub|
        super initialize.
        self layoutPolicy: ProportionalLayout new.
        frame := LayoutFrame fractions: (0.0 @ 0.0 corner: 1.0@ 1.0) offsets: (0@50 corner: 0@50 negated).
        sub := BorderedMorph new.
        sub color: Color red.
        self addMorph: sub fullFrame: frame.
        self extent:600@600.

Am I doing something wrong or is proportional layout broken?
Reply | Threaded
Open this post in threaded view
|

Re: Proportional Layout does not work for me

Thierry Goubier
Hi,

you're falling prey to the Rectangle / LayoutFrame api issue: your
offsets, when written this way, are reversed.

You need to use a different API: for example:

frame := (0 @ 0 corner: 1.0 @ 1.0) asLayoutFrame topLeftOffset: 0 @ 50;
bottomRightOffset: 0@50 negated.

Thierry

Le 09/04/2016 19:44, kmo a écrit :

> I was just experimenting with creating a user interface in Pharo using
> Morphic. I wanted to create a sub-morph that fills its parent with a 50
> pixel gap at the top and a 50 pixel gap at the bottom (leaving space for a
> toolbar at the top and a status bar at the bottom).
>
> This code works in pharo 3 but does not work in pharo 4 or 5:
>
> Morph>>>initialize
> |frame sub|
> super initialize.
> self layoutPolicy: ProportionalLayout new.
> frame := LayoutFrame fractions: (0.0 @ 0.0 corner: 1.0@ 1.0) offsets: (0@50
> corner: 0@50 negated).
> sub := BorderedMorph new.
> sub color: Color red.
> self addMorph: sub fullFrame: frame.
> self extent:600@600.
>
> Am I doing something wrong or is proportional layout broken?
>
>
>
> --
> View this message in context: http://forum.world.st/Proportional-Layout-does-not-work-for-me-tp4889237.html
> Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Proportional Layout does not work for me

Stephan Eggermont-3
In reply to this post by kmo
Rectangles can no longer have negative sizes. Use Margin

Stephan


kmo
Reply | Threaded
Open this post in threaded view
|

Re: Proportional Layout does not work for me

kmo
Thanks everybody. That' s great.