Getting Started with C++
This guide shows how to create your first Azul application in C++.
Quick Start
Download the pre-compiled library from releases and include azul.hpp in your project.
Hello World
// Your application state
;
// Layout function - converts state to UI
StyledDom
int
Enums
Enums use C++11 enum class for type safety:
// Explicit constructors are static functions
auto window = ;
Move Semantics
All by-value arguments require std::move:
auto window = ;
app.;
Adding Callbacks
// Callback function
Update
// In layout function
auto button =
.
.;
// Attach callback
auto event = ;
button.root.;
Constructors
Default constructors take arguments in field order:
// API: struct ColorU { r: u8, g: u8, b: u8, a: u8 }
auto color = ;
Explicit constructors are static functions:
auto window = ;
RefAny and Generics
No macros needed - use C++ templates:
;
auto object = ;
// Read-only access
if
// Mutable access
if
Vector Conversions
Convert std::vector without copying:
auto scancodes = std::vector<int>;
auto converted = ;
auto backToStd = converted.;
Convert strings:
auto stdString = ;
auto azulString = ;
Pattern Matching
Union enums have constexpr constructors and match functions for pattern matching:
// Create a union enum - Exact() is a constexpr function
auto cursor = ;
// Const reference match (returns std::optional<const StyleCursor*>)
if
// Mutable match (returns std::optional<StyleCursor* restrict>)
if
Compilation
# Linux
# macOS
# Windows (MSVC)
Next Steps
- CSS Styling - Supported CSS properties
- Widgets - Interactive components
- Architecture - Framework design