Difference between revisions of "Layout Containers"

From CEGUI Wiki - Crazy Eddie's GUI System (Open Source)
Jump to: navigation, search
m (Bot: Automated text replacement (-<code>[:space:]?<cpp/>(.*?)</code> +<syntaxhighlight lang="cpp">\1</syntaxhighlight>))
m (Lets use <source> instead of <syntaxhighlight>, it is much less typo-prone)
Line 11: Line 11:
  
 
Code sample:
 
Code sample:
<syntaxhighlight lang="cpp">
+
<source lang="cpp">
 
CEGUI::VerticalLayoutContainer* layout = static_cast<CEGUI::VerticalLayoutContainer*>(CEGUI::WindowManager::getSingleton().createWindow("VerticalLayoutContainer"));
 
CEGUI::VerticalLayoutContainer* layout = static_cast<CEGUI::VerticalLayoutContainer*>(CEGUI::WindowManager::getSingleton().createWindow("VerticalLayoutContainer"));
  
Line 19: Line 19:
  
 
parentWindow->addChildWindow(layout);
 
parentWindow->addChildWindow(layout);
</syntaxhighlight>
+
</source>
  
 
=== Horizontal Layout Container ===
 
=== Horizontal Layout Container ===

Revision as of 11:21, 28 February 2011

Written for CEGUI 0.7


Works with versions 0.7.x (obsolete)

Requires at least version
0.7.2

This introduces the concept of widgets that automatically layout their child widgets. Without these layout containers, doing dynamic complex UI was really hard and you had to do a lot of custom code.

Basic concepts

Layout containers are simply widgets that have no visuals to them, they don't render anything, they also usually don't react to any input (this isn't really required but the 3 existing stock layout containers don't react to input themselves). They simply just set their child windows positions in a certain way (depending on the container). When child windows are resized, added or removed, the layout containers relayouts them to match the arrangement.

Inbuilt layout containers

Vertical Layout Container

Arranges child windows one after each other vertically.

Code sample:

CEGUI::VerticalLayoutContainer* layout = static_cast<CEGUI::VerticalLayoutContainer*>(CEGUI::WindowManager::getSingleton().createWindow("VerticalLayoutContainer"));
 
// add windows to the layout
layout->addChildWindow(wnd1);
layout->addChildWIndow(wnd2);
 
parentWindow->addChildWindow(layout);

Horizontal Layout Container

Arranges child windows one after each other horizontally.

Horizontal layout container is used exactly the same as vertical layout container.

Grid Layout Container

Arranges child windows into a grid. You have to set grid dimensions before you add any windows to the container.