Opened 13 years ago

Last modified 12 years ago

#2955 closed task

layout(), resize(), onResized() refactor — at Version 1

Reported by: bill Owned by: koranteng
Priority: high Milestone: 0.9beta
Component: Dijit Version: 0.9
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

Concerning sizing:

There are two categories of widgets: children, and top level. Child widgets (ex: a split container inside a tabcontainer) get their size set by the parent widget. Top level widgets need to monitor when their size changes because (for example) the window has changed size.

The onResized() call from 0.4 is inefficient because it tells each widget "your size changed" without telling it what the new size is; widgets should be changed to implement and call resize({w: 500, h: 500}) which sets the margin box of the widget. There should be no onResized() method. Maybe we can also get rid of all the calls to getContentBox(), since the margin box size is passed to resize().

This brings up the problem with layout() and resize(). After all widgets are created, layout() is called on each widget, to let it "hook up" to other widgets such as it's parent/children/widgets it references. The problem is that, given a parent and child widget, parent.layout() wants to size itself and then call child.resize(), but that's not really valid until after child.layout() is called. Have to rethink the lifecycle.

  1. Change dijit.base.Layout.layoutChildren() to take coordinates (l,t,w,h) about box into which to place children.
  1. Modify all widgets to have resize() method rather than onResized() method
  1. Rename Widget.layout() to startup(), to match method name in dijit.Sizable
  1. In the past we've seen that setMarginBox() followed by getContentBox() can fail (return NaN or 0), due to race conditions or if some things are hidden. Maybe we can work around it w/code like:
	setMarginGetContent: function(node, mb){
		dojo.marginBox(node, mb);
		var cs = dojo.getComputedStyle(node);
		var me=dojo._getMarginExtents(node, cs);
		var pb=dojo._getPadBounds(node, cs);
		return { l: pb.l, t: pb.t, w: mb.w - me.w - pb.w, h: mb.h - me.h - pb.h };
	}

Change History (1)

comment:1 Changed 13 years ago by bill

Description: modified (diff)
Note: See TracTickets for help on using tickets.