- Note
- This page describes an example listed in UI.
- Minimal UI boilerplate template with AUI Assets.
Source Files#
Project Structure#
graph TD
A[project_template_assets_ui/] --> B[CMakeLists.txt]
A --> C[src/]
C --> D[MainWindow.h]
C --> E[MainWindow.cpp]
C --> F[main.cpp]
A --> G[assets/img/]
G --> H[logo.svg]
CMakeLists.txt#
# Standard routine
cmake_minimum_required(VERSION 3.16)
project(project_template_assets_ui)
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)
aui_compile_assets(${PROJECT_NAME})
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>
#include <AUI/View/ADrawableView.h>
using namespace declarative;
MainWindow::MainWindow():
AWindow(
"Project template app", 300_dp, 200_dp) {
setContents(
Centered{
Vertical{
Centered {
Icon {
":img/logo.svg" } with_style {
FixedSize(64_dp) } },
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
Controls the fixed size of AView.
Definition FixedSize.h:26
Declarative form of ADrawableView.
Definition ADrawableView.h:110
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.