graph TD
A[project_template_ui_assets_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]
A --> I[xmake/]
I --> J[aui.lua]
A --> K[assets/img/]
K --> L[logo.svg]
-- Specify available build configurationsadd_rules("mode.release","mode.debug")-- Specify compile commands output directory and LSP to analyze C++ code files and highlight IntelliSenseadd_rules("plugin.compile_commands.autoupdate",{outputdir=".vscode",lsp="clangd"})-- Specify C++ standard to use, as AUI uses C++20 by defaultset_languages("c++20")-- Download aui package to use for targets lateradd_requires("aui")-- Define our target executable to buildtarget("aui-assets-minimal-example")-- Add source code and headers to targetadd_files("src/*.cpp")add_includedirs("src")-- Add AUI package to target while linking only required componentsadd_packages("aui",{components={"core","image","views","xml"}})-- Resolve linking by grouping AUI components into link groupsadd_linkgroups("aui.views","aui.xml","aui.image","aui.core",{whole=true})-- Pack assets before building the targeton_prepare(function(target)import("xmake.aui",{alias="aui"})aui.assets(target)end)
import("lib.detect.find_program")import("core.project.config")function_get_gen_path()returnpath.join(path.absolute(config.builddir()),".gens","aui")endfunction_get_aui_package(target)-- Get the aui package from targetfor_,pkginpairs(target:pkgs())doifpkg:name()=="aui"thenreturnpkgendendreturnnilendfunction_pack_asset(assets_dir,asset_path,aui_installdir)localtoolbox_path=path.join(aui_installdir,"bin","aui.toolbox")ifnotos.isfile(toolbox_path)thentoolbox_path=path.join(aui_installdir,"bin","aui.toolbox.exe")endifnotos.isfile(toolbox_path)thentoolbox_path=find_program("aui.toolbox")endwprint("Using toolbox: "..toolbox_path)os.execv(toolbox_path,{"pack",assets_dir,asset_path,path.join(_get_gen_path(),hash.sha256(asset_path)..".cpp")})endfunctionassets(target)-- Get aui package install directorylocalaui_pkg=_get_aui_package(target)ifnotaui_pkgthenraise("aui package not found in target")endlocalaui_installdir=aui_pkg:installdir()wprint("AUI package install directory: "..aui_installdir)localassets_dir=path.join(path.absolute(target:scriptdir()),"assets")for_,fileinipairs(os.files(path.join(assets_dir,"**")))do_pack_asset(assets_dir,file,aui_installdir)end-- Add generated files to the targettarget:add("files",path.join(_get_gen_path(),"**.cpp"))end
#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>usingnamespacedeclarative;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,[]{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");}),}});}
#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>usingnamespacedeclarative;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,[]{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");}),}});}