载入中...
搜索中...
未找到
Layout.h
浏览该文件的文档.
1#pragma once
2
3#include "ui/UIHost.h"
4
5#include <vector>
6
7namespace eve::ui {
8
23 float basisMain = 0.f; // measured content size on main axis
24 float basisCross = 0.f; // measured content size on cross axis
25 float marginBefore = 0.f; // leading main-axis margin
26 float marginAfter = 0.f; // trailing main-axis margin
27 float marginCrossBefore = 0.f;
28 float marginCrossAfter = 0.f;
29 float flexGrow = 0.f;
30 bool isSpacer = false; // default grow = 1
31 bool absolute = false; // excluded from flex flow
32 float anchorMain = 0.f; // 0..1 anchor point inside content box
33 float anchorCross = 0.f;
34 float posMain = 0.f; // offset from the anchored edge
35 float posCross = 0.f;
36 float percentMain = 0.f; // 0..1 of available main size; overrides basis
37 float percentCross = 0.f;
38 float minMain = 0.f;
39 float maxMain = 0.f;
40 float minCross = 0.f;
41 float maxCross = 0.f;
42 float explicitMain = 0.f; // >0 overrides basisMain (fixed size)
43 float explicitCross = 0.f; // >0 overrides basisCross
45 int alignSelf = -1;
46};
47
49struct FlexRect {
50 float x = 0.f;
51 float y = 0.f;
52 float w = 0.f;
53 float h = 0.f;
54};
55
56struct FlexResult {
57 std::vector<FlexRect> items; // one per non-absolute item, same order
58 float contentW = 0.f; // total outer extent on X
59 float contentH = 0.f; // total outer extent on Y
60};
61
66FlexResult flexArrange(bool row, float gap, float availMain, float availCross,
67 FlexAlign containerAlign, FlexJustify justify,
68 const std::vector<FlexItemSpec> &items);
69
71void measureNode(UIHost::Tree &tree, int index);
72
74void measureTree(UIHost::Tree &tree);
75
77void measureFlowChildren(UIHost::Tree &tree, int firstChild, float *outW, float *outH);
78
79} // namespace eve::ui
void measureTree(UIHost::Tree &tree)
Definition Layout.cpp:348
FlexJustify
Main-axis distribution of free space in a Flex container.
Definition UIHost.h:42
void measureNode(UIHost::Tree &tree, int index)
Definition Layout.cpp:208
FlexResult flexArrange(bool row, float gap, float availMain, float availCross, FlexAlign containerAlign, FlexJustify justify, const std::vector< FlexItemSpec > &items)
Definition Layout.cpp:24
FlexAlign
Cross-axis alignment of Flex children.
Definition UIHost.h:39
void measureFlowChildren(UIHost::Tree &tree, int firstChild, float *outW, float *outH)
Definition Layout.cpp:170
WidgetDesc row(std::vector< WidgetDesc > children, std::string id)
Horizontal elastic layout row.
Definition Widget.cpp:431
float marginCrossBefore
Definition Layout.h:27
std::vector< FlexRect > items
Definition Layout.h:57