[cross-posting to gwt-contrib, because I think this will be of general interest]
There's some documentation on the overall design here: http://code.google.com/p/google-web-toolkit/wiki/LayoutDesign On Sat, Dec 19, 2009 at 11:14 PM, 牟昕(mu xin) <[email protected]> wrote: > With the release of GWT 2.0, there are some kinds of LayoutPanel. I > notice that every LayoutPanel has a 'Ruler', and a "StyleRuler' in > LayoutImplIE6. > As the lack of experiences in CSS, I couldn't understand how > LayoutPanels work, e.g., the functions of the 'Ruler', the ways > LayoutPanels know the exactly dimensions of themselves... > I didn't really address the Ruler stuff in the design doc -- it kind of evolved as I was working on it. Essentially, there are two rulers: 1. The "global" ruler, which is used for measuring physical units (cm, in, etc). 2. The "local" ruler for each panel, which is used for measuring font-relative units (em, ex). The latter rulers have to be attached to each separate panel, because the definition of these units is a function of the particular font properties that apply to it. You might ask why we even need the rulers at all. A lot of the system manages avoid asking questions like "how big is a centimeter in pixels". Specifically, this is why each child element is wrapped by a container element. The container element is known to have no decorations (i.e., margins, borders, or padding). The child element can have any arbitrary decorations, but because the CSS properties {left, top, right, bottom} are specified in terms of the element's total size including decorations, we can set the child to {left:0; top:0; right:0; bottom:0;} and it will perfectly fill its container element. The rulers become necessary when adjusting constraints for animation. If you look at Layout.adjust[Horizontal Vertical]Constraints(), you'll see where they're used (via getUnitSize()). The good news is that these methods are not called frequently, so even though they might be a little slow, it doesn't end up mattering in practice. You'll also see that they are heavily used in the IE implementation of the layout system, where we have to do a lot more manual calculation to work around IE bugs. Also, I found ScrollPanel has implemented RequiresResize and > ProvideResize, and the docs said that it work perfectly in > LayoutPanels. > Are ScrollPanels act like bridges between LayoutPanels and normal > Panels? That is, LayoutPanels deside the size of the inner > ScrollPanel, and normal Panels in ScrollPanel make ScrollPanel scroll > or not? > ScrollPanel does indeed act as sort of a "bridge" among layout panels. That's the general intention of anything that implements both ProvidesResize and RequiresResize -- they guarantee that they will propagate onResize() calls to their children. Hope that helps, joel. -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
