forked from nodegui/nodegui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnodestyle.cpp
More file actions
70 lines (55 loc) · 1.89 KB
/
nodestyle.cpp
File metadata and controls
70 lines (55 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "nodestyle.h"
std::unordered_map<std::string, int> NodeStyle::NodeAlign {
{"auto",YGAlignAuto},
{"flex-start",YGAlignFlexStart},
{"center",YGAlignCenter},
{"flex-end",YGAlignFlexEnd},
{"stretch",YGAlignStretch},
{"baseline",YGAlignBaseline},
{"space-between",YGAlignSpaceBetween},
{"space-around",YGAlignSpaceAround},
};
std::unordered_map<std::string, int> NodeStyle::NodeJustifyContent {
{"flex-start",YGJustifyFlexStart},
{"center",YGJustifyCenter},
{"flex-end",YGJustifyFlexEnd},
{"space-between",YGJustifySpaceBetween},
{"space-around",YGJustifySpaceAround},
{"space-evenly",YGJustifySpaceEvenly}
};
std::unordered_map<std::string, int> NodeStyle::NodeDirection {
{"inherit", YGDirectionInherit},
{"ltr",YGDirectionLTR},
{"rtl",YGDirectionRTL}
};
std::unordered_map<std::string, int> NodeStyle::NodeDisplay {
{"flex", YGDisplayFlex},
{"none", YGDisplayNone}
};
std::unordered_map<std::string, int> NodeStyle::NodeFlexDirection {
{"column", YGFlexDirectionColumn},
{"column-reverse", YGFlexDirectionColumnReverse},
{"row", YGFlexDirectionRow},
{"row-reverse", YGFlexDirectionRowReverse}
};
std::unordered_map<std::string, int> NodeStyle::NodeOverflow {
{"visible",YGOverflowVisible},
{"hidden",YGOverflowHidden},
{"scroll",YGOverflowScroll}
};
std::unordered_map<std::string, int> NodeStyle::NodePosition {
{"relative",YGPositionTypeRelative},
{"absolute",YGPositionTypeAbsolute},
};
std::unordered_map<std::string, int> NodeStyle::NodeWrap {
{"no-wrap",YGWrapNoWrap},
{"wrap",YGWrapWrap},
{"wrap-reverse",YGWrapWrapReverse}
};
NodeValueUnit NodeStyle::parseMeasurement(QString rawValue){
float value = std::stof(rawValue.toStdString());
if(rawValue.back() == "%"){
return NodeValueUnit(value, YGUnitPercent);
}
return NodeValueUnit(value, YGUnitPoint);
}