Add justify-content: space-evenly

Summary:
Adds new ```space-evenly``` for ```justify-content```.

Also adds a typofix in one of the other justify-content tests.

Fixes #657
Closes https://github.com/facebook/yoga/pull/658

Differential Revision: D6407996

Pulled By: emilsjolander

fbshipit-source-id: cc837409e1345624b4bd72c31e25fe68dcb0f6a3
This commit is contained in:
Lukas Wöhrl 2017-11-27 03:40:01 -08:00 коммит произвёл Facebook Github Bot
Родитель 1d62848535
Коммит 1050e0b476
4 изменённых файлов: 19 добавлений и 8 удалений

Просмотреть файл

@ -17,7 +17,8 @@ public enum YogaJustify {
CENTER(1), CENTER(1),
FLEX_END(2), FLEX_END(2),
SPACE_BETWEEN(3), SPACE_BETWEEN(3),
SPACE_AROUND(4); SPACE_AROUND(4),
SPACE_EVENLY(5);
private int mIntValue; private int mIntValue;
@ -36,6 +37,8 @@ public enum YogaJustify {
case 2: return FLEX_END; case 2: return FLEX_END;
case 3: return SPACE_BETWEEN; case 3: return SPACE_BETWEEN;
case 4: return SPACE_AROUND; case 4: return SPACE_AROUND;
case 5:
return SPACE_EVENLY;
default: throw new IllegalArgumentException("Unknown enum value: " + value); default: throw new IllegalArgumentException("Unknown enum value: " + value);
} }
} }

Просмотреть файл

@ -121,6 +121,8 @@ const char *YGJustifyToString(const YGJustify value){
return "space-between"; return "space-between";
case YGJustifySpaceAround: case YGJustifySpaceAround:
return "space-around"; return "space-around";
case YGJustifySpaceEvenly:
return "space-evenly";
} }
return "unknown"; return "unknown";
} }

Просмотреть файл

@ -77,13 +77,14 @@ typedef YG_ENUM_BEGIN(YGFlexDirection) {
} YG_ENUM_END(YGFlexDirection); } YG_ENUM_END(YGFlexDirection);
WIN_EXPORT const char *YGFlexDirectionToString(const YGFlexDirection value); WIN_EXPORT const char *YGFlexDirectionToString(const YGFlexDirection value);
#define YGJustifyCount 5 #define YGJustifyCount 6
typedef YG_ENUM_BEGIN(YGJustify){ typedef YG_ENUM_BEGIN(YGJustify){
YGJustifyFlexStart, YGJustifyFlexStart,
YGJustifyCenter, YGJustifyCenter,
YGJustifyFlexEnd, YGJustifyFlexEnd,
YGJustifySpaceBetween, YGJustifySpaceBetween,
YGJustifySpaceAround, YGJustifySpaceAround,
YGJustifySpaceEvenly,
} YG_ENUM_END(YGJustify); } YG_ENUM_END(YGJustify);
WIN_EXPORT const char *YGJustifyToString(const YGJustify value); WIN_EXPORT const char *YGJustifyToString(const YGJustify value);

Просмотреть файл

@ -2447,6 +2447,11 @@ static void YGNodelayoutImpl(const YGNodeRef node,
betweenMainDim = 0; betweenMainDim = 0;
} }
break; break;
case YGJustifySpaceEvenly:
// Space is distributed evenly across all elements
betweenMainDim = remainingFreeSpace / (itemsOnLine + 1);
leadingMainDim = betweenMainDim;
break;
case YGJustifySpaceAround: case YGJustifySpaceAround:
// Space on the edges is half of the space between elements // Space on the edges is half of the space between elements
betweenMainDim = remainingFreeSpace / itemsOnLine; betweenMainDim = remainingFreeSpace / itemsOnLine;