added percentage feature

This commit is contained in:
Lukas Woehrl
2016-12-11 15:58:30 +01:00
parent f36f545d75
commit 435f1f6a12
6 changed files with 501 additions and 305 deletions

5
.gitignore vendored
View File

@@ -8,3 +8,8 @@
# Visual studio code
.vscode
*.pdb
*.tlog
*.obj
*.pch
*.log

View File

@@ -15,7 +15,7 @@ static int unmanagedLogger(YGLogLevel level, const char *format, va_list args) {
int result = 0;
if (gManagedFunc) {
char buffer[256];
result = vsnprintf(buffer, sizeof(buffer), format, args);
result = vsnprintf_s(buffer, sizeof(buffer), format, args);
(*gManagedFunc)(level, buffer);
}
return result;

View File

@@ -16,6 +16,10 @@ ENUMS = {
'Inherit',
'LTR',
'RTL',
],
'Unit': [
'Pixel',
'Percent',
],
'FlexDirection': [
'Column',

View File

@@ -21,6 +21,12 @@ typedef enum YGFlexDirection {
YGFlexDirectionCount,
} YGFlexDirection;
typedef enum YGUnit {
YGUnitPixel,
YGUnitPercent,
YGUnitModeCount,
} YGUnit;
typedef enum YGMeasureMode {
YGMeasureModeUndefined,
YGMeasureModeExactly,

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,16 @@ typedef struct YGSize {
float height;
} YGSize;
typedef struct YGValue{
float value;
YGUnit unit;
bool defined;
} YGValue;
WIN_EXPORT YGValue YGPx(const float value);
WIN_EXPORT YGValue YGPercent(const float value);
typedef struct YGNode *YGNodeRef;
typedef YGSize (*YGMeasureFunc)(YGNodeRef node,
float width,
@@ -82,7 +92,8 @@ WIN_EXPORT bool YGNodeIsDirty(const YGNodeRef node);
WIN_EXPORT void YGNodePrint(const YGNodeRef node, const YGPrintOptions options);
WIN_EXPORT bool YGValueIsUndefined(const float value);
WIN_EXPORT bool YGValueIsUndefinedf(const float value);
WIN_EXPORT bool YGValueIsUndefined(const YGValue value);
WIN_EXPORT bool YGNodeCanUseCachedMeasurement(const YGMeasureMode widthMode,
const float width,
@@ -107,12 +118,24 @@ WIN_EXPORT void YGNodeCopyStyle(const YGNodeRef dstNode, const YGNodeRef srcNode
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node);
#define YG_NODE_STYLE_PROPERTY_UNIT(type, name, paramName) \
YG_NODE_STYLE_PROPERTY(float, name, paramName); \
WIN_EXPORT void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name##WithUnit(const YGNodeRef node);
#define YG_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name(const YGNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_STYLE_EDGE_PROPERTY_UNIT(type, name, paramName) \
YG_NODE_STYLE_EDGE_PROPERTY(float, name, paramName) \
WIN_EXPORT void YGNodeStyleSet##name##WithUnit(const YGNodeRef node, \
const YGEdge edge, \
const type paramName); \
WIN_EXPORT type YGNodeStyleGet##name##WithUnit(const YGNodeRef node, const YGEdge edge);
#define YG_NODE_LAYOUT_PROPERTY(type, name) \
WIN_EXPORT type YGNodeLayoutGet##name(const YGNodeRef node);
@@ -134,19 +157,19 @@ YG_NODE_STYLE_PROPERTY(YGOverflow, Overflow, overflow);
WIN_EXPORT void YGNodeStyleSetFlex(const YGNodeRef node, const float flex);
YG_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
YG_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
YG_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, FlexBasis, flexBasis);
YG_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Position, position);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Margin, margin);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Padding, padding);
YG_NODE_STYLE_EDGE_PROPERTY_UNIT(YGValue, Border, border);
YG_NODE_STYLE_PROPERTY(float, Width, width);
YG_NODE_STYLE_PROPERTY(float, Height, height);
YG_NODE_STYLE_PROPERTY(float, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY(float, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY(float, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY(float, MaxHeight, maxHeight);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Width, width);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, Height, height);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinWidth, minWidth);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MinHeight, minHeight);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxWidth, maxWidth);
YG_NODE_STYLE_PROPERTY_UNIT(YGValue, MaxHeight, maxHeight);
// Yoga specific properties, not compatible with flexbox specification
// Aspect ratio control the size of the undefined dimension of a node.