This guide will help you get started with building your first SphereUI application.
Every SphereUI application starts by initializing the Application singleton.
#include <SPHXApplication.hpp>
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
SphereUI::Application::getInstance().init();
// ...
}SphereUI provides a Win32Window class for creating windows on Windows.
#include <SPHXFoundation.hpp>
SphereUI::Win32Window window("My SphereUI App", 800, 600);
window.enableMica(true); // Optional: Enable Windows 11 Mica effectSphereUI uses a tree of FlexNode objects for the UI. You can use standard nodes or create custom ones.
using namespace SphereUI;
auto root = FlexNode::Column();
root->style.backgroundColor = Theme::Background;
root->style.setWidthFull();
root->style.setHeightFull();
root->style.setPadding(20);
auto title = std::make_shared<TextNode>("Hello, SphereUI!");
title->fontSize = Theme::FontLarge;
title->color = Theme::TextPrimary;
root->addChild(title);
auto btn = std::make_shared<ButtonNode>();
btn->label = "Click Me";
btn->onClick = []() {
// Handle click
};
root->addChild(btn);Finally, set the root node for the window and start the event loop.
window.setRoot(root);
window.run();#include <SPHXApplication.hpp>
#include <SPHXGraphicComponents.hpp>
using namespace SphereUI;
int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) {
Application::getInstance().init();
Win32Window window("Hello World", 400, 300);
auto root = FlexNode::Column();
root->style.backgroundColor = Theme::Background;
root->style.setJustifyContent(YGJustifyCenter);
root->style.setAlignItems(YGAlignCenter);
root->style.setWidthFull();
root->style.setHeightFull();
auto text = std::make_shared<TextNode>("Welcome to SphereUI");
text->color = Theme::TextPrimary;
root->addChild(text);
window.setRoot(root);
window.run();
return 0;
}- Native C++ UI: build node trees directly with
FlexNodeand the built-in components. - Embedded assets: pack UI text with
res://— Resources. - Scripted UI (Windows): V8 + optional React reconciler — JavaScript and React and MikoUI.
- Build from CI or clean machine: Build and CI.