slot 0.0.1
A real time UI render framework
载入中...
搜索中...
未找到
DockTree.h
浏览该文件的文档.
1#pragma once
2
3#include <cstdint>
4#include <memory>
5#include <string>
6#include <vector>
7
8namespace z8::ui {
9class BaseNode;
10
11using DockNodeID = std::uint64_t;
12
14struct DockRect {
15 float Left = 0.0f;
16 float Top = 0.0f;
17 float Width = 0.0f;
18 float Height = 0.0f;
19
20 bool Contains(float x, float y) const;
21};
22
23enum class DockNodeType { Leaf, Split };
26enum class FixedSplitChild { None, A, B };
27enum class DockSide { Left, Right, Top, Bottom, Center };
29
35struct DockNode {
38 DockNode *Parent = nullptr;
41 float SplitRatio = 0.5f;
42 float FixedExtent = 0.0f;
44 bool SplitterResizable = true;
45 std::unique_ptr<DockNode> ChildA;
46 std::unique_ptr<DockNode> ChildB;
47 std::vector<BaseNode *> Panels;
48};
49
65
71public:
72 std::unique_ptr<DockNode> Root;
73
76 DockNode *Find(DockNodeID id) const;
77 DockNode *FindLeafAt(float x, float y) const;
78 DockNode *FindPanelLeaf(const BaseNode *panel) const;
79 DockNode *FindSplitterAt(float x, float y, float tolerance = 4.0f) const;
81 void Layout(const DockRect &workspace);
84 float minimumExtent = 80.0f);
85 bool Validate(std::string *error = nullptr) const;
86 std::string Dump() const;
87 void Clear();
88
89private:
91
92 std::unique_ptr<DockNode> CreateLeaf(BaseNode *panel = nullptr);
94 static void LayoutNode(DockNode &node, const DockRect &rect);
95 std::unique_ptr<DockNode> *OwnerSlot(DockNode *node);
96};
97
98} // namespace z8::ui
资源的强类型引用,同时覆盖持久化 ID 与运行时索引两种边界。
Definition ResourceRef.h:36
Definition BaseNode.h:25
Definition DockTree.h:70
DockNode * FindLeafAt(float x, float y) const
Definition DockTree.cpp:130
DockNode * FindSplitterAt(float x, float y, float tolerance=4.0f) const
Definition DockTree.cpp:145
std::unique_ptr< DockNode > * OwnerSlot(DockNode *node)
Definition DockTree.cpp:149
DockNode * FindPanelLeaf(const BaseNode *panel) const
Definition DockTree.cpp:134
bool Validate(std::string *error=nullptr) const
Definition DockTree.cpp:327
bool ResizeSplitter(DockNodeID split, float clientX, float clientY, float minimumExtent=80.0f)
Definition DockTree.cpp:304
void Layout(const DockRect &workspace)
Definition DockTree.cpp:283
static void LayoutNode(DockNode &node, const DockRect &rect)
Definition DockTree.cpp:253
std::unique_ptr< DockNode > Root
Definition DockTree.h:72
DockNode * AddPanel(BaseNode *panel)
Definition DockTree.cpp:107
DockRect GetPreviewRect(const DockNode &target, DockSide side) const
Definition DockTree.cpp:288
bool Commit(const DockTransaction &transaction)
Definition DockTree.cpp:193
void Clear()
Definition DockTree.cpp:121
bool RemovePanel(BaseNode *panel)
Definition DockTree.cpp:180
void CollapseEmptyLeaf(DockNodeID leaf)
Definition DockTree.cpp:161
std::string Dump() const
Definition DockTree.cpp:358
std::unique_ptr< DockNode > CreateLeaf(BaseNode *panel=nullptr)
Definition DockTree.cpp:99
DockNodeID NextID
Definition DockTree.h:90
DockNode * Find(DockNodeID id) const
Definition DockTree.cpp:126
Definition Application.h:18
FixedSplitChild
Definition DockTree.h:26
DockSide
Definition DockTree.h:27
PanelPlacement
Definition DockTree.h:28
DockNodeType
Definition DockTree.h:23
std::uint64_t DockNodeID
Definition DockTree.h:11
SplitAxis
Definition DockTree.h:24
Definition DockTree.h:35
SplitAxis Axis
Definition DockTree.h:40
DockNode * Parent
Definition DockTree.h:38
DockNodeID ID
Definition DockTree.h:36
float SplitRatio
Definition DockTree.h:41
DockRect Rect
Definition DockTree.h:39
std::unique_ptr< DockNode > ChildA
Definition DockTree.h:45
float FixedExtent
Definition DockTree.h:42
FixedSplitChild FixedChild
Definition DockTree.h:43
bool SplitterResizable
Definition DockTree.h:44
std::unique_ptr< DockNode > ChildB
Definition DockTree.h:46
std::vector< BaseNode * > Panels
Definition DockTree.h:47
DockNodeType Type
Definition DockTree.h:37
Definition DockTree.h:14
float Width
Definition DockTree.h:17
float Left
Definition DockTree.h:15
float Height
Definition DockTree.h:18
float Top
Definition DockTree.h:16
bool Contains(float x, float y) const
Definition DockTree.cpp:95
Definition DockTree.h:51
DockRect FloatingRect
Definition DockTree.h:57
DockNodeID SourceNode
Definition DockTree.h:53
bool SplitterResizable
Definition DockTree.h:63
float FixedExtent
Definition DockTree.h:61
bool TargetFloating
Definition DockTree.h:56
BaseNode * Panel
Definition DockTree.h:52
DockNodeID TargetNode
Definition DockTree.h:54
float SplitRatio
Definition DockTree.h:59
DockSide TargetSide
Definition DockTree.h:55