Use single function for margin, position, padding, and border
Summary: marginLeft(node, margin) -> margin(node, CSSEdgeLeft, margin) This reduces the api surface of CSSLayout as well as puts the api more in line with the java version. This also adds support for CSSEdgeAll which java has had support for for a while. This also open up the possibility of doing margin(node, CSSEdgeLeft | CSSEdgeTop, margin) in the future. Reviewed By: lucasr Differential Revision: D3715201 fbshipit-source-id: ea81ed426f0f7853bb542355c01fc16ae4360238
This commit is contained in:
committed by
Facebook Github Bot 6
parent
48e5304276
commit
a960203567
@@ -62,16 +62,6 @@ typedef struct CSSStyle {
|
||||
float flexBasis;
|
||||
float margin[6];
|
||||
float position[6];
|
||||
/**
|
||||
* You should skip all the rules that contain negative values for the
|
||||
* following attributes. For example:
|
||||
* {padding: 10, paddingLeft: -5}
|
||||
* should output:
|
||||
* {left: 10 ...}
|
||||
* the following two are incorrect:
|
||||
* {left: -5 ...}
|
||||
* {left: 0 ...}
|
||||
*/
|
||||
float padding[6];
|
||||
float border[6];
|
||||
float dimensions[2];
|
||||
|
@@ -179,6 +179,37 @@ float CSSNodeStyleGetFlex(CSSNodeRef node) {
|
||||
return node->style.instanceName; \
|
||||
}
|
||||
|
||||
#define CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(type, name, paramName, instanceName) \
|
||||
void CSSNodeStyleSet##name(CSSNodeRef node, CSSEdge edge, type paramName) { \
|
||||
switch (edge) { \
|
||||
case CSSEdgeHorizontal: \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeLeft, paramName); \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeRight, paramName); \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeStart, paramName); \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeEnd, paramName); \
|
||||
break; \
|
||||
case CSSEdgeVertical: \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeTop, paramName); \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeBottom, paramName); \
|
||||
break; \
|
||||
case CSSEdgeAll: \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeHorizontal, paramName); \
|
||||
CSSNodeStyleSet##name(node, CSSEdgeVertical, paramName); \
|
||||
break; \
|
||||
default: \
|
||||
if (node->style.instanceName[edge] != paramName) { \
|
||||
node->style.instanceName[edge] = paramName; \
|
||||
_CSSNodeMarkDirty(node); \
|
||||
} \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
type CSSNodeStyleGet##name(CSSNodeRef node, CSSEdge edge) { \
|
||||
CSS_ASSERT(edge <= CSSEdgeEnd, "Cannot get value of compound edge"); \
|
||||
return node->style.instanceName[edge]; \
|
||||
}
|
||||
|
||||
#define CSS_NODE_LAYOUT_PROPERTY_IMPL(type, name, instanceName) \
|
||||
type CSSNodeLayoutGet##name(CSSNodeRef node) { \
|
||||
return node->layout.instanceName; \
|
||||
@@ -203,33 +234,10 @@ CSS_NODE_STYLE_PROPERTY_IMPL(float, FlexGrow, flexGrow, flexGrow);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, FlexShrink, flexShrink, flexShrink);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, FlexBasis, flexBasis, flexBasis);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PositionLeft, positionLeft, position[CSSPositionLeft]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PositionTop, positionTop, position[CSSPositionTop]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PositionRight, positionRight, position[CSSPositionRight]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PositionBottom, positionBottom, position[CSSPositionBottom]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PositionStart, positionStart, position[CSSPositionStart]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PositionEnd, positionEnd, position[CSSPositionEnd]);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, MarginLeft, marginLeft, margin[CSSPositionLeft]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, MarginTop, marginTop, margin[CSSPositionTop]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, MarginRight, marginRight, margin[CSSPositionRight]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, MarginBottom, marginBottom, margin[CSSPositionBottom]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, MarginStart, marginStart, margin[CSSPositionStart]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, MarginEnd, marginEnd, margin[CSSPositionEnd]);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PaddingLeft, paddingLeft, padding[CSSPositionLeft]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PaddingTop, paddingTop, padding[CSSPositionTop]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PaddingRight, paddingRight, padding[CSSPositionRight]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PaddingBottom, paddingBottom, padding[CSSPositionBottom]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PaddingStart, paddingStart, padding[CSSPositionStart]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, PaddingEnd, paddingEnd, padding[CSSPositionEnd]);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, BorderLeft, borderLeft, border[CSSPositionLeft]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, BorderTop, borderTop, border[CSSPositionTop]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, BorderRight, borderRight, border[CSSPositionRight]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, BorderBottom, borderBottom, border[CSSPositionBottom]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, BorderStart, borderStart, border[CSSPositionStart]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, BorderEnd, BorderEnd, border[CSSPositionEnd]);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Position, position, position);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Margin, margin, margin);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Padding, padding, padding);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY_IMPL(float, Border, border, border);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, Width, width, dimensions[CSSDimensionWidth]);
|
||||
CSS_NODE_STYLE_PROPERTY_IMPL(float, Height, height, dimensions[CSSDimensionHeight]);
|
||||
|
@@ -101,6 +101,18 @@ typedef enum CSSDimension {
|
||||
CSSDimensionHeight,
|
||||
} CSSDimension;
|
||||
|
||||
typedef enum CSSEdge {
|
||||
CSSEdgeLeft,
|
||||
CSSEdgeTop,
|
||||
CSSEdgeRight,
|
||||
CSSEdgeBottom,
|
||||
CSSEdgeStart,
|
||||
CSSEdgeEnd,
|
||||
CSSEdgeHorizontal,
|
||||
CSSEdgeVertical,
|
||||
CSSEdgeAll,
|
||||
} CSSEdge;
|
||||
|
||||
typedef enum CSSPrintOptions {
|
||||
CSSPrintOptionsLayout = 1,
|
||||
CSSPrintOptionsStyle = 2,
|
||||
@@ -156,6 +168,10 @@ bool CSSValueIsUndefined(float value);
|
||||
void CSSNodeStyleSet##name(CSSNodeRef node, type paramName); \
|
||||
type CSSNodeStyleGet##name(CSSNodeRef node);
|
||||
|
||||
#define CSS_NODE_STYLE_EDGE_PROPERTY(type, name, paramName) \
|
||||
void CSSNodeStyleSet##name(CSSNodeRef node, CSSEdge edge, type paramName); \
|
||||
type CSSNodeStyleGet##name(CSSNodeRef node, CSSEdge edge);
|
||||
|
||||
#define CSS_NODE_LAYOUT_PROPERTY(type, name) type CSSNodeLayoutGet##name(CSSNodeRef node);
|
||||
|
||||
CSS_NODE_PROPERTY(void *, Context, context);
|
||||
@@ -178,33 +194,10 @@ CSS_NODE_STYLE_PROPERTY(float, FlexGrow, flexGrow);
|
||||
CSS_NODE_STYLE_PROPERTY(float, FlexShrink, flexShrink);
|
||||
CSS_NODE_STYLE_PROPERTY(float, FlexBasis, flexBasis);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(float, PositionLeft, positionLeft);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PositionTop, positionTop);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PositionRight, positionRight);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PositionBottom, positionBottom);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PositionStart, positionStart);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PositionEnd, positionEnd);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(float, MarginLeft, marginLeft);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MarginTop, marginTop);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MarginRight, marginRight);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MarginBottom, marginBottom);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MarginStart, marginStart);
|
||||
CSS_NODE_STYLE_PROPERTY(float, MarginEnd, marginEnd);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(float, PaddingLeft, paddingLeft);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PaddingTop, paddingTop);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PaddingRight, paddingRight);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PaddingBottom, paddingBottom);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PaddingStart, paddingStart);
|
||||
CSS_NODE_STYLE_PROPERTY(float, PaddingEnd, paddingEnd);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(float, BorderLeft, borderLeft);
|
||||
CSS_NODE_STYLE_PROPERTY(float, BorderTop, borderTop);
|
||||
CSS_NODE_STYLE_PROPERTY(float, BorderRight, borderRight);
|
||||
CSS_NODE_STYLE_PROPERTY(float, BorderBottom, borderBottom);
|
||||
CSS_NODE_STYLE_PROPERTY(float, BorderStart, borderStart);
|
||||
CSS_NODE_STYLE_PROPERTY(float, BorderEnd, borderEnd);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Position, position);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Margin, margin);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Padding, padding);
|
||||
CSS_NODE_STYLE_EDGE_PROPERTY(float, Border, border);
|
||||
|
||||
CSS_NODE_STYLE_PROPERTY(float, Width, width);
|
||||
CSS_NODE_STYLE_PROPERTY(float, Height, height);
|
||||
|
@@ -293,140 +293,46 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
|
||||
jni_CSSNodeStyleSetFlex(mNativePointer, flex);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetMarginLeft(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetMarginTop(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetMarginRight(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetMarginBottom(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetMarginStart(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetMarginEnd(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetMargin(int nativePointer, int edge);
|
||||
@Override
|
||||
public Spacing getMargin() {
|
||||
assertNativeInstance();
|
||||
Spacing margin = new Spacing();
|
||||
margin.set(Spacing.LEFT, jni_CSSNodeStyleGetMarginLeft(mNativePointer));
|
||||
margin.set(Spacing.TOP, jni_CSSNodeStyleGetMarginTop(mNativePointer));
|
||||
margin.set(Spacing.RIGHT, jni_CSSNodeStyleGetMarginRight(mNativePointer));
|
||||
margin.set(Spacing.BOTTOM, jni_CSSNodeStyleGetMarginBottom(mNativePointer));
|
||||
margin.set(Spacing.START, jni_CSSNodeStyleGetMarginStart(mNativePointer));
|
||||
margin.set(Spacing.END, jni_CSSNodeStyleGetMarginEnd(mNativePointer));
|
||||
margin.set(Spacing.LEFT, jni_CSSNodeStyleGetMargin(Spacing.LEFT, mNativePointer));
|
||||
margin.set(Spacing.TOP, jni_CSSNodeStyleGetMargin(Spacing.TOP, mNativePointer));
|
||||
margin.set(Spacing.RIGHT, jni_CSSNodeStyleGetMargin(Spacing.RIGHT, mNativePointer));
|
||||
margin.set(Spacing.BOTTOM, jni_CSSNodeStyleGetMargin(Spacing.BOTTOM, mNativePointer));
|
||||
margin.set(Spacing.START, jni_CSSNodeStyleGetMargin(Spacing.START, mNativePointer));
|
||||
margin.set(Spacing.END, jni_CSSNodeStyleGetMargin(Spacing.END, mNativePointer));
|
||||
return margin;
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetMarginLeft(int nativePointer, float marginLeft);
|
||||
private native void jni_CSSNodeStyleSetMarginTop(int nativePointer, float marginTop);
|
||||
private native void jni_CSSNodeStyleSetMarginRight(int nativePointer, float marginRight);
|
||||
private native void jni_CSSNodeStyleSetMarginBottom(int nativePointer, float marginBottom);
|
||||
private native void jni_CSSNodeStyleSetMarginStart(int nativePointer, float marginStart);
|
||||
private native void jni_CSSNodeStyleSetMarginEnd(int nativePointer, float marginEnd);
|
||||
private native void jni_CSSNodeStyleSetMargin(int nativePointer, int edge, float margin);
|
||||
@Override
|
||||
public void setMargin(int spacingType, float margin) {
|
||||
assertNativeInstance();
|
||||
switch (spacingType) {
|
||||
case Spacing.LEFT:
|
||||
jni_CSSNodeStyleSetMarginLeft(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.TOP:
|
||||
jni_CSSNodeStyleSetMarginTop(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.RIGHT:
|
||||
jni_CSSNodeStyleSetMarginRight(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.BOTTOM:
|
||||
jni_CSSNodeStyleSetMarginBottom(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.START:
|
||||
jni_CSSNodeStyleSetMarginStart(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.END:
|
||||
jni_CSSNodeStyleSetMarginEnd(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.HORIZONTAL:
|
||||
jni_CSSNodeStyleSetMarginLeft(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginRight(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginStart(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginEnd(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.VERTICAL:
|
||||
jni_CSSNodeStyleSetMarginTop(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginBottom(mNativePointer, margin);
|
||||
break;
|
||||
case Spacing.ALL:
|
||||
jni_CSSNodeStyleSetMarginLeft(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginRight(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginStart(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginEnd(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginTop(mNativePointer, margin);
|
||||
jni_CSSNodeStyleSetMarginBottom(mNativePointer, margin);
|
||||
break;
|
||||
}
|
||||
jni_CSSNodeStyleSetMargin(mNativePointer, spacingType, margin);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetPaddingLeft(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPaddingTop(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPaddingRight(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPaddingBottom(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPaddingStart(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPaddingEnd(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPadding(int nativePointer, int edge);
|
||||
@Override
|
||||
public Spacing getPadding() {
|
||||
assertNativeInstance();
|
||||
Spacing padding = new Spacing();
|
||||
padding.set(Spacing.LEFT, jni_CSSNodeStyleGetPaddingLeft(mNativePointer));
|
||||
padding.set(Spacing.TOP, jni_CSSNodeStyleGetPaddingTop(mNativePointer));
|
||||
padding.set(Spacing.RIGHT, jni_CSSNodeStyleGetPaddingRight(mNativePointer));
|
||||
padding.set(Spacing.BOTTOM, jni_CSSNodeStyleGetPaddingBottom(mNativePointer));
|
||||
padding.set(Spacing.START, jni_CSSNodeStyleGetPaddingStart(mNativePointer));
|
||||
padding.set(Spacing.END, jni_CSSNodeStyleGetPaddingEnd(mNativePointer));
|
||||
padding.set(Spacing.LEFT, jni_CSSNodeStyleGetPadding(Spacing.LEFT, mNativePointer));
|
||||
padding.set(Spacing.TOP, jni_CSSNodeStyleGetPadding(Spacing.TOP, mNativePointer));
|
||||
padding.set(Spacing.RIGHT, jni_CSSNodeStyleGetPadding(Spacing.RIGHT, mNativePointer));
|
||||
padding.set(Spacing.BOTTOM, jni_CSSNodeStyleGetPadding(Spacing.BOTTOM, mNativePointer));
|
||||
padding.set(Spacing.START, jni_CSSNodeStyleGetPadding(Spacing.START, mNativePointer));
|
||||
padding.set(Spacing.END, jni_CSSNodeStyleGetPadding(Spacing.END, mNativePointer));
|
||||
return padding;
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPaddingLeft(int nativePointer, float paddingLeft);
|
||||
private native void jni_CSSNodeStyleSetPaddingTop(int nativePointer, float paddingTop);
|
||||
private native void jni_CSSNodeStyleSetPaddingRight(int nativePointer, float paddingRight);
|
||||
private native void jni_CSSNodeStyleSetPaddingBottom(int nativePointer, float paddingBottom);
|
||||
private native void jni_CSSNodeStyleSetPaddingStart(int nativePointer, float paddingStart);
|
||||
private native void jni_CSSNodeStyleSetPaddingEnd(int nativePointer, float paddingEnd);
|
||||
private native void jni_CSSNodeStyleSetPadding(int nativePointer, int edge, float padding);
|
||||
@Override
|
||||
public void setPadding(int spacingType, float padding) {
|
||||
assertNativeInstance();
|
||||
switch (spacingType) {
|
||||
case Spacing.LEFT:
|
||||
jni_CSSNodeStyleSetPaddingLeft(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.TOP:
|
||||
jni_CSSNodeStyleSetPaddingTop(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.RIGHT:
|
||||
jni_CSSNodeStyleSetPaddingRight(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.BOTTOM:
|
||||
jni_CSSNodeStyleSetPaddingBottom(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.START:
|
||||
jni_CSSNodeStyleSetPaddingStart(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.END:
|
||||
jni_CSSNodeStyleSetPaddingEnd(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.HORIZONTAL:
|
||||
jni_CSSNodeStyleSetPaddingLeft(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingRight(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingStart(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingEnd(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.VERTICAL:
|
||||
jni_CSSNodeStyleSetPaddingTop(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingBottom(mNativePointer, padding);
|
||||
break;
|
||||
case Spacing.ALL:
|
||||
jni_CSSNodeStyleSetPaddingLeft(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingRight(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingStart(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingEnd(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingTop(mNativePointer, padding);
|
||||
jni_CSSNodeStyleSetPaddingBottom(mNativePointer, padding);
|
||||
break;
|
||||
}
|
||||
jni_CSSNodeStyleSetPadding(mNativePointer, spacingType, padding);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -434,138 +340,46 @@ public class CSSNodeJNI implements CSSNodeAPI<CSSNodeJNI> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetBorderLeft(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetBorderTop(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetBorderRight(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetBorderBottom(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetBorderStart(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetBorderEnd(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetBorder(int nativePointer, int edge);
|
||||
@Override
|
||||
public Spacing getBorder() {
|
||||
assertNativeInstance();
|
||||
Spacing border = new Spacing();
|
||||
border.set(Spacing.LEFT, jni_CSSNodeStyleGetBorderLeft(mNativePointer));
|
||||
border.set(Spacing.TOP, jni_CSSNodeStyleGetBorderTop(mNativePointer));
|
||||
border.set(Spacing.RIGHT, jni_CSSNodeStyleGetBorderRight(mNativePointer));
|
||||
border.set(Spacing.BOTTOM, jni_CSSNodeStyleGetBorderBottom(mNativePointer));
|
||||
border.set(Spacing.START, jni_CSSNodeStyleGetBorderStart(mNativePointer));
|
||||
border.set(Spacing.END, jni_CSSNodeStyleGetBorderEnd(mNativePointer));
|
||||
border.set(Spacing.LEFT, jni_CSSNodeStyleGetBorder(Spacing.LEFT, mNativePointer));
|
||||
border.set(Spacing.TOP, jni_CSSNodeStyleGetBorder(Spacing.TOP, mNativePointer));
|
||||
border.set(Spacing.RIGHT, jni_CSSNodeStyleGetBorder(Spacing.RIGHT, mNativePointer));
|
||||
border.set(Spacing.BOTTOM, jni_CSSNodeStyleGetBorder(Spacing.BOTTOM, mNativePointer));
|
||||
border.set(Spacing.START, jni_CSSNodeStyleGetBorder(Spacing.START, mNativePointer));
|
||||
border.set(Spacing.END, jni_CSSNodeStyleGetBorder(Spacing.END, mNativePointer));
|
||||
return border;
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetBorderLeft(int nativePointer, float borderLeft);
|
||||
private native void jni_CSSNodeStyleSetBorderTop(int nativePointer, float borderTop);
|
||||
private native void jni_CSSNodeStyleSetBorderRight(int nativePointer, float borderRight);
|
||||
private native void jni_CSSNodeStyleSetBorderBottom(int nativePointer, float borderBottom);
|
||||
private native void jni_CSSNodeStyleSetBorderStart(int nativePointer, float borderStart);
|
||||
private native void jni_CSSNodeStyleSetBorderEnd(int nativePointer, float borderEnd);
|
||||
private native void jni_CSSNodeStyleSetBorder(int nativePointer, int edge, float border);
|
||||
@Override
|
||||
public void setBorder(int spacingType, float border) {
|
||||
assertNativeInstance();
|
||||
switch (spacingType) {
|
||||
case Spacing.LEFT:
|
||||
jni_CSSNodeStyleSetBorderLeft(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.TOP:
|
||||
jni_CSSNodeStyleSetBorderTop(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.RIGHT:
|
||||
jni_CSSNodeStyleSetBorderRight(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.BOTTOM:
|
||||
jni_CSSNodeStyleSetBorderBottom(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.START:
|
||||
jni_CSSNodeStyleSetBorderStart(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.END:
|
||||
jni_CSSNodeStyleSetBorderEnd(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.HORIZONTAL:
|
||||
jni_CSSNodeStyleSetBorderLeft(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderRight(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderStart(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderEnd(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.VERTICAL:
|
||||
jni_CSSNodeStyleSetBorderTop(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderBottom(mNativePointer, border);
|
||||
break;
|
||||
case Spacing.ALL:
|
||||
jni_CSSNodeStyleSetBorderLeft(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderRight(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderStart(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderEnd(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderTop(mNativePointer, border);
|
||||
jni_CSSNodeStyleSetBorderBottom(mNativePointer, border);
|
||||
break;
|
||||
}
|
||||
jni_CSSNodeStyleSetBorder(mNativePointer, spacingType, border);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetPositionLeft(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPositionTop(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPositionRight(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPositionBottom(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPositionStart(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPositionEnd(int nativePointer);
|
||||
private native float jni_CSSNodeStyleGetPosition(int nativePointer, int edge);
|
||||
@Override
|
||||
public Spacing getPosition() {
|
||||
assertNativeInstance();
|
||||
Spacing position = new Spacing();
|
||||
position.set(Spacing.LEFT, jni_CSSNodeStyleGetPositionLeft(mNativePointer));
|
||||
position.set(Spacing.TOP, jni_CSSNodeStyleGetPositionTop(mNativePointer));
|
||||
position.set(Spacing.RIGHT, jni_CSSNodeStyleGetPositionRight(mNativePointer));
|
||||
position.set(Spacing.BOTTOM, jni_CSSNodeStyleGetPositionBottom(mNativePointer));
|
||||
position.set(Spacing.START, jni_CSSNodeStyleGetPositionStart(mNativePointer));
|
||||
position.set(Spacing.END, jni_CSSNodeStyleGetPositionEnd(mNativePointer));
|
||||
position.set(Spacing.LEFT, jni_CSSNodeStyleGetPosition(Spacing.LEFT, mNativePointer));
|
||||
position.set(Spacing.TOP, jni_CSSNodeStyleGetPosition(Spacing.TOP, mNativePointer));
|
||||
position.set(Spacing.RIGHT, jni_CSSNodeStyleGetPosition(Spacing.RIGHT, mNativePointer));
|
||||
position.set(Spacing.BOTTOM, jni_CSSNodeStyleGetPosition(Spacing.BOTTOM, mNativePointer));
|
||||
position.set(Spacing.START, jni_CSSNodeStyleGetPosition(Spacing.START, mNativePointer));
|
||||
position.set(Spacing.END, jni_CSSNodeStyleGetPosition(Spacing.END, mNativePointer));
|
||||
return position;
|
||||
}
|
||||
|
||||
private native void jni_CSSNodeStyleSetPositionLeft(int nativePointer, float position);
|
||||
private native void jni_CSSNodeStyleSetPositionTop(int nativePointer, float position);
|
||||
private native void jni_CSSNodeStyleSetPositionRight(int nativePointer, float position);
|
||||
private native void jni_CSSNodeStyleSetPositionBottom(int nativePointer, float position);
|
||||
private native void jni_CSSNodeStyleSetPositionStart(int nativePointer, float position);
|
||||
private native void jni_CSSNodeStyleSetPositionEnd(int nativePointer, float position);
|
||||
private native void jni_CSSNodeStyleSetPosition(int nativePointer, int edge, float position);
|
||||
@Override
|
||||
public void setPosition(int spacingType, float position) {
|
||||
switch (spacingType) {
|
||||
case Spacing.LEFT:
|
||||
jni_CSSNodeStyleSetPositionLeft(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.TOP:
|
||||
jni_CSSNodeStyleSetPositionTop(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.RIGHT:
|
||||
jni_CSSNodeStyleSetPositionRight(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.BOTTOM:
|
||||
jni_CSSNodeStyleSetPositionBottom(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.START:
|
||||
jni_CSSNodeStyleSetPositionStart(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.END:
|
||||
jni_CSSNodeStyleSetPositionEnd(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.HORIZONTAL:
|
||||
jni_CSSNodeStyleSetPositionLeft(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionRight(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionStart(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionEnd(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.VERTICAL:
|
||||
jni_CSSNodeStyleSetPositionTop(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionBottom(mNativePointer, position);
|
||||
break;
|
||||
case Spacing.ALL:
|
||||
jni_CSSNodeStyleSetPositionLeft(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionRight(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionStart(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionEnd(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionTop(mNativePointer, position);
|
||||
jni_CSSNodeStyleSetPositionBottom(mNativePointer, position);
|
||||
break;
|
||||
}
|
||||
assertNativeInstance();
|
||||
jni_CSSNodeStyleSetPosition(mNativePointer, spacingType, position);
|
||||
}
|
||||
|
||||
private native float jni_CSSNodeStyleGetWidth(int nativePointer);
|
||||
|
@@ -37,22 +37,22 @@ public class Spacing {
|
||||
*/
|
||||
public static final int BOTTOM = 3;
|
||||
/**
|
||||
* Spacing type that represents vertical direction (top and bottom). E.g. {@code marginVertical}.
|
||||
* Spacing type that represents start direction e.g. left in left-to-right, right in right-to-left.
|
||||
*/
|
||||
public static final int VERTICAL = 4;
|
||||
public static final int START = 4;
|
||||
/**
|
||||
* Spacing type that represents end direction e.g. right in left-to-right, left in right-to-left.
|
||||
*/
|
||||
public static final int END = 5;
|
||||
/**
|
||||
* Spacing type that represents horizontal direction (left and right). E.g.
|
||||
* {@code marginHorizontal}.
|
||||
*/
|
||||
public static final int HORIZONTAL = 5;
|
||||
public static final int HORIZONTAL = 6;
|
||||
/**
|
||||
* Spacing type that represents start direction e.g. left in left-to-right, right in right-to-left.
|
||||
* Spacing type that represents vertical direction (top and bottom). E.g. {@code marginVertical}.
|
||||
*/
|
||||
public static final int START = 6;
|
||||
/**
|
||||
* Spacing type that represents end direction e.g. right in left-to-right, left in right-to-left.
|
||||
*/
|
||||
public static final int END = 7;
|
||||
public static final int VERTICAL = 7;
|
||||
/**
|
||||
* Spacing type that represents all directions (left, top, right, bottom). E.g. {@code margin}.
|
||||
*/
|
||||
@@ -63,10 +63,10 @@ public class Spacing {
|
||||
2, /*TOP*/
|
||||
4, /*RIGHT*/
|
||||
8, /*BOTTOM*/
|
||||
16, /*VERTICAL*/
|
||||
32, /*HORIZONTAL*/
|
||||
64, /*START*/
|
||||
128, /*END*/
|
||||
16, /*START*/
|
||||
32, /*END*/
|
||||
64, /*HORIZONTAL*/
|
||||
128, /*VERTICAL*/
|
||||
256, /*ALL*/
|
||||
};
|
||||
|
||||
@@ -211,11 +211,11 @@ public class Spacing {
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
CSSConstants.UNDEFINED,
|
||||
CSSConstants.UNDEFINED,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
defaultValue,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@@ -27,6 +27,19 @@
|
||||
CSSNodeStyleSet##name((CSSNodeRef) nativePointer, (type) value); \
|
||||
})
|
||||
|
||||
#define CSS_NODE_JNI_STYLE_EDGE_PROP(javatype, type, name) \
|
||||
CSS_NODE_JNI( \
|
||||
javatype, \
|
||||
CSSNodeStyleGet##name(JNIEnv *env, jobject instance, jint nativePointer, jint edge) { \
|
||||
return (javatype) CSSNodeStyleGet##name((CSSNodeRef) nativePointer, (CSSEdge) edge); \
|
||||
}) \
|
||||
\
|
||||
CSS_NODE_JNI(void, \
|
||||
CSSNodeStyleSet##name( \
|
||||
JNIEnv *env, jobject instance, jint nativePointer, jint edge, javatype value) { \
|
||||
CSSNodeStyleSet##name((CSSNodeRef) nativePointer, (CSSEdge) edge, (type) value); \
|
||||
})
|
||||
|
||||
#define CSS_NODE_JNI_LAYOUT_PROP(javatype, type, name) \
|
||||
CSS_NODE_JNI(javatype, \
|
||||
CSSNodeLayoutGet##name(JNIEnv *env, jobject instance, jint nativePointer) { \
|
||||
@@ -174,33 +187,10 @@ CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexGrow);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexShrink);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, FlexBasis);
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MarginLeft);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MarginTop);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MarginRight);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MarginBottom);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MarginStart);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MarginEnd);
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PaddingLeft);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PaddingTop);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PaddingRight);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PaddingBottom);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PaddingStart);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PaddingEnd);
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, BorderLeft);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, BorderTop);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, BorderRight);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, BorderBottom);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, BorderStart);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, BorderEnd);
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PositionLeft);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PositionTop);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PositionRight);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PositionBottom);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PositionStart);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, PositionEnd);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Position);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Margin);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Padding);
|
||||
CSS_NODE_JNI_STYLE_EDGE_PROP(jfloat, float, Border);
|
||||
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, Width);
|
||||
CSS_NODE_JNI_STYLE_PROP(jfloat, float, MinWidth);
|
||||
|
Reference in New Issue
Block a user