Skip to content

AUI_ENTRY#

Application entry point.

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

Definition#

#define AUI_ENTRY \
    AUI_EXPORT int aui_entry(const AStringVector& args); \
    AUI_EXPORT int aui_main(int argc, char** argv, int(*aui_entry)(const AStringVector&)); \
    static int fake_main(int argc, char** argv) {                               \
        return aui_main(argc, argv, aui_entry);\
    }             \
AUI_EXPORT int aui_entry(const AStringVector& args)

Detailed Description#

Entry point of any AUI application.

Native entry point varies platform to platform (i.e. Windows requires int main entry point for console applications and WinMain for graphical applications; entry point of an Android application is located in Java code). AUI_ENTRY unifies your entry point, effectively supporting every platform.

AUI_ENTRY of a graphical application should be non-blocking since on mobile platforms application's event loop is located outsize of the entry point. On desktop platforms, an event loop is created outside AUI_ENTRY in order to unify the mobile and desktop behaviour. If there are no open windows, the event loop breaks, causing the application to exit with the exit code returned by AUI_ENTRY earlier, or 0.

Application arguments (int argc, char** argv) are forwarded to AUI_ENTRY as AStringVector args.

Minimal entrypoint of an UI application:

/*
 * AUI Framework - Declarative UI toolkit for modern C++20
 * Copyright (C) 2020-2025 Alex2772 and Contributors
 *
 * SPDX-License-Identifier: MPL-2.0
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include "ExampleWindow.h"
#include <AUI/Platform/Entry.h>

AUI_ENTRY {
    _new<ExampleWindow>()->show();
    return 0;
}

Minimal entrypoint of a console application:

/*
 * AUI Framework - Declarative UI toolkit for modern C++20
 * Copyright (C) 2020-2022 Alex2772
 *
 * SPDX-License-Identifier: MPL-2.0
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 */

#include <AUI/Platform/Entry.h>
#include <AUI/Logging/ALogger.h>

static constexpr auto LOG_TAG = "MyApp";

AUI_ENTRY {
    ALogger::info(LOG_TAG) << "Hello world!";
    return 0;
}

Prototype of AUI_ENTRY function you are actually implementing:

AUI_EXPORT int aui_entry(const AStringVector& args);

Examples#

examples/app/notes/src/main.cpp

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

                      },
                      /// [scrollarea]
                      AScrollArea::Builder()
                          .withContents(
                          AUI_DECLARATIVE_FOR(note, *mNotes, AVerticalLayout) {
                              observeChangesForDirty(note);
                              return notePreview(note) AUI_LET {
                                  connect(it->clicked, [this, note] { mCurrentNote = note; });
                                  it& mCurrentNote > [note](AView& view, const _<Note>& currentNote) {
                                      ALOG_DEBUG(LOG_TAG) << "currentNote == note " << currentNote << " == " << note;

examples/ui/contacts/src/main.cpp

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

        mSelectedContact = nullptr;
    }

    _<AView> indexedList() {
        return AUI_DECLARATIVE_FOR(group, *mContacts | ranges::views::chunk_by([](const _<Contact>& lhs, const _<Contact>& rhs) {
                                return groupLetter(lhs->displayName) == groupLetter(rhs->displayName);
                            }), AVerticalLayout) {
            auto firstContact = *ranges::begin(group);
            auto firstLetter = groupLetter(firstContact->displayName);
            ALogger::info("Test") << "Computing view for group " << AString(1, firstLetter);

examples/ui/infinite_lazy_list/src/main.cpp

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

        };
    });

    return Vertical {
        AUI_DECLARATIVE_FOR(i, *state->items, AVerticalLayout) { return Label{} & i->value; },
        Centered {
          _new<ASpinnerV2>() AUI_LET {
                  AObject::connect(it->redrawn, AObject::GENERIC_OBSERVER, [state] {
                      // when a spinner appears, we indicate that we need more items.
                      state->needMore = true;

examples/7guis/crud/src/main.cpp

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

                Label { "Filter prefix:" },
                _new<ATextField>() AUI_WITH_STYLE { Expanding(1, 0) } && mFilterPrefix,
              },
              AScrollArea::Builder().withExpanding().withContents(
                  AUI_DECLARATIVE_FOR(i, *mUsers | FILTER_VIEW, AVerticalLayout) {
                    auto view = _new<ALabel>();
                    view & i->displayName;
                    connect(mSelectedUser, view, [this, &view = *view, i] {
                        view.setAssName("selected", mSelectedUser == i);
                    });

examples/ui/backdrop/src/main.cpp

Backdrop - Backdrop effects demo.

    };
    return result;
}

AUI_ENTRY {
    auto window = _new<AWindow>("Backdrop test", 600_dp, 300_dp);

    window->setContents(headerWithContents(
        Centered {
          Vertical::Expanding {

examples/app/fractal/src/main.cpp

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

#include <AUI/Platform/Entry.h>
#include "FractalWindow.h"

AUI_ENTRY {
    _new<FractalWindow>()->show();
    return 0;
}

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.

private:
    Cells mCells { { 64, 64 } };
}; /// end

AUI_ENTRY {
    auto w = _new<GameOfLifeWindow>();
    w->pack();
    w->show();
    return 0;
}

examples/app/minesweeper/src/main.cpp

Minesweeper Game - Minesweeper game implementation driven by ass.

#include <AUI/Platform/Entry.h>
#include "MinesweeperWindow.h"

AUI_ENTRY {
    _new<MinesweeperWindow>()->show();

    return 0;
}

examples/ui/minimal_ui_xmake/src/main.cpp

Minimal UI Template XMake - Minimal UI boilerplate template XMake.

#include <AUI/Platform/Entry.h>
#include "MainWindow.h"

AUI_ENTRY {
    _new<MainWindow>()->show();
    return 0;
};

examples/basic/hello_world/src/main.cpp

Console Hello World Example - Basic CLI Hello World application.

#include <AUI/Logging/ALogger.h>

static constexpr auto LOG_TAG = "MyApp";

AUI_ENTRY {
    ALogger::info(LOG_TAG) << "Hello world!";
    return 0;
}

examples/7guis/flight_booker/src/main.cpp

7GUIs Flight Booker - Flight Booker.

        AMessageBox::show(this, "You've booked the flight", msg);
    }
};

AUI_ENTRY {
    _new<FlightBookerWindow>()->show();
    return 0;
}

examples/7guis/cells/src/main.cpp

7GUIs Cells - Spreadsheet processor (Excel).

        } AUI_WITH_STYLE { Padding(0) });
    }
};

AUI_ENTRY {
    _new<CellsWindow>()->show();
    return 0;
}

examples/7guis/circle_drawer/src/main.cpp

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

        mState.history.redo();
    }
};

AUI_ENTRY {
    _new<CircleDrawerWindow>()->show();
    return 0;
}

examples/7guis/temperature_converter/src/main.cpp

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

private:
    AProperty<int> mCelsius, mFahrenheit;
};

AUI_ENTRY {
    _new<TemperatureConverterWindow>()->show();
    return 0;
}

examples/7guis/counter/src/main.cpp

7GUIs Counter - Simple counter.

private:
    AProperty<int> mCounter;
};

AUI_ENTRY {
    _new<CounterWindow>()->show();
    return 0;
}

examples/7guis/timer/src/main.cpp

7GUIs Timer - Timer example.

    void reset() { mStartTime = high_resolution_clock::now(); }
};

AUI_ENTRY {
    _new<TimerWindow>()->show();
    return 0;
}

examples/ui/views/src/main.cpp

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

#include "ExampleWindow.h"
#include <AUI/Platform/Entry.h>

AUI_ENTRY {
    _new<ExampleWindow>()->show();
    return 0;
}

Examples#