class ffw::GuiLayout
Class List > ffw :: GuiLayout
Create a linear layout widget. More...
Inherits the following classes: ffw::GuiWidget
Inherited by the following classes: ffw::GuiBody, ffw::GuiFixedLayout, ffw::GuiHorizontalLayout, ffw::GuiTabs::Content, ffw::GuiTabs::TopBar, ffw::GuiVerticalLayout
Classes
Type | Name |
---|---|
struct | Style |
Public Functions
Type | Name |
---|---|
GuiLayout (GuiWindow * context, GuiOrientation orientation) | |
virtual | ~GuiLayout () |
GuiWidget * | addWidget (GuiWidget * widget) |
GuiWidget * | addWidgetAfter (const GuiWidget * previous, GuiWidget * widget) |
GuiWidget * | addWidgetBefore (const GuiWidget * next, GuiWidget * widget) |
void | deleteWidgets () |
bool | deleteSingleWidget (const GuiWidget * widget) |
void | setOrientation (GuiOrientation orient) |
virtual ffw::Pointf | getMinimumWrapSize () override |
void | setStyle (const GuiLayout::Style * style, bool defaults = false) |
Detailed Description
This widget is able to hold any number of child widgets. The widgets will be displayed in the order inserted via addWidget() method. Based on the orientation, the widgets will be ordered vertically or horizontally. It is possible to order the widgets with a fixed [X, Y] position by using ffw::GuiOrientation::FIXED and setting position for each inserted child via setPos() method. If the available area is not big enough to contain all widgets, they will be cut off. However, you can force wrapping the widgets (for example adding 4 widgets with width of 50% will create two rows) by calling setWrap(true)
auto gui = ffw::GuiWindowNanoVG(nvg);
auto root = gui.getLayout();
// Create two columns with 47.5% width each and 5% margin between...
auto left = new ffw::GuiLayout(&gui, ffw::GuiOrientation::VERTICAL);
left->setSize(ffw::guiPercent(47.5f), ffw::guiPercent(100.0));
left->setMarginRight(ffw::guiPercent(2.5f)); // 2.5% margin on right
auto right = new ffw::GuiLayout(&gui, ffw::GuiOrientation::VERTICAL);
right->setSize(ffw::guiPercent(47.5f), ffw::guiPercent(100.0));
right->setMarginLeft(ffw::guiPercent(2.5f)); // 2.5% margin on left
auto button1 = new ffw::GuiButton(&gui, "I am on the left!");
left->addWidget(button1);
auto button2 = new ffw::GuiButton(&gui, "I am on the right!");
right->addWidget(button2);
root->setOrientation(ffw::GuiOrientation::HORIZONTAL);
root->addWidget(left);
root->addWidget(right);
// Do not free the created widgets! They will be deleted by the gui window!
while(true){
// Render the gui
}
Bug:
Sometimes when layout changes its size by adding new widgets programatically, it will not properly redraw, and some artifacts may appear. To fix this, simply call redraw() function on the parent widget.
Public Functions Documentation
function GuiLayout
ffw::GuiLayout::GuiLayout (
GuiWindow * context,
GuiOrientation orientation
)
function ~GuiLayout
virtual ffw::GuiLayout::~GuiLayout ()
function addWidget
GuiWidget * ffw::GuiLayout::addWidget (
GuiWidget * widget
)
function addWidgetAfter
GuiWidget * ffw::GuiLayout::addWidgetAfter (
const GuiWidget * previous,
GuiWidget * widget
)
function addWidgetBefore
GuiWidget * ffw::GuiLayout::addWidgetBefore (
const GuiWidget * next,
GuiWidget * widget
)
function deleteWidgets
void ffw::GuiLayout::deleteWidgets ()
function deleteSingleWidget
bool ffw::GuiLayout::deleteSingleWidget (
const GuiWidget * widget
)
function setOrientation
void ffw::GuiLayout::setOrientation (
GuiOrientation orient
)
function getMinimumWrapSize
virtual ffw::Pointf ffw::GuiLayout::getMinimumWrapSize ()
Implements GuiWidget::getMinimumWrapSize
function setStyle
void ffw::GuiLayout::setStyle (
const GuiLayout::Style * style,
bool defaults = false
)
The documentation for this class was generated from the following file: include/ffw/gui/guilayout.h