bWidgets
Core widget toolkit designed for Blender
|
Helper class to construct screen-graphs. More...
#include <Builder.h>
Public Types | |
template<typename _BuilderType = Builder> | |
using | BuildFunc = std::function< void(_BuilderType &)> |
A callable type to build a layout. More... | |
Public Member Functions | |
Builder (LayoutNode &active_layout_node) | |
Builder (ScreenGraph &screen_graph) | |
virtual | ~Builder ()=default |
void | setActiveLayout (bwScreenGraph::LayoutNode &) |
Activate a layout node. More... | |
template<typename _LayoutType , typename... _Args> | |
auto | addLayout (_Args &&... __args) -> LayoutNode & |
Add and activate a child node for a layout created in-place. More... | |
template<typename _LayoutType , typename... _Args> | |
auto | buildLayout (BuildFunc<> build_func, _Args &&... __args) -> LayoutNode & |
Build a sub-layout node in-place using build_func. More... | |
template<typename _LayoutType , typename _BuilderType , typename... _Args> | |
auto | buildLayout (BuildFunc< _BuilderType > build_func, _Args &&... __args) -> LayoutNode & |
Build a sub-layout node in-place using build_func. More... | |
template<typename _WidgetType , typename... _Args> | |
auto | addWidget (_Args &&... __args) -> _WidgetType & |
template<typename _WidgetType , typename... _Args> | |
auto | addContainer (std::unique_ptr< bwLayoutInterface > layout, _Args &&... __args) -> ContainerNode & |
template<typename _WidgetType , typename... _Args> | |
auto | buildContainer (BuildFunc<> build_func, std::unique_ptr< bwLayoutInterface > layout, _Args &&... __args) -> ContainerNode & |
Build a container node in-place using build_func. More... | |
template<typename _WidgetType , typename _BuilderType , typename... _Args> | |
auto | buildContainer (BuildFunc< _BuilderType > build_func, std::unique_ptr< bwLayoutInterface > layout, _Args &&... __args) -> ContainerNode & |
Build a container node in-place using build_func. More... | |
Static Public Member Functions | |
static void | setLayout (LayoutNode &node, std::unique_ptr< bwLayoutInterface > layout) |
static void | setWidget (WidgetNode &node, std::unique_ptr< bwWidget > widget) |
static auto | addWidget (LayoutNode &node, std::unique_ptr< bwWidget > widget) -> bwWidget & |
template<typename _WidgetType , typename... _Args> | |
static auto | emplaceWidget (LayoutNode &node, _Args &&... __args) -> _WidgetType & |
Add child node for a widget created in-place. More... | |
Helper class to construct screen-graphs.
Use this to create all screen-graphs or sub-trees.
addFoo
functions add a node and constructs its item (widget or layout) in-place. That means arguments are passed to the function are forwarded to the widget or layout constructor.buildFoo
functions do the same but allow specifying a build-function for sub-layouts. This is the prefered way to construct sub-layouts, because the builder manages all state. For the caller it's a stateless way to build. using bWidgets::bwScreenGraph::Builder::BuildFunc = std::function<void(_BuilderType&)> |
A callable type to build a layout.
buildFoo
functions use this to receive a callback for building their sub-layout. Can bind to a plain old function pointer, a function object (functor) or a lambda.
bWidgets::bwScreenGraph::Builder::Builder | ( | LayoutNode & | active_layout_node | ) |
bWidgets::bwScreenGraph::Builder::Builder | ( | ScreenGraph & | screen_graph | ) |
|
virtualdefault |
|
inline |
|
inline |
Add and activate a child node for a layout created in-place.
|
inline |
|
static |
|
inline |
Build a container node in-place using build_func.
This override passes a custom builder type to the build_func (must inherit from Builder).
Only creates widget in-place, layout still needs to be created by the caller. Otherwise, we'd have to do perfect forwarding of parameters to multiple constructors. This can be done (e.g. see https://cpptruths.blogspot.com/2012/06/perfect-forwarding-of-parameter-groups.html) but in the end, just letting the caller create the layout is less verbose and easier to understand.
build_func | Callback to create the subtree for this container. |
|
inline |
Build a container node in-place using build_func.
This override passes the default builder type (Builder) to the build_func.
|
inline |
Build a sub-layout node in-place using build_func.
This override passes a custom builder type to the build_func (must inherit from Builder).
|
inline |
Build a sub-layout node in-place using build_func.
This override passes the default builder type (Builder) to the build_func.
|
inlinestatic |
Add child node for a widget created in-place.
Simplifies creating and appending widgets. The arguments __args are forwarded to the widget constructor; a new node for it is added as child to node.
Without emplaceWidget()
:
With emplaceWidget()
:
void bWidgets::bwScreenGraph::Builder::setActiveLayout | ( | bwScreenGraph::LayoutNode & | node | ) |
Activate a layout node.
Adding further items will add them as children to this node, until a different layout node is activated.
|
static |
|
static |