- Note
- This page describes an example listed in UI.
- Minimal UI boilerplate template.
Source Files#
Project Structure#
graph TD
A[project_template_ui/] --> B[CMakeLists.txt]
A --> C[src/]
C --> D[MainWindow.h]
C --> E[MainWindow.cpp]
C --> F[main.cpp]
CMakeLists.txt#
# Standard routine
cmake_minimum_required(VERSION 3.16)
project(project_template_ui)
# Tip: in a production project don't use branch name, use a specific name tag (i.e. v1.1.1),
# but for a sandbox project branch name is perfectly enough
set(AUI_VERSION v7.0.1)
# Use AUI.Boot
file(
DOWNLOAD
https://raw.githubusercontent.com/aui-framework/aui/${AUI_VERSION}/aui.boot.cmake
${CMAKE_CURRENT_BINARY_DIR}/aui.boot.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/aui.boot.cmake)
# import AUI
auib_import(aui https://github.com/aui-framework/aui
COMPONENTS core views
VERSION ${AUI_VERSION})
# Create the executable. This function automatically links all sources from the src/ folder,
# creates CMake target and places the resulting executable to bin/ folder.
aui_executable(${PROJECT_NAME})
# Link required libs
aui_link(${PROJECT_NAME} PRIVATE aui::core aui::views)
src/MainWindow.h#
#pragma once
#include <AUI/Platform/AWindow.h>
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, [] {
}),
}),
}),
}
}
);
}
emits clicked
Left mouse button clicked.
Definition AView.h:945
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
This example is located outside AUI's source tree. Checkout its repository.