AUI Framework
master
Cross-platform module-based framework for developing C++20 desktop applications
|
AUI uses CMake as a build system. All CPP source files are placed in src/
folder. See file structure in the examples below.
Project: docs/projects/hello_world/basic
Files:
Here's the example of basic hello work application, which every AUI project starts with.
CMakeLists.txt
src/main.cpp
AUI.Boot is a CMake script which allows you to manage dependencies. You can specify link to a repository to add an installable (and findable by CMake) dependency. It compiles and links all required dependencies to free you from dependency management and focus you right to development of your application.
To build a CMake project:
build/
): mkdir build
cd build
cmake ..
If you use AUI on your computer for the first time, the command above will take a lot of time because it builds AUI.cmake . --build
bin/project_template
Possible output:
Project: docs/projects/hello_world/ui
Files:
Since AUI is graphical framework it allows to easily create windows, buttons, fields without any graphical UI toolkits.
Don't forget to add component views
and link to aui::views
in CMakeLists.txt
:
aui::views
is a module which holds all UI related functionality of the framework.
The main.cpp
file also contains some changes:
src/main.cpp
Let's analyze this code line by line:
#include <AUI/Platform/Entry.h>
for AUI_ENTRY
;#include <AUI/Platform/AWindow.h>
for AWindow
;#include <AUI/Util/UIBuildingHelpers.h>
for Stacked
and ALabel
;class MyWindow: public AWindow
we created our own window class because the setContents
function is protected
;MyWindow(): AWindow("Hello world", 300_dp, 200_dp)
specifies window title and size, _dp
means density independent screen unit (300_dp is 300 pixels with 100% DPI scale and 450 pixels with 150% DPI scale), for more info check the AMetric section;setContents( ... )
updates the contents of the container (of the window in our case);Stacked { ... }
means the container of AStackedLayout
layout manager, basically it centers all of its children specified in the curly braces; _new<ALabel>("Hello world!")
is the only child of the stacked container, _new
is an alias for the std::make_shared
function which returns std::shared_ptr
, ALabel
is a simple label (text on the screen), arguments in braces are used to construct ALabel
;_new<MyWindow>()->show();
creates a new instance of your window and pushes it to the AUI's window manager, which references to your window which guards your window from destruction by std::shared_ptr
.Please note that if any window in shown, an event loop is created after returning from the AUI_ENTRY
function.
The example above produces the following window:
See layout managers for more info about layout managers.
See ASS for more info about styling.