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&)); \
[[maybe_unused]] static int _fake_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. The event loop runs as long as the application is held (by open windows or by AApplication::hold()), then the application exits with the exit code returned by AUI_ENTRY earlier (or the one passed to AApplication::quit()). If nothing holds the application, it exits right after AUI_ENTRY returns, so AUI_ENTRY is perfectly fine for CLI applications, even if they link to aui::views.

AUI_ENTRY is called every time the application's executable is launched. That includes a user trying to launch an already running application. By default, every launch is an independent process (multi instance). To make the application single instanced, call AApplication::requestSingleInstanceLock() in the beginning of AUI_ENTRY. See Application lifetime & instancing for details.

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/7guis/cells/src/main.cpp

7GUIs Cells — Spreadsheet processor (Excel).

        } AUI_OVERRIDE_STYLE { Padding(0) });
    }
};

AUI_ENTRY {
    _new<CellsWindow>()->show();
    return 0;
}
examples/7guis/flight_booker/src/main.cpp

7GUIs Flight Booker — Flight Booker.

        return true;
    };
};

AUI_ENTRY {
    // Create state instance
    _<State> state = _new<State>();

    // Create window
    auto window = _new<AWindow>("AUI - 7GUIs - Book Flight", 150_dp, 50_dp);
examples/7guis/circle_drawer/src/main.cpp

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

    void redo() { mState.history.redo(); }
};

AUI_ENTRY {
    _new<CircleDrawerWindow>()->show();
    return 0;
}
examples/7guis/timer/src/main.cpp

7GUIs Timer — Timer example.

    void reset() { mStartTime = high_resolution_clock::now(); }
};
/// [example]

AUI_ENTRY {
    _new<TimerWindow>()->show();
    return 0;
}
examples/7guis/crud/src/main.cpp

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

        mSelectedUser = nullptr;
    }
};

AUI_ENTRY {
    _new<CRUDWindow>()->show();
    return 0;
}
examples/7guis/counter/src/main.cpp

7GUIs Counter — Simple counter.

    AProperty<int> mCounter;
};
/// [counter]

AUI_ENTRY {
    _new<CounterWindow>()->show();
    return 0;
}
examples/7guis/temperature_converter/src/main.cpp

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

    AProperty<int> mCelsius, mFahrenheit;
};
/// [window]

AUI_ENTRY {
    _new<TemperatureConverterWindow>()->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/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/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/notes/src/main.cpp

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

    AProperty<_<Note>> mCurrentNote;
    AProperty<bool> mDirty = false;
};

AUI_ENTRY {
    auto w = _new<MainWindow>();
    w->show();
    return 0;
}
examples/ui/minimal_ui_assets_xmake/src/main.cpp

Minimal UI Template XMake with Assets — Minimal UI boilerplate template XMake with AUI Assets.

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

AUI_ENTRY {
    _new<MainWindow>()->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/ui/contacts/src/main.cpp

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

        return d;
    }
};

AUI_ENTRY {
    _new<ContactsWindow>()->show();
    return 0;
}
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/ui/opengl_simple/src/main.cpp

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

    GLuint mVertexBufferObject {};
};
}   // namespace

AUI_ENTRY {
    // ask aui to provide opengl context for us. (no fallback to software rendering)
    ARenderingContextOptions::set({
        .initializationOrder = {
            ARenderingContextOptions::OpenGL{},
        },
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/ui/infinite_lazy_list/src/main.cpp

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

        },
    };
}

AUI_ENTRY {
    auto window = _new<AWindow>("Infinite Lazy List", 200_dp, 300_dp);
    window->setContents(Stacked { AScrollArea::Builder().withContents(myLazyList(_new<State>())) });
    window->show();

    return 0;
examples/ui/embedded_sdl/src/main.cpp

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

/// [handleSDLEvent]

using namespace declarative;

AUI_ENTRY {
    /// [SDL_Init]
    if (!SDL_Init(SDL_INIT_VIDEO)) {
        ALogger::err("SDL3") << SDL_GetError();
        return 1;
    }

Examples#