Skip to content

aui#

Promise type specialization for AFuture coroutines.

Header:#include <AUI/Thread/AFutureCpp20Coro.h>
CMake:aui_link(my_target PUBLIC aui::core)

Detailed Description#

Provides return_void (required by the coroutine standard for void-returning promises) and delegates to CoPromiseTypeBase::return_() with no arguments.

Examples#

examples/7guis/cells/CMakeLists.txt

7GUIs Cells — Spreadsheet processor (Excel).

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.cells)
aui_link(aui.example.cells PRIVATE aui::views)
aui_enable_tests(aui.example.cells)
examples/7guis/cells/src/Tokens.h

7GUIs Cells — Spreadsheet processor (Excel).

};

using Any = std::variant<Identifier, Double, Semicolon, LPar, RPar, Colon, Plus, Minus, Asterisk, Slash, LAngle, RAngle, StringLiteral>;

AVector<token::Any> parse(aui::no_escape<ATokenizer> t);

}   // namespace token
examples/7guis/cells/src/Tokens.cpp

7GUIs Cells — Spreadsheet processor (Excel).

 */

#include "Tokens.h"

AVector<token::Any> token::parse(aui::no_escape<ATokenizer> t) {
    AVector<token::Any> out;
    t->readChar();   // =
    try {
        while (!t->isEof()) {
            switch (char c = t->readChar()) {
examples/7guis/cells/src/AST.cpp

7GUIs Cells — Spreadsheet processor (Excel).

namespace {

template <typename type>
constexpr size_t got = aui::variant::index_of<token::Any, type>::value;

template <typename T, typename Variant>
const T& expect(const Variant& variant) {
    if (std::holds_alternative<T>(variant)) {
        return std::get<T>(variant);
examples/7guis/cells/src/Spreadsheet.h

7GUIs Cells — Spreadsheet processor (Excel).

            bool operator==(const RangeIterator&) const = default;
            bool operator!=(const RangeIterator&) const = default;
        };
        return aui::range(
            RangeIterator { .spreadsheet = this, .range = range, .current = range.from },
            RangeIterator { .spreadsheet = this, .range = range, .current = { Cell::UNDEFINED, Cell::UNDEFINED } });
    }

    glm::uvec2 size() const { return mSize; }
examples/7guis/cells/src/Functions.cpp

7GUIs Cells — Spreadsheet processor (Excel).

#include <range/v3/all.hpp>
#include "Functions.h"

namespace {
template<aui::invocable<formula::Value> Callback>
void forEachArgAndRangeCell(const functions::Ctx& ctx, Callback&& callback) {
    for (const auto& arg : ctx.args) {
        if (auto rng = std::get_if<formula::Range>(&arg)) {
            for (const auto& cell : ctx.spreadsheet[*rng]) {
                callback(cell.value);
examples/7guis/cells/src/main.cpp

7GUIs Cells — Spreadsheet processor (Excel).

        mConnection = connect(mCell.value, [this](const formula::Value& v) {
            ALayoutInflater::inflate(
                this,
                std::visit(
                    aui::lambda_overloaded {
                      [](std::nullopt_t) -> _<AView> { return _new<AView>(); },
                      [](double v) -> _<AView> { return Label { "{}"_format(v) } AUI_OVERRIDE_STYLE { ATextAlign::RIGHT }; },
                      [](const AString& v) -> _<AView> { return Label { "{}"_format(v) }; },
                      [](const formula::Range& v) -> _<AView> { return Label { "#RANGE?" }; },
                    },
examples/7guis/flight_booker/CMakeLists.txt

7GUIs Flight Booker — Flight Booker.

auib_import(ctre https://github.com/hanickadot/compile-time-regular-expressions
            VERSION 6225211806c48230e5d17a1e555ef69e7325051c
            CMAKE_ARGS -DCTRE_BUILD_TESTS=OFF)

aui_executable(aui.example.flight_booker)
aui_link(aui.example.flight_booker PRIVATE aui::views ctre::ctre)
examples/7guis/circle_drawer/CMakeLists.txt

7GUIs Circle Drawer — Undo, redo, dialog control.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.circle_drawer)
aui_link(aui.example.circle_drawer PRIVATE aui::views)
examples/7guis/circle_drawer/src/main.cpp

7GUIs Circle Drawer — Undo, redo, dialog control.

                        Label { "Adjust diameter of circle at {}."_format(circle->position) },
                        Slider {
                          .value = AUI_REACT(circle->radius / MAX_RADIUS),
                          .onValueChanged =
                              [this, circle](aui::float_within_0_1 s) {
                                  circle->radius = s * MAX_RADIUS;
                                  mState->circles.notify();
                              },
                        },
                      });
examples/7guis/timer/CMakeLists.txt

7GUIs Timer — Timer example.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.timer)
aui_link(aui.example.timer PRIVATE aui::views)
examples/7guis/timer/src/main.cpp

7GUIs Timer — Timer example.

              /// [timer_slider]
              Slider {
                .value = AUI_REACT(float(mDuration->count()) / float(MAX_DURATION.count())),
                .onValueChanged =
                    [this](aui::float_within_0_1 newValue) {
                        mDuration =
                            high_resolution_clock::duration(long(float(MAX_DURATION.count()) * float(newValue)));
                    },
              } AUI_OVERRIDE_STYLE { Expanding { 1, 0 } },
              /// [timer_slider]
examples/7guis/crud/CMakeLists.txt

7GUIs CRUD — Create/Read/Update/Delete example.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.crud)
aui_link(aui.example.crud PRIVATE aui::views)
examples/7guis/crud/src/main.cpp

7GUIs CRUD — Create/Read/Update/Delete example.

    APropertyPrecomputed<bool> mDeleteEnabled = [this] { return mSelectedUser != nullptr; };
    APropertyPrecomputed<bool> mUpdateEnabled = [this] { return mCreateEnabled && mDeleteEnabled; };

    void createClicked() {
        mUsers.writeScope() << aui::ptr::manage_shared(new User {
          .name = std::exchange(mEditedUser.name, {}), .surname = std::exchange(mEditedUser.surname, {}) });
    }

    void updateClicked() {
        (*mSelectedUser)->name = std::exchange(mEditedUser.name, {});
examples/7guis/counter/CMakeLists.txt

7GUIs Counter — Simple counter.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.counter)
aui_link(aui.example.counter PRIVATE aui::views)
examples/7guis/temperature_converter/CMakeLists.txt

7GUIs Temperature Converter — Fahrenheit to Celsius and vice versa.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.temperature_converter)
aui_link(aui.example.temperature_converter PRIVATE aui::views)
examples/basic/hello_world/CMakeLists.txt

Console Hello World Example — Basic CLI Hello World application.

project(project_template)

# Use AUI.Boot
#
# Download aui.boot.cmake (one-time):
#   curl https://raw.githubusercontent.com/aui-framework/aui/refs/heads/master/aui.boot.cmake -o aui.boot.cmake
#
# Or use CLI mode:
#   cmake -P aui.boot.cmake update
#
examples/app/minesweeper/CMakeLists.txt

Minesweeper Game — Minesweeper game implementation driven by ass.

if (NOT (AUI_PLATFORM_WIN OR AUI_PLATFORM_LINUX OR AUI_PLATFORM_MACOS))
    return()
endif ()

aui_executable(aui.example.minesweeper)
aui_compile_assets(aui.example.minesweeper)

aui_link(aui.example.minesweeper PRIVATE aui::core aui::views)
examples/app/fractal/CMakeLists.txt

Fractal Example — Fractal viewer application demonstrating usage of custom shaders.

if (NOT (AUI_PLATFORM_WIN OR AUI_PLATFORM_LINUX OR AUI_PLATFORM_MACOS))
    return()
endif ()

aui_executable(aui.example.fractal)
aui_compile_assets(aui.example.fractal)

aui_link(aui.example.fractal PRIVATE aui::core aui::views)
examples/app/game_of_life/CMakeLists.txt

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.

project(aui.example.game_of_life)
cmake_minimum_required(VERSION 3.16)

if (NOT (AUI_PLATFORM_WIN OR AUI_PLATFORM_LINUX OR AUI_PLATFORM_MACOS))
    return()
endif ()
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.

                  },
            } AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } },
          },
          Centered {
            _new<CellsView>(aui::ptr::fake_shared(&mCells)) AUI_OVERRIDE_STYLE {
                  Expanding(),
                  BackgroundSolid(AColor::BLACK),
                },
          },
        } AUI_OVERRIDE_STYLE { LayoutSpacing { 4_dp } });
examples/app/notes/CMakeLists.txt

Notes App — Note taking app that demonstrates usage of AListModel, AProperty, user data saving and loading.

project(aui.example.notes)
cmake_minimum_required(VERSION 3.16)

# Uncomment this code to pull AUI:
#
# # Download aui.boot.cmake (one-time):
examples/app/notes/src/main.cpp

Notes App — Note taking app that demonstrates usage of AListModel, AProperty, user data saving and loading.

        try {
            if (!"notes.json"_path.isRegularFileExists()) {
                return;
            }
            aui::from_json(AJson::fromStream(AFileInputStream("notes.json")), mNotes);
        } catch (const AException& e) {
            ALogger::info(LOG_TAG) << "Can't load notes: " << e;
        }
    }
    /// [load]
examples/ui/contacts/CMakeLists.txt

AUI Contacts — Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.contacts)

aui_link(aui.example.contacts PRIVATE aui::core aui::views)
examples/ui/backdrop/CMakeLists.txt

Backdrop — Backdrop effects demo.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.backdrop)
aui_compile_assets(aui.example.backdrop)
aui_link(aui.example.backdrop PRIVATE aui::core aui::views)
examples/ui/opengl_simple/CMakeLists.txt

OpenGL Example — Demonstrates how to integrate custom OpenGL rendering with AUI Framework.

get_filename_component(_t ${CMAKE_CURRENT_SOURCE_DIR} NAME)

aui_executable("aui.example.${_t}")
aui_link("aui.example.${_t}" PRIVATE aui::core aui::views)
examples/ui/views/CMakeLists.txt

Views Example — All-in-one views building example.

project(aui.example.views)
cmake_minimum_required(VERSION 3.16)

# Uncomment this code to pull AUI:
#
# file(
examples/ui/views/src/ExampleWindow.cpp

Views Example — All-in-one views building example.

        Expanding(1, 0),
    });

    _<ATabView> tabView;
    auto progressBarState = _new<AProperty<aui::float_within_0_1>>(0);

    addView(tabView = _new<ATabView>() AUI_LET {
        it->addTab(
            AScrollArea::Builder().withContents(std::conditional_t<
                                                aui::platform::current::is_mobile(), Vertical, Horizontal> {
examples/ui/infinite_lazy_list/CMakeLists.txt

Infinite Lazy List — Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.

cmake_minimum_required(VERSION 3.10)

aui_executable(aui.example.infinite_lazy_list)

aui_link(aui.example.infinite_lazy_list PRIVATE aui::core aui::views)
examples/ui/infinite_lazy_list/src/main.cpp

Infinite Lazy List — Usage of AUI_DECLARATIVE_FOR to make an infinite lazy list.

            AThread::sleep(500ms); // imitate hard work here

            // aka "loaded" from backend storage of some kind
            auto loadedItems = AVector<_<Item>>::generate(20, [&](size_t i) {
                return aui::ptr::manage_shared(new Item { .value = "Item {}"_format(loadFrom + i) });
            });

            AUI_UI_THREAD { // back to main thread.
                state->items.writeScope()->insertAll(loadedItems);
                state->needMore = false;
examples/ui/embedded_sdl/CMakeLists.txt

SDL3 — This code demonstrates how to integrate the AUI Framework with SDL3 to create a window with OpenGL rendering.

set(AUIB_SDL3_VALIDATE OFF)
auib_import(SDL3 https://github.com/libsdl-org/SDL VERSION release-3.2.26)

aui_executable(aui.example.embedded_sdl)
aui_link(aui.example.embedded_sdl PRIVATE aui::core aui::views)

if (TARGET SDL3::SDL3-static)
    aui_link(aui.example.embedded_sdl PRIVATE SDL3::SDL3-static)
elseif (TARGET SDL3::SDL3-shared)

Public Methods#

return_void#


void aui::return_void()

Called by the compiler when the coroutine co_return s without a value.