#include "vulkan/vulkan.h" import Crafter.Graphics; import Crafter.Event; import Crafter.Math; import std; using namespace Crafter; int main() { Device::Initialize(); Window window(1280, 720, "VulkanUI"); window.StartInit(); window.FinishInit(); Font font("Inter.ttf"); UI::Theme theme = UI::themes::default_dark(); theme.defaultFont = &font; // ───────────────────────────────────────────────────────────────────── // Wire the scene: it auto-creates a descriptor heap, plugs into the // window's pass list, hooks mouse + update events, and drives a // compute-shader UI pass per frame. // ───────────────────────────────────────────────────────────────────── UI::UIScene scene; scene.Initialize(window, "ui.comp.spv"); scene.background(UI::Color{0.06f, 0.07f, 0.10f, 1.0f}); scene.Root( UI::VStack{} .padding(20) .spacing(12) .children( UI::Text{"Crafter UI — V1"}.font(font).size(28), UI::Text{}.font(font).size(14).runs( UI::TextRun{"Click "}, UI::TextRun{"Quit"}.color(UI::Color{1.0f, 0.55f, 0.55f}).bold(), UI::TextRun{" to close the window. Tabs switch on click. "}, UI::TextRun{"Have fun!"}.color(UI::Color{0.55f, 0.85f, 1.0f}) ), UI::HStack{} .width(UI::Length::Frac(1)) .spacing(8) .children( UI::Button{"Play"} .font(font).style(theme.primary) .onClick([]{ std::println(std::cerr, "[click] Play"); }), UI::Button{"Options"}.font(font).style(theme.secondary).onClick([]{ std::println(std::cerr, "[click] Options"); }), UI::Spacer{}, UI::Button{"Quit"} .font(font).style(theme.danger) .onClick([]{ std::println(std::cerr, "[click] Quit"); std::_Exit(0); }) ), UI::ProgressBar{} .value(0.42f) .size(UI::Length::Frac(1), UI::Length::Px(20)) .foreground(theme.primary.background), UI::TabView{} .font(font) .width(UI::Length::Frac(1)) .height(UI::Length::Px(220)) .tab("Graphics", UI::VStack{}.padding(8).spacing(8).children( UI::Text{"Resolution"}.font(font).size(14), UI::InputField{"1920x1080"}.font(font).style(theme.input), UI::Text{"Max lights"}.font(font).size(14), UI::InputField{"32"}.font(font).style(theme.input) )) .tab("Input", UI::VStack{}.padding(8).spacing(8).children( UI::Text{"Mouse sensitivity"}.font(font).size(14), UI::InputField{"1.0"}.font(font).style(theme.input) )) .tab("Audio", UI::VStack{}.padding(8).spacing(8).children( UI::Text{"Master volume"}.font(font).size(14), UI::InputField{"80"}.font(font).style(theme.input) )) ) ); window.Render(); window.SaveFrame("frame.png"); window.StartUpdate(); // continuous rendering — UIScene re-emits per frame window.StartSync(); }