Showing posts with label layout. Show all posts
Showing posts with label layout. Show all posts

Saturday, July 16, 2011

More Concise and More Powerful

Over a year ago I posted about the focus of Sgine to be extremely concise in creating 3d applications. I've always found it annoying that the barrier to entry writing 3d applications of any sort if overly complicated. I started Sgine with the belief that an engine could be created that abstracts without reducing the power of the system. Scala has been instrumental in making this possible.

Now, the point of this post is to announce that I'm finally back to the UI abstraction layer again. After nearly a year of re-architecting and adding new foundational concepts I'm finally back to the high-level abstraction that is the magic of Sgine.

In the post I mentioned above I was showing off just how concisely you can display an image in Sgine:

package org.sgine.ui

import org.sgine.core.Resource

import org.sgine.render.StandardDisplay

object TestImage extends StandardDisplay {
 def setup() = {
  val component = new Image(Resource("puppies.jpg"))
  scene += component
 }
}

My goal in this re-write was to keep at least as concise as 0.1 and hopefully achieve something even better. I do believe I have accomplished something even more concise in the current iteration of development with only a single line of logic to display an image on the screen:

package org.sgine.ui

object ImageTest extends UI {
  this += Image("sgine.png")
}

There may be some slight revisions to this (ex. I'm considering extracting the base container out into a variable name "container" instead of mixing it into UI), but I honestly don't see any way I can make it any more concise than that. :)

For those of you that love pictures, here's the screenshot of what's displayed:



There hasn't been a lot of chatter on here lately, but now that I'm back on the UI abstraction layer there will be a lot more to see, so check back often.

Wednesday, June 16, 2010

Layout Management

For any UI application layout management is an absolute essential. In 3D game development I have yet to see any sort of layout management and though I can think of a few uses they are pretty few and far between. However, with the goals of Sgine to provide both a 3D UI as well as a full scenegraph infrastructure layout management is a very important thing.

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].
Scala Engine for high-performance interactive applications.