Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Layout
Last updated at 8:27 am UTC on 24 January 2017

How does layout work in Morphic?

Laying out usually occurs when the size or position of a Morph is changed, althought there are other possible reasons. As this happens in the event processing stage of a UI cycle, the Morphs are only marked to be relaid in the layout stage. This is done via Morph@layoutChanged.
Morph@layoutChanged

Then, in the drawing stage, WorldState@displayWorld:submorphs: calls fullBounds to each submorph.

fullBounds "CODE STRIPPED!!!"
	"Return the bounding box of the receiver and all its children. Recompute the layout if necessary."
	fullBounds ifNotNil:[^fullBounds].
	self doLayoutIn: self layoutBounds
	^fullBounds

As you can see, if the layout wasn't changed, fullBounds is not nil, so nothing happens. If it was nil,
doLayoutIn: is sent to self.

doLayoutIn: layoutBounds "CODE STRIPPED!!!"
	"Compute a new layout based on the given layout bounds."
	| layout box priorBounds |
	submorphs do: [:m | m ownerChanged].
	layout := self layoutPolicy.
	layout layout: self in: layoutBound].
	fullBounds := self privateFullBounds.


Layout types


The actual laying out can be done several ways;

see How to lay out submorphs for pointers to pages describing the various methods.