Skip to content

AViewContainerBase#

A view that represents a set of views.

Header:#include <AUI/View/AViewContainerBase.h>
CMake:aui_link(my_target PUBLIC aui::views)

Detailed Description#

AViewContainerBase can store, render, resize, provide events to and handle the child views.

AViewContainerBase does not control the position and size of the child views by itself; instead, it delegates that responsibility to it's layout manager.

Since AViewContainerBase is an instance of AView, AViewContainerBase can handle AViewContainerBases recursively, thus, making possible complex UI by nested AViewContainerBases with different layout managers.

This class is abstract. The methods for modifying it's views are protected. You can use AViewContainer which exposes these methods to public or extend AViewContainerBase to make your own container-like view.

Public Types#

PointerEventsMapping#


struct AViewContainerBase::PointerEventsMapping

Empty structure.

Public Methods#

applyGeometryToChildrenIfNecessary#


void AViewContainerBase::applyGeometryToChildrenIfNecessary()

Applies geometry to all children if needed.

See layout-managers for more info.

focusChainTarget#


_<AView> AViewContainerBase::focusChainTarget()
Returns
Focus chain target.

See mFocusChainTarget for further info.

getLayout#


const _unique<ALayout>& AViewContainerBase::getLayout()

Get layout manager of the container.

getViewAt#


virtual _<AView> AViewContainerBase::getViewAt(glm::ivec2 pos, ABitField<AViewLookupFlags> flags = AViewLookupFlags::NONE)

Finds first direct child view under position.

Arguments
pos
position relative to this container
flags
see AViewLookupFlags
Returns
found view or nullptr

Some containers may implement getViewAt by it's own (i.e. AListView for performance reasons).

getViewAtRecursive#


_<AView> AViewContainerBase::getViewAtRecursive(glm::ivec2 pos, ABitField<AViewLookupFlags> flags = AViewLookupFlags::NONE)

Acts as AViewContainerBase::getViewAt but recursively (may include non-direct child).

Arguments
pos
position relative to this container
flags
see AViewLookupFlags
Returns
found view or nullptr

template<aui::predicate<_<AView> > Callback >
bool AViewContainerBase::getViewAtRecursive(glm::ivec2 pos, const Callback& callback, ABitField<AViewLookupFlags> flags = AViewLookupFlags::NONE)

Acts as AViewContainerBase::getViewAtRecursive but calls a callback instead of returning value.

Arguments
pos
position relative to this container
callback
callback to call
flags
see AViewLookupFlags
Returns
true if callback returned true; false otherwise

The passed callback is a predicate. If predicate returns true, the execution of lookup is stopped and getViewAt returns true. If predicate returns false, the lookup continues.

getViewAtRecursiveOfType#


template<typename T >
_<T> AViewContainerBase::getViewAtRecursiveOfType(glm::ivec2 pos, ABitField<AViewLookupFlags> flags = AViewLookupFlags::NONE)

Acts as AViewContainerBase::getViewAtRecursive but finds a view castable to specified template type.

Arguments
pos
position relative to this container
flags
see AViewLookupFlags
Returns
found view or nullptr

getViews#


const AVector<_<AView>>& AViewContainerBase::getViews()

Get all views of the container.

Examples#

examples/app/minesweeper/src/MinesweeperWindow.cpp

Minesweeper Game - Minesweeper game implementation driven by ass.

        }
    }
}
void MinesweeperWindow::updateCellViewStyle(int x, int y) const {
    AUI_EMIT_FOREIGN(mGrid->getViews()[y * mFieldColumns + x], customCssPropertyChanged);
}

int MinesweeperWindow::countBombsAround(int x, int y) {
    int count = 0;
    for (int i = -1; i <= 1; ++i) {
examples/7guis/cells/src/main.cpp

7GUIs Cells - Spreadsheet processor (Excel).

                      [](const AString& v) -> _<AView> { return Label { "{}"_format(v) }; },
                      [](const formula::Range& v) -> _<AView> { return Label { "#RANGE?" }; },
                    },
                    v));
            connect(getViews().first()->clicked, me::inflateEditor);
        });
    }

    void inflateEditor() {
        mState->currentExpression = mCell.expression;

pointerEventsMapping#


const ASmallVector<PointerEventsMapping,1>& AViewContainerBase::pointerEventsMapping()

setFocusChainTarget#


void AViewContainerBase::setFocusChainTarget(_weak<AView> target)

Set focus chain target.

Arguments
target
a new focus chain view belonging to this container

See mFocusChainTarget for further info.

visitsViewRecursive#


template<aui::predicate<_<AView> > Callback >
bool AViewContainerBase::visitsViewRecursive(Callback&& callback, ABitField<AViewLookupFlags> flags = AViewLookupFlags::NONE)

Performs recursive view traversal.

Arguments
callback
callback to call. Returns true to finish traversal.
flags
see AViewLookupFlags
Returns
true if there's at least one view for which callback returned true, false otherwise.