Add feature to use percentage as value unit #258
5
.gitignore
vendored
@@ -8,3 +8,8 @@
|
||||
|
||||
# Visual studio code
|
||||
.vscode
|
||||
*.pdb
|
||||
|
||||
*.tlog
|
||||
*.obj
|
||||
*.pch
|
||||
*.log
|
||||
|
@@ -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;
|
||||
|
4
enums.py
@@ -16,6 +16,10 @@ ENUMS = {
|
||||
'Inherit',
|
||||
'LTR',
|
||||
![]() indentation indentation
|
||||
'RTL',
|
||||
![]() 'Unit' is still wrongly indented compared to other enums 'Unit' is still wrongly indented compared to other enums
![]() 😖 sorry, will do (all my editors are configured to use tabs instead of spaces) 😖 sorry, will do (all my editors are configured to use tabs instead of spaces)
|
||||
],
|
||||
'Unit': [
|
||||
'Pixel',
|
||||
'Percent',
|
||||
],
|
||||
'FlexDirection': [
|
||||
'Column',
|
||||
|
@@ -21,6 +21,12 @@ typedef enum YGFlexDirection {
|
||||
YGFlexDirectionCount,
|
||||
![]() YGUnitModeCount?? should be YGUnitCount probably. Did you forget to re-generate after changes? YGUnitModeCount?? should be YGUnitCount probably. Did you forget to re-generate after changes?
|
||||
} YGFlexDirection;
|
||||
|
||||
typedef enum YGUnit {
|
||||
YGUnitPixel,
|
||||
YGUnitPercent,
|
||||
YGUnitModeCount,
|
||||
} YGUnit;
|
||||
|
||||
typedef enum YGMeasureMode {
|
||||
YGMeasureModeUndefined,
|
||||
YGMeasureModeExactly,
|
||||
|
742
yoga/Yoga.c
47
yoga/Yoga.h
@@ -38,6 +38,16 @@ typedef struct YGSize {
|
||||
float height;
|
||||
![]() remove empty line remove empty line
![]() space before { (actually just run format.sh) space before { (actually just run format.sh)
![]() I would like to do this, but setting everything up on my maschine would be a huge job. As I have no linux runtime currently available, and also no clang localy. It would be greate if you could run this, after your import, if you don't mind. Same for enum.py, currently I have no python installed. If not I'll try my best to set this up locally, could take a while (the clang environment). I would like to do this, but setting everything up on my maschine would be a huge job. As I have no linux runtime currently available, and also no clang localy. It would be greate if you could run this, after your import, if you don't mind. Same for enum.py, currently I have no python installed. If not I'll try my best to set this up locally, could take a while (the clang environment).
![]() isDefined isDefined
![]() great idea! great idea!
|
||||
} 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);
|
||||
|
||||
![]() No reason to have this function as we export the No reason to have this function as we export the `defined` member of `YGValue`
|
||||
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); \
|
||||
![]() Let's remove the *WithUnit APIs and just use units everywhere. This makes the API smaller and more concise. Also it forces the user to think about units. Let's remove the *WithUnit APIs and just use units everywhere. This makes the API smaller and more concise. Also it forces the user to think about units.
![]() How should we return the units in the getter? Should I use YGValue in both get + set or use (float, YGUnitPixel) in the set and return only the float in get? How should we return the units in the getter? Should I use YGValue in both get + set or use (float, YGUnitPixel) in the set and return only the float in get?
![]() The getter should return a YGValue as well. The getter should return a YGValue as well.
|
||||
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.
|
||||
|
please mirror these changes in .hgignore