Add feature to use percentage as value unit #258

Closed
woehrl01 wants to merge 43 commits from percentage-feature into master
35 changed files with 872 additions and 1851 deletions
Showing only changes of commit 435f1f6a12 - Show all commits

5
.gitignore vendored
View File

@@ -8,3 +8,8 @@
# Visual studio code
.vscode
*.pdb
emilsjolander commented 2016-12-23 13:48:55 -08:00 (Migrated from github.com)
Review

please mirror these changes in .hgignore

please mirror these changes in .hgignore
*.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',
emilsjolander commented 2016-12-23 13:51:01 -08:00 (Migrated from github.com)
Review

indentation

indentation
'RTL',
emilsjolander commented 2016-12-23 13:57:12 -08:00 (Migrated from github.com)
Review

'Unit' is still wrongly indented compared to other enums

'Unit' is still wrongly indented compared to other enums
woehrl01 commented 2016-12-23 13:58:18 -08:00 (Migrated from github.com)
Review

😖 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',

View File

@@ -21,6 +21,12 @@ typedef enum YGFlexDirection {
YGFlexDirectionCount,
emilsjolander commented 2016-12-18 22:12:54 -08:00 (Migrated from github.com)
Review

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,

File diff suppressed because it is too large Load Diff

View File

@@ -38,6 +38,16 @@ typedef struct YGSize {
float height;
emilsjolander commented 2016-12-18 22:13:11 -08:00 (Migrated from github.com)
Review

remove empty line

remove empty line
emilsjolander commented 2016-12-18 22:13:35 -08:00 (Migrated from github.com)
Review

space before { (actually just run format.sh)

space before { (actually just run format.sh)
woehrl01 commented 2016-12-19 10:23:01 -08:00 (Migrated from github.com)
Review

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).
emilsjolander commented 2016-12-19 11:56:48 -08:00 (Migrated from github.com)
Review

isDefined

isDefined
woehrl01 commented 2016-12-19 12:09:04 -08:00 (Migrated from github.com)
Review

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);
emilsjolander commented 2016-12-18 22:16:31 -08:00 (Migrated from github.com)
Review

No reason to have this function as we export the defined member of YGValue

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); \
emilsjolander commented 2016-12-18 22:18:49 -08:00 (Migrated from github.com)
Review

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.
woehrl01 commented 2016-12-18 22:55:57 -08:00 (Migrated from github.com)
Review

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?
emilsjolander commented 2016-12-18 23:09:51 -08:00 (Migrated from github.com)
Review

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.