ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Layouts.hpp
Go to the documentation of this file.
1#pragma once
2
11
12#include "Common.hpp"
13#include "Layout.hpp"
14
15namespace ZenitUI::UI
16{
17
21
27 inline std::shared_ptr<Layout> VStack(std::initializer_list<std::shared_ptr<Layout>> children = {})
28 {
29 auto l = std::make_shared<Layout>(LayoutType::Vertical);
30 l->setStyleTag("VStack");
31 for (auto &c : children)
32 l->addChild(c);
33 return l;
34 }
35
41 inline std::shared_ptr<Layout> HStack(std::initializer_list<std::shared_ptr<Layout>> children = {})
42 {
43 auto l = std::make_shared<Layout>(LayoutType::Horizontal);
44 l->setStyleTag("HStack");
45 for (auto &c : children)
46 l->addChild(c);
47 return l;
48 }
49
53 inline std::shared_ptr<Layout> Box(std::initializer_list<std::shared_ptr<Layout>> children = {})
54 {
55 auto l = std::make_shared<Layout>(LayoutType::Horizontal);
56 l->setStyleTag("Box");
57 for (auto &c : children)
58 l->addChild(c);
59 return l;
60 }
61
66 inline std::shared_ptr<Layout> Grid(std::initializer_list<std::shared_ptr<Layout>> children = {})
67 {
68 auto l = std::make_shared<Layout>(LayoutType::Grid);
69 l->setStyleTag("Grid");
70 for (auto &c : children)
71 l->addChild(c);
72 return l;
73 }
74
86 class Panel : public TLayout<Panel>
87 {
88 public:
90 {
91 setBlocksRaycast(true);
92 setInteractive(false);
93 setStyleTag("Panel");
94 }
95 };
96
98 inline std::shared_ptr<Panel> Pan() { return Panel::create(); }
100} // namespace ZenitUI::UI
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
void setStyleTag(const std::string &t)
Set the node's style tag.
TLayout(Args &&...args)
Definition Layout.hpp:1401
static std::shared_ptr< Panel > create(Args &&...args)
Definition Layout.hpp:1410
@ Vertical
Children flow top-to-bottom (column flex semantics).
Definition UIEnums.hpp:31
@ Stack
Children overlap each other; Z-order controls paint order.
Definition UIEnums.hpp:30
@ Grid
2D CSS-style grid layout (grid-template-columns / grid-template-rows).
Definition UIEnums.hpp:33
@ Horizontal
Children flow left-to-right (row flex semantics).
Definition UIEnums.hpp:32
std::shared_ptr< Layout > Grid(std::initializer_list< std::shared_ptr< Layout > > children={})
Create a 2D grid container (LayoutType::Grid).
Definition Layouts.hpp:66
std::shared_ptr< Layout > VStack(std::initializer_list< std::shared_ptr< Layout > > children={})
Create a vertical-flow container (LayoutType::Vertical).
Definition Layouts.hpp:27
std::shared_ptr< Layout > HStack(std::initializer_list< std::shared_ptr< Layout > > children={})
Create a horizontal-flow container (LayoutType::Horizontal).
Definition Layouts.hpp:41
std::shared_ptr< Panel > Pan()
Convenience factory for Panel::create().
Definition Layouts.hpp:98
std::shared_ptr< Layout > Box(std::initializer_list< std::shared_ptr< Layout > > children={})
Generic Flexbox container modified via CSS (direction).
Definition Layouts.hpp:53