Appearance
Getting started
Set up Barton in a CMake project and create your first application window.
Requirements
- A C++23 compiler
- CMake
Installation
The easiest way to get started is by adding CPM.cmake to the project:
cmake
include(cmake/CPM.cmake)
CPMAddPackage("gh:violet-crown-games/barton@0.1.0")
add_executable(hello main.cpp)
target_link_libraries(hello PRIVATE barton)TIP
Use the latest release in place of 0.1.0.
First window
Barton applications use Window components to define their interface. Create a type derived from Window and implement render to describe its contents.
cpp
#include <barton/barton.h>
using namespace barton;
class MainWindow : public Window {
public:
View render() const {
return Container {
align_items = Align::Center,
justify_content = Justify::Center,
Text { "Hello, Barton" },
};
}
};
int main(int argc, char** argv) {
return App {}
.open<MainWindow>({ .title = "Hello" })
.run(argc, argv)
.unwrap_or_else([](const auto&) { return 1; });
}Here, MainWindow describes a centered text label inside a container. App opens the window, starts the event loop, and runs until the application exits.
Next steps
Read Concepts to see how props, state and environment fit together.