[Cuis] Newbie question

Ken.Dickey Ken.Dickey at whidbey.com
Tue May 12 16:52:01 CDT 2015


On Tue, 12 May 2015 00:24:06 -0400
Hari Balaraman <hbalaraman at gmail.com> wrote:

> Hi Juan et al,
> 
> I’ve been pondering on how to position and size morphs (based on Juan's comment below about automatic layout in an earlier exchange) without having an intermediate layer of layoutMorphs. 
> 
> Attached is a fileout of a test class with a class method “example 1” showing a rectangle that varies its size based on its owner (I’m also writing the method to reset the location of a morph if it wishes to be remain in the same location relative to the midpoints of two sides of the enclosing morph.)
> 
> This way a morph can be positioned and at any time sent a message to relocate or resize itself based on its then owner. That way there are only two actors, the morph and its owner, and a morph knows (based on two messages, whether it should maintain its relative place and size within its owner. Although I have got a bit of the hang of layoutMorphs, I’m exploring whether positioning and repositioning a lot of elements in my UI may be easier with this approach.
> 
> I was wondering what you think of this approach.

Hari,

I think we all need to get more experience building things to see what works and is as simple as we can make it.

Please continue to build things and share them!

Here is the example using aLayoutMorpk and a LayoutSpec.

example2
"
    self example2.
"	| f g |
	g := LayoutMorph initializedInstance openInWorld.
	g padding: 0.5. "center"
	f := RectangleLikeMorph new.
	g morphExtent:400 at 400; color: Color orange.
	g addMorph: f layoutSpec: (LayoutSpec proportionalWidth: 0.25 proportionalHeight: 0.25).
 	f morphPosition:150 at 150; color: Color blue.
	g morphPosition:70 at 70.


Cheers,
-KenD




More information about the Cuis mailing list