ALayout#
Base class for all layout managers.
| Header: | #include <AUI/Layout/ALayout.h> |
| CMake: | aui_link(my_target PUBLIC aui::views) |
Public Methods#
addView#
Attaches view to the layout.
- Arguments
See ABasicLayout for basic implementation of this method.
Examples:
examples/app/minesweeper/src/MinesweeperWindow.cpp
Minesweeper Game — Minesweeper game implementation driven by ass.
examples/ui/views/src/ExampleWindow.cpp
Views Example — All-in-one views building example.
using namespace declarative;
void fillWindow(_<AViewContainer> t) {
t->setLayout(std::make_unique<AStackedLayout>());
t->addView(_new<ALabel>("Window contents"));
}
class AllViewsWindow : public AWindow {
public:
AllViewsWindow() : AWindow("All views", 300_dp, 500_dp, nullptr, WindowStyle::MODAL) {
computeMinMaxAxis#
Returns min/max preferred inline (width) size of the layout for a given block (height).
- Arguments
heightContent height in px, or -1 for unconstrained.- Returns
- `AMinMaxAxis` with `min` and `max` outer widths.
Wraps onComputeIntrinsicMinMaxAxis and applies padding, ass::FixedSize, ass::MinSize, ass::MaxSize.
Result is cached; invalidated by requestLayout().
Do not override this method — override onComputeIntrinsicMinMaxAxis instead.
See Measurement pipeline in detail for the full pipeline.
getAllViews#
Visits all views in the layout.
layout#
Applies geometry to children.
- Arguments
xx coordinate in container's coordinate space, add padding if necessary.yy coordinate in container's coordinate space, add padding if necessary.widthwidth of the container, add padding if necessary.heightheight of the container, add padding if necessary.
See layout-managers for more info.
measure#
glm::ivec2 ALayout::measure(AConstraints constraints)
Returns the preferred outer size of the layout under given constraints.
- Arguments
constraintsConstraints describing the available space (see `AConstraints`).- Returns
- Preferred outer `{width, height}` in px.
Wraps onIntrinsicMeasure and applies padding, ass::FixedSize, ass::MinSize, ass::MaxSize.
Result is cached per AConstraints key; invalidated by requestLayout().
Do not override this method — override onIntrinsicMeasure instead.
See Measurement pipeline in detail for the full pipeline.
onComputeIntrinsicMinMaxAxis#
Computes the min/max preferred content inline (width) size for a given content height.
- Arguments
heightContent height in px, or -1 for unconstrained.- Returns
- `AMinMaxAxis` with `min` and `max` content widths.
Override this in a layout manager to report the range of widths the managed children need.
The public computeMinMaxAxis wraps this method and handles padding, ass::FixedSize, etc.
automatically — never call onComputeIntrinsicMinMaxAxis directly.
See Measurement pipeline in detail for the full pipeline.
onIntrinsicMeasure#
virtual glm::ivec2 ALayout::onIntrinsicMeasure(AConstraints constraints)
Computes the preferred content size under given constraints.
- Arguments
constraintsConstraints describing the available **content** space (padding already subtracted).- Returns
- Preferred content `{width, height}` in px.
Override this in a layout manager to report how much space the managed children need.
The public measure wraps this method and handles padding, ass::FixedSize, ass::MinSize, ass::MaxSize
automatically — never call onIntrinsicMeasure directly.
The default implementation delegates to onComputeIntrinsicMinMaxAxis and clamps to constraints.
See Measurement pipeline in detail for the full pipeline.
Examples:
examples/app/game_of_life/src/main.cpp
Game of Life — Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.
(*mCells)[position] = !(*mCells)[position];
updateTexture();
}
glm::ivec2 onIntrinsicMeasure(AConstraints constraints) override {
return mCells->size() * int(SCALE);
}
private:
_<Cells> mCells;
removeView#
Detaches view from the layout.
- Arguments
See ABasicLayout for basic implementation of this method.
requestLayout#
Invalidates cached measurement results, triggering a layout recalculation.
Call this whenever the layout manager's content changes in a way that may affect sizes (e.g. a child was
added/removed, spacing changed). Clears mMeasureCache and mMinMaxSizesCache and propagates the
invalidation up the view tree so that all ancestor containers re-measure themselves.
This is the direct replacement for the old markMinContentSizeInvalid() from the Qt-style layout system.
The two are equivalent — requestLayout() additionally invalidates both measure caches introduced by
the new Measurement pipeline in detail.
Note
You rarely need to call this manually. It is called automatically when ASS properties change,
when a view is resized, or when addView/removeView is called. Override this in a custom layout
manager only if you maintain extra internal caches that also need clearing.
setSpacing#
Layout spacing.
- Arguments
spacingspacing in px.