Hello!
I've only been Squeaking for 2 days so I've got a very elementary question about Morphic layout stuff...
Below is a code snipet which illustrates the problem.
"**************************************************" am := AlignmentMorph new. am extent: 500@500.
picopaint := PicoPaintMorph new. picopaint hResizing: #spaceFill. picopaint vResizing: #spaceFill.
am addMorphBack: picopaint. am openInWorld. "**************************************************"
The PicoPaintMorph is from the "Introduction to Morphic" article by John Maloney.
So after invoking doit, the AlignmentMorph appears and the PicoPaintMorph is inside it. However, the size of the PicoPaintMorph is still it's initial size. That is, it hasn't filled up the remaining space in the AlignmentMorph. If I activate the halo's on the AlignmentMorph and manually resize it, the PicoPaintMorph finally get's resized. How do I get it to fill the space from the very beginning so that it looks correct as soon as I send 'openInWorld' to the AlignmentMorph?
Thanks!
Ed
_________________________________________________________________ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.com/go/onm00200415ave/direct/01/
On Wednesday 24 March 2004 4:35 am, Ed Cavazos wrote:
Hello!
I've only been Squeaking for 2 days so I've got a very elementary question about Morphic layout stuff...
Below is a code snipet which illustrates the problem.
"**************************************************" am := AlignmentMorph new. am extent: 500@500.
picopaint := PicoPaintMorph new. picopaint hResizing: #spaceFill. picopaint vResizing: #spaceFill.
am addMorphBack: picopaint. am openInWorld. "**************************************************"
The PicoPaintMorph is from the "Introduction to Morphic" article by John Maloney.
So after invoking doit, the AlignmentMorph appears and the PicoPaintMorph is inside it. However, the size of the PicoPaintMorph is still it's initial size. That is, it hasn't filled up the remaining space in the AlignmentMorph. If I activate the halo's on the AlignmentMorph and manually resize it, the PicoPaintMorph finally get's resized. How do I get it to fill the space from the very beginning so that it looks correct as soon as I send 'openInWorld' to the AlignmentMorph?
As you've probably guessed, the initial layout doesn't send #extent: so your morph doesn't get resized. Instead it gets sent #bounds:.
Rather than overriding #bounds: as well, a better way to do this might be to check the form size at drawing time.
The attached version of PicoPaint does this by adding an accessor for form that checks to see if the size has been changed and copies the form if necessary.
The two direct references to the form instance variable were replaced with calls to this accessor.
ned would it make sense to have that in the image?
Stef
On 24 mars 04, at 18:16, Ned Konz wrote:
On Wednesday 24 March 2004 4:35 am, Ed Cavazos wrote:
Hello!
I've only been Squeaking for 2 days so I've got a very elementary question about Morphic layout stuff...
Below is a code snipet which illustrates the problem.
"**************************************************" am := AlignmentMorph new. am extent: 500@500.
picopaint := PicoPaintMorph new. picopaint hResizing: #spaceFill. picopaint vResizing: #spaceFill.
am addMorphBack: picopaint. am openInWorld. "**************************************************"
The PicoPaintMorph is from the "Introduction to Morphic" article by John Maloney.
So after invoking doit, the AlignmentMorph appears and the PicoPaintMorph is inside it. However, the size of the PicoPaintMorph is still it's initial size. That is, it hasn't filled up the remaining space in the AlignmentMorph. If I activate the halo's on the AlignmentMorph and manually resize it, the PicoPaintMorph finally get's resized. How do I get it to fill the space from the very beginning so that it looks correct as soon as I send 'openInWorld' to the AlignmentMorph?
As you've probably guessed, the initial layout doesn't send #extent: so your morph doesn't get resized. Instead it gets sent #bounds:.
Rather than overriding #bounds: as well, a better way to do this might be to check the form size at drawing time.
The attached version of PicoPaint does this by adding an accessor for form that checks to see if the size has been changed and copies the form if necessary.
The two direct references to the form instance variable were replaced with calls to this accessor.
-- Ned Konz http://bike-nomad.com/squeak/ <PicoPaintLazyForm-nk.1.cs>
On Wednesday 24 March 2004 11:19 am, stéphane ducasse wrote:
ned would it make sense to have that in the image?
Which "that"?
picoPaint as a good example of bounds/extent: using. I was thikning that picopaint was in the image but this is TinyPain. Another lovely morph.
Stef
On 24 mars 04, at 22:28, Ned Konz wrote:
On Wednesday 24 March 2004 11:19 am, stéphane ducasse wrote:
ned would it make sense to have that in the image?
Which "that"?
-- Ned Konz http://bike-nomad.com/squeak/
Ned Konz ned@squeakland.org wrote:
As you've probably guessed, the initial layout doesn't send #extent: so your morph doesn't get resized. Instead it gets sent #bounds:.
Rather than overriding #bounds: as well, a better way to do this might be to check the form size at drawing time.
Morph>>bounds: calls #extent:, however. It sounds like something else is going on.
Your code deals with the *form* size, not the morph size. I was about to whine about changing the size of a morph within a drawOn: method, which sounds quite unstable. How is Morphic supposed to cope, if a morph is asked to draw itself but it changes its size along the way? But the code you post is changing the *form* size, not the size of the morph. And it is using "self extent" to find the size of the form, thus suggesting that the morph is indeed getting set to the correct size.
So perhaps the morph was getting resized all along, but it just wasn't drawing in its full area?
-Lex
On Thursday 25 March 2004 12:54 pm, Lex Spoon wrote:
Morph>>bounds: calls #extent:, however. It sounds like something else is going on.
There are paths through the layout code that don't call #extent:, though, and instead just assign to bounds directly.
Your code deals with the *form* size, not the morph size. I was about to whine about changing the size of a morph within a drawOn: method, which sounds quite unstable. How is Morphic supposed to cope, if a morph is asked to draw itself but it changes its size along the way? But the code you post is changing the *form* size, not the size of the morph. And it is using "self extent" to find the size of the form, thus suggesting that the morph is indeed getting set to the correct size.
Right.
So perhaps the morph was getting resized all along, but it just wasn't drawing in its full area?
The morph was getting resized. However, #extent: was not getting called from the layout method, so the form wasn't getting resized.
Ned Konz ned@squeakland.org wrote:
Date: Thu, 25 Mar 2004 14:10:59 -0800 From: Ned Konz ned@squeakland.org Subject: Re: Getting a submorph to spaceFill To: The general-purpose Squeak developers list squeak-dev@lists.squeakfoundation.org reply-to: The general-purpose Squeak developers list squeak-dev@lists.squeakfoundation.org
On Thursday 25 March 2004 12:54 pm, Lex Spoon wrote:
Morph>>bounds: calls #extent:, however. ÊIt sounds like something else is going on.
There are paths through the layout code that don't call #extent:, though, and instead just assign to bounds directly.
Ahh, it's #layoutBounds:, not #bounds:, and layoutBounds: does indeed directly assign to bounds.
This looks like a bug. Morphs used to be able to rely on intercepting #extent:, and why should layout be any different? At the least there should be a comment here, but why not use #bounds: instead of #layoutBounds: ? And why not have #layoutBounds: fall down to #position: and #extent:, the way #bounds: does ?
-Lex
squeak-dev@lists.squeakfoundation.org