What's particularly cool about layout management in Sgine is that it's not just for UI elements and it's not just for vertical and horizontal. That's right, you can use layout managers to lay out 3D objects in 3D space.
The layout management infrastructure is now in place, but still has a long way to go to provide a full set of advanced layout techniques. For now, here's a simple example laying out two Buttons:
package org.sgine.ui import org.sgine.core.Direction import org.sgine.render.StandardDisplay import org.sgine.ui.layout.BoxLayout object TestLayout extends StandardDisplay { def setup() = { val container = new LayoutContainer() container.layout := BoxLayout(Direction.Vertical, 10) container += new Button("Test Button 1") container += new Button("Test Button 2") scene += container } }
What do you get for those five lines of logic? This:
You are not required to specify the layout as it will default to BoxLayout(Direction.Vertical, 0), but in order to show how easy configuring the layout function I decided to show a custom example. Custom layout functions can be provided that simply follow: Function1[NodeContainer, Unit].
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.