AUI Framework
master
Cross-platform module-based framework for developing C++20 desktop applications
|
Layout manager is an object that manages placement and size of views inside containers. More...
Layout manager is an object that manages placement and size of views inside containers.
In AUI, layout building consists of layout managers. Layout manager determines position and size of container's children views. A container is a view that consists of other views, called children. In general, layout manager does not allow going beyond the border of the container. A container can be a child of an another container i.e., nesting is allowed.
Horizontal layout:
Code | Result |
---|---|
setContents(
_new<AButton>("1"),
_new<AButton>("2"),
_new<AButton>("3"),
}
);
Definition: Declarative.h:173 |
Vertical layout:
Code | Result |
---|---|
Since container can be child of other container, we can create complex UIs using basic layout managers:
Code | Result |
---|---|
setContents(
Vertical {
_new<AButton>("Up"),
_new<AButton>("Left"),
_new<AButton>("Right"),
},
_new<AButton>("Down"),
}
);
|
Expanding (often referred as stretch factor) is a property of any AView. Expanding is an expansion coefficient set on per-axis basic (i.e, one value along x axis, another value along y axis), however it's convenient to set both values. Hints layout manager how much this AView should be extended relative to other AViews in the same container.
Horizontal layouts ignore y expanding of their children, Vertical layouts ignore x expanding of their children.
Views are normally created without any expanding set. When Expanding views appear in a layout they are given a share of space in accordance with their expanding or their minimum size whichever gives more space to them. Expanding is used to change how much space views are given in proportion to one another.
Expanding view does not affect parent's size or parent's expanding property. Use AView::setExpanding() on parent, or ::Expanding variant of declarative container notation (Vertical::Expanding, Horizontal::Expanding, Stacked::Expanding) for such case.
Expanding views use free space of their container to grow.
Free space of a container is determined by its size subtracted by sum of minimum sizes of its children. Please note that your container would probably occupy minimum possible size (determined by minimum sizes of its children). It order to make container larger than minimum possible size, you can specify FixedSize or MinSize or Expanding to the container.
You can use ass::Expanding ass rule, or AView::setExpanding method to specify Expanding:
Code | Result |
---|---|
setContents(
Vertical {
_new<AButton>("Up"),
_new<AButton>("Left"),
_new<AButton>("Center"),
_new<AButton>("Right") let { it->setExpanding(); },
// alias to it->setExpanding(2) ^^^^^^
},
_new<AButton>("Down"),
}
);
#define let Performs multiple operations on a single object without repeating its name (in place) This function c... Definition: kAUI.h:262 |
Expanding views push remaining views in their container:
Code | Result |
---|---|
Expanding view does affect expanding environment inside a single container. If there's one view with expanding set to any positive value it would occupy all free space in the container. If there is a view with expanding equal to 1 and another view with expanding equal to 2 the first view would occupy one third of free space, the second view would occupy two thirds of free space:
You can use ASpacerExpanding as blank expanding view:
Classes | |
class | AAbsoluteLayout |
Absolute positioning layout. Allows to explicitly set your own coordinates. More... | |
class | AAdvancedGridLayout |
Grid layout. Unlike AGridLayout, cells may have different sizes. More... | |
class | AGridLayout |
Grid layout with fixed-size cells. More... | |
class | AHorizontalLayout |
Places views in a row. More... | |
class | ALayout |
Base class for all layout managers. More... | |
class | AStackedLayout |
Places views in a stack (along z axis). More... | |
class | AVerticalLayout |
Places views in a column. More... | |
class | AWordWrappingLayout |
Imitates behaviour of word wrapping, but uses views instead words. More... | |