AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
Minimal UI Template XMake

Note
This page describes an example listed in UI.
Minimal UI boilerplate template XMake.

Source Files#

Project Structure#

graph TD A[project_template_ui_xmake/] --> B[xmake.lua] A --> C[src/] C --> D[MainWindow.h] C --> E[MainWindow.cpp] C --> F[main.cpp] A --> G[.vscode/] G --> H[c_cpp_properties.json]

xmake.lua#

-- Specify available build configurations
add_rules("mode.release", "mode.debug")
-- Specify compile commands output directory and LSP to analyze C++ code files and highlight IntelliSense
add_rules("plugin.compile_commands.autoupdate", {outputdir = ".vscode", lsp = "clangd"})
-- Specify C++ standard to use, as AUI uses C++20 by default
set_languages("c++20")
-- Download aui package to use for targets later
add_requires("aui")
-- Use shared GLEW to resolve LNK2019 errors
add_requireconfs("**.glew", {override = true, configs = {shared = true}})
-- Define our target executable to build
target("aui-minimal-example")
    -- Add source code and headers to target
    add_files("src/*.cpp")
    add_includedirs("src")
    -- Add AUI package to target while linking only required components
    add_packages("aui", {components = {"core", "image", "views", "xml"}})
    -- Add defines that point to your OS and link against required syslinks/frameworks
    if is_plat("windows") then
        add_defines(
            "AUI_PLATFORM_WIN=1", "AUI_PLATFORM_LINUX=0", "AUI_PLATFORM_APPLE=0"
        )
        add_syslinks("gdi32", "ole32")
    elseif is_plat("linux") then
        add_defines(
            "AUI_PLATFORM_WIN=0", "AUI_PLATFORM_LINUX=1", "AUI_PLATFORM_APPLE=0"
        )
    elseif is_plat("macosx") then
        add_defines(
            "AUI_PLATFORM_WIN=0", "AUI_PLATFORM_LINUX=0", "AUI_PLATFORM_APPLE=1"
        )
    end
    -- Add defines that point to symbol exports
    add_defines(
        "API_AUI_VIEWS=AUI_IMPORT", "API_AUI_IMAGE=AUI_IMPORT"
    )

src/MainWindow.h#

#pragma once
#include <AUI/Platform/AWindow.h>
class MainWindow: public AWindow {
public:
    MainWindow();
};
Represents a window in the underlying windowing system.
Definition AWindow.h:45

src/MainWindow.cpp#

#include "MainWindow.h"
#include <AUI/Util/UIBuildingHelpers.h>
#include <AUI/View/ALabel.h>
#include <AUI/View/AButton.h>
#include <AUI/Platform/APlatform.h>
using namespace declarative;
MainWindow::MainWindow(): AWindow("Project template app", 300_dp, 200_dp) {
    setContents(
        Centered{
            Vertical{
                Centered { Label { "Hello world from AUI!" } },
                _new<AButton>("Visit GitHub repo").connect(&AView::clicked, this, [] {
                    APlatform::openUrl("https://github.com/aui-framework/aui");
                }),
                _new<AButton>("Visit docs").connect(&AView::clicked, this, [] {
                    APlatform::openUrl("https://aui-framework.github.io/");
                }),
                _new<AButton>("Submit an issue").connect(&AView::clicked, this, [] {
                    APlatform::openUrl("https://github.com/aui-framework/aui/issues/new");
                }),
            }
        }
    );
}
emits clicked
Left mouse button clicked.
Definition AView.h:945
API_AUI_VIEWS void openUrl(const AUrl &url)
Opens a URL using the system's default application.
Declarative form of ALabel.
Definition ALabel.h:35

src/main.cpp#

#include <AUI/Platform/Entry.h>
#include "MainWindow.h"
    _new<MainWindow>()->show();
    return 0;
};
#define AUI_ENTRY
Application entry point.
Definition Entry.h:90

.vscode/c_cpp_properties.json#

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "windowsSdkVersion": "10.0.26100.0",
            "compilerPath": "cl.exe",
            "cStandard": "c17",
            "cppStandard": "c++20",
            "intelliSenseMode": "windows-msvc-x64"
        }
    ],
    "version": 4
}

Source Files#