mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-26 11:17:04 +08:00
Move the effective* values from style to this
This commit is contained in:
@ -21,8 +21,8 @@ export class Border extends ContentView implements BorderDefinition {
|
|||||||
let heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
let heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
|
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let horizontalBorderLength = style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
let verticalBorderLength = style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
|
|
||||||
let result = View.measureChild(this, this.layoutView,
|
let result = View.measureChild(this, this.layoutView,
|
||||||
layout.makeMeasureSpec(width - horizontalBorderLength, widthMode),
|
layout.makeMeasureSpec(width - horizontalBorderLength, widthMode),
|
||||||
@ -36,9 +36,9 @@ export class Border extends ContentView implements BorderDefinition {
|
|||||||
|
|
||||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let horizontalBorderLength = style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
let horizontalBorderLength = this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
let verticalBorderLength = style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
let verticalBorderLength = this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
|
|
||||||
View.layoutChild(this, this.layoutView, style.effectiveBorderLeftWidth, style.effectiveBorderTopWidth, right - left - horizontalBorderLength, bottom - top - verticalBorderLength);
|
View.layoutChild(this, this.layoutView, this.effectiveBorderLeftWidth, this.effectiveBorderTopWidth, right - left - horizontalBorderLength, bottom - top - verticalBorderLength);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -39,11 +39,11 @@ export class Button extends ButtonBase {
|
|||||||
let result = new android.graphics.Rect();
|
let result = new android.graphics.Rect();
|
||||||
this._button.getBackground().getPadding(result);
|
this._button.getBackground().getPadding(result);
|
||||||
this._defaultNativePadding = result;
|
this._defaultNativePadding = result;
|
||||||
|
|
||||||
this.style.effectivePaddingTop = this._defaultNativePadding.top;
|
this.effectivePaddingTop = this._defaultNativePadding.top;
|
||||||
this.style.effectivePaddingRight = this._defaultNativePadding.right;
|
this.effectivePaddingRight = this._defaultNativePadding.right;
|
||||||
this.style.effectivePaddingBottom = this._defaultNativePadding.bottom;
|
this.effectivePaddingBottom = this._defaultNativePadding.bottom;
|
||||||
this.style.effectivePaddingLeft = this._defaultNativePadding.left;
|
this.effectivePaddingLeft = this._defaultNativePadding.left;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PseudoClassHandler("normal", "highlighted", "pressed", "active")
|
@PseudoClassHandler("normal", "highlighted", "pressed", "active")
|
||||||
|
@ -70,7 +70,7 @@ export class Button extends ButtonBase {
|
|||||||
set [borderTopWidthProperty.native](value: Length) {
|
set [borderTopWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let top = style.effectivePaddingTop + style.effectiveBorderTopWidth;
|
let top = this.effectivePaddingTop + this.effectiveBorderTopWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ export class Button extends ButtonBase {
|
|||||||
set [borderRightWidthProperty.native](value: Length) {
|
set [borderRightWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let right = style.effectivePaddingRight + style.effectiveBorderRightWidth;
|
let right = this.effectivePaddingRight + this.effectiveBorderRightWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ export class Button extends ButtonBase {
|
|||||||
set [borderBottomWidthProperty.native](value: Length) {
|
set [borderBottomWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let bottom = style.effectivePaddingBottom + style.effectiveBorderBottomWidth;
|
let bottom = this.effectivePaddingBottom + this.effectiveBorderBottomWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ export class Button extends ButtonBase {
|
|||||||
set [borderLeftWidthProperty.native](value: Length) {
|
set [borderLeftWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let left = style.effectivePaddingLeft + style.effectiveBorderLeftWidth;
|
let left = this.effectivePaddingLeft + this.effectiveBorderLeftWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ export class Button extends ButtonBase {
|
|||||||
set [paddingTopProperty.native](value: Length) {
|
set [paddingTopProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let top = style.effectivePaddingTop + style.effectiveBorderTopWidth;
|
let top = this.effectivePaddingTop + this.effectiveBorderTopWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.contentEdgeInsets = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +135,7 @@ export class Button extends ButtonBase {
|
|||||||
set [paddingRightProperty.native](value: Length) {
|
set [paddingRightProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let right = style.effectivePaddingRight + style.effectiveBorderRightWidth;
|
let right = this.effectivePaddingRight + this.effectiveBorderRightWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ export class Button extends ButtonBase {
|
|||||||
set [paddingBottomProperty.native](value: Length) {
|
set [paddingBottomProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let bottom = style.effectivePaddingBottom + style.effectiveBorderBottomWidth;
|
let bottom = this.effectivePaddingBottom + this.effectiveBorderBottomWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
this.nativeView.contentEdgeInsets = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ export class Button extends ButtonBase {
|
|||||||
set [paddingLeftProperty.native](value: Length) {
|
set [paddingLeftProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.contentEdgeInsets;
|
let inset = this.nativeView.contentEdgeInsets;
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let left = style.effectivePaddingLeft + style.effectiveBorderLeftWidth;
|
let left = this.effectivePaddingLeft + this.effectiveBorderLeftWidth;
|
||||||
this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.contentEdgeInsets = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,8 +78,8 @@ export class ContentView extends CustomLayoutView implements ContentViewDefiniti
|
|||||||
let heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
let heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
|
|
||||||
let style = this.style;
|
let style = this.style;
|
||||||
let measureWidth = Math.max(result.measuredWidth, style.effectiveMinWidth);
|
let measureWidth = Math.max(result.measuredWidth, this.effectiveMinWidth);
|
||||||
let measureHeight = Math.max(result.measuredHeight, style.effectiveMinHeight);
|
let measureHeight = Math.max(result.measuredHeight, this.effectiveMinHeight);
|
||||||
|
|
||||||
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
|
@ -32,23 +32,6 @@ export {
|
|||||||
// instance.set("text", propertyValue);
|
// instance.set("text", propertyValue);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
Style.prototype.effectiveMinWidth = 0;
|
|
||||||
Style.prototype.effectiveMinHeight = 0;
|
|
||||||
Style.prototype.effectiveWidth = 0;
|
|
||||||
Style.prototype.effectiveHeight = 0;
|
|
||||||
Style.prototype.effectiveMarginTop = 0;
|
|
||||||
Style.prototype.effectiveMarginRight = 0;
|
|
||||||
Style.prototype.effectiveMarginBottom = 0;
|
|
||||||
Style.prototype.effectiveMarginLeft = 0;
|
|
||||||
Style.prototype.effectivePaddingTop = 0;
|
|
||||||
Style.prototype.effectivePaddingRight = 0;
|
|
||||||
Style.prototype.effectivePaddingBottom = 0;
|
|
||||||
Style.prototype.effectivePaddingLeft = 0;
|
|
||||||
Style.prototype.effectiveBorderTopWidth = 0;
|
|
||||||
Style.prototype.effectiveBorderRightWidth = 0;
|
|
||||||
Style.prototype.effectiveBorderBottomWidth = 0;
|
|
||||||
Style.prototype.effectiveBorderLeftWidth = 0;
|
|
||||||
|
|
||||||
export function PseudoClassHandler(...pseudoClasses: string[]): MethodDecorator {
|
export function PseudoClassHandler(...pseudoClasses: string[]): MethodDecorator {
|
||||||
let stateEventNames = pseudoClasses.map(s => ":" + s);
|
let stateEventNames = pseudoClasses.map(s => ":" + s);
|
||||||
let listeners = Symbol("listeners");
|
let listeners = Symbol("listeners");
|
||||||
@ -99,6 +82,23 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
|
|
||||||
// public parent: ViewCommon;
|
// public parent: ViewCommon;
|
||||||
|
|
||||||
|
public effectiveMinWidth: number;
|
||||||
|
public effectiveMinHeight: number;
|
||||||
|
public effectiveWidth: number;
|
||||||
|
public effectiveHeight: number;
|
||||||
|
public effectiveMarginTop: number;
|
||||||
|
public effectiveMarginRight: number;
|
||||||
|
public effectiveMarginBottom: number;
|
||||||
|
public effectiveMarginLeft: number;
|
||||||
|
public effectivePaddingTop: number;
|
||||||
|
public effectivePaddingRight: number;
|
||||||
|
public effectivePaddingBottom: number;
|
||||||
|
public effectivePaddingLeft: number;
|
||||||
|
public effectiveBorderTopWidth: number;
|
||||||
|
public effectiveBorderRightWidth: number;
|
||||||
|
public effectiveBorderBottomWidth: number;
|
||||||
|
public effectiveBorderLeftWidth: number;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this._goToVisualState("normal");
|
this._goToVisualState("normal");
|
||||||
@ -584,11 +584,11 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
let childWidth = child.getMeasuredWidth();
|
let childWidth = child.getMeasuredWidth();
|
||||||
let childHeight = child.getMeasuredHeight();
|
let childHeight = child.getMeasuredHeight();
|
||||||
|
|
||||||
let effectiveMarginTop = childStyle.effectiveMarginTop;
|
let effectiveMarginTop = child.effectiveMarginTop;
|
||||||
let effectiveMarginBottom = childStyle.effectiveMarginBottom;
|
let effectiveMarginBottom = child.effectiveMarginBottom;
|
||||||
|
|
||||||
let vAlignment: VerticalAlignment;
|
let vAlignment: VerticalAlignment;
|
||||||
if (childStyle.effectiveHeight >= 0 && childStyle.verticalAlignment === VerticalAlignment.STRETCH) {
|
if (child.effectiveHeight >= 0 && childStyle.verticalAlignment === VerticalAlignment.STRETCH) {
|
||||||
vAlignment = VerticalAlignment.MIDDLE;
|
vAlignment = VerticalAlignment.MIDDLE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -615,11 +615,11 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
let effectiveMarginLeft = childStyle.effectiveMarginLeft;
|
let effectiveMarginLeft = child.effectiveMarginLeft;
|
||||||
let effectiveMarginRight = childStyle.effectiveMarginRight;
|
let effectiveMarginRight = child.effectiveMarginRight;
|
||||||
|
|
||||||
let hAlignment: HorizontalAlignment;
|
let hAlignment: HorizontalAlignment;
|
||||||
if (childStyle.effectiveWidth >= 0 && childStyle.horizontalAlignment === HorizontalAlignment.STRETCH) {
|
if (child.effectiveWidth >= 0 && childStyle.horizontalAlignment === HorizontalAlignment.STRETCH) {
|
||||||
hAlignment = HorizontalAlignment.CENTER;
|
hAlignment = HorizontalAlignment.CENTER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -673,11 +673,11 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
updateChildLayoutParams(child, parent, density);
|
updateChildLayoutParams(child, parent, density);
|
||||||
|
|
||||||
let style = child.style;
|
let style = child.style;
|
||||||
let horizontalMargins = style.effectiveMarginLeft + style.effectiveMarginRight;
|
let horizontalMargins = child.effectiveMarginLeft + child.effectiveMarginRight;
|
||||||
let verticalMargins = style.effectiveMarginTop + style.effectiveMarginRight;
|
let verticalMargins = child.effectiveMarginTop + child.effectiveMarginRight;
|
||||||
|
|
||||||
let childWidthMeasureSpec = ViewCommon.getMeasureSpec(width, widthMode, horizontalMargins, style.effectiveWidth, style.horizontalAlignment === HorizontalAlignment.STRETCH);
|
let childWidthMeasureSpec = ViewCommon.getMeasureSpec(width, widthMode, horizontalMargins, child.effectiveWidth, style.horizontalAlignment === HorizontalAlignment.STRETCH);
|
||||||
let childHeightMeasureSpec = ViewCommon.getMeasureSpec(height, heightMode, verticalMargins, style.effectiveHeight, style.verticalAlignment === VerticalAlignment.STRETCH);
|
let childHeightMeasureSpec = ViewCommon.getMeasureSpec(height, heightMode, verticalMargins, child.effectiveHeight, style.verticalAlignment === VerticalAlignment.STRETCH);
|
||||||
|
|
||||||
if (traceEnabled) {
|
if (traceEnabled) {
|
||||||
traceWrite(child.parent + " :measureChild: " + child + " " + layout.measureSpecToString(childWidthMeasureSpec) + ", " + layout.measureSpecToString(childHeightMeasureSpec), traceCategories.Layout);
|
traceWrite(child.parent + " :measureChild: " + child + " " + layout.measureSpecToString(childWidthMeasureSpec) + ", " + layout.measureSpecToString(childHeightMeasureSpec), traceCategories.Layout);
|
||||||
@ -944,6 +944,23 @@ export abstract class ViewCommon extends ViewBase implements ViewDefinition {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ViewCommon.prototype.effectiveMinWidth = 0;
|
||||||
|
ViewCommon.prototype.effectiveMinHeight = 0;
|
||||||
|
ViewCommon.prototype.effectiveWidth = 0;
|
||||||
|
ViewCommon.prototype.effectiveHeight = 0;
|
||||||
|
ViewCommon.prototype.effectiveMarginTop = 0;
|
||||||
|
ViewCommon.prototype.effectiveMarginRight = 0;
|
||||||
|
ViewCommon.prototype.effectiveMarginBottom = 0;
|
||||||
|
ViewCommon.prototype.effectiveMarginLeft = 0;
|
||||||
|
ViewCommon.prototype.effectivePaddingTop = 0;
|
||||||
|
ViewCommon.prototype.effectivePaddingRight = 0;
|
||||||
|
ViewCommon.prototype.effectivePaddingBottom = 0;
|
||||||
|
ViewCommon.prototype.effectivePaddingLeft = 0;
|
||||||
|
ViewCommon.prototype.effectiveBorderTopWidth = 0;
|
||||||
|
ViewCommon.prototype.effectiveBorderRightWidth = 0;
|
||||||
|
ViewCommon.prototype.effectiveBorderBottomWidth = 0;
|
||||||
|
ViewCommon.prototype.effectiveBorderLeftWidth = 0;
|
||||||
|
|
||||||
function updateChildLayoutParams(child: ViewCommon, parent: ViewCommon, density: number): void {
|
function updateChildLayoutParams(child: ViewCommon, parent: ViewCommon, density: number): void {
|
||||||
let style = child.style;
|
let style = child.style;
|
||||||
|
|
||||||
@ -951,17 +968,19 @@ function updateChildLayoutParams(child: ViewCommon, parent: ViewCommon, density:
|
|||||||
let parentWidthMeasureSize = layout.getMeasureSpecSize(parentWidthMeasureSpec);
|
let parentWidthMeasureSize = layout.getMeasureSpecSize(parentWidthMeasureSpec);
|
||||||
let parentWidthMeasureMode = layout.getMeasureSpecMode(parentWidthMeasureSpec);
|
let parentWidthMeasureMode = layout.getMeasureSpecMode(parentWidthMeasureSpec);
|
||||||
let parentAvailableWidth = parentWidthMeasureMode === layout.UNSPECIFIED ? -1 : parentWidthMeasureSize;
|
let parentAvailableWidth = parentWidthMeasureMode === layout.UNSPECIFIED ? -1 : parentWidthMeasureSize;
|
||||||
style.effectiveWidth = PercentLength.toDevicePixels(style.width, -2, parentAvailableWidth)
|
|
||||||
style.effectiveMarginLeft = PercentLength.toDevicePixels(style.marginLeft, 0, parentAvailableWidth);
|
child.effectiveWidth = PercentLength.toDevicePixels(style.width, -2, parentAvailableWidth)
|
||||||
style.effectiveMarginRight = PercentLength.toDevicePixels(style.marginRight, 0, parentAvailableWidth);
|
child.effectiveMarginLeft = PercentLength.toDevicePixels(style.marginLeft, 0, parentAvailableWidth);
|
||||||
|
child.effectiveMarginRight = PercentLength.toDevicePixels(style.marginRight, 0, parentAvailableWidth);
|
||||||
|
|
||||||
let parentHeightMeasureSpec = parent._currentHeightMeasureSpec;
|
let parentHeightMeasureSpec = parent._currentHeightMeasureSpec;
|
||||||
let parentHeightMeasureSize = layout.getMeasureSpecSize(parentHeightMeasureSpec);
|
let parentHeightMeasureSize = layout.getMeasureSpecSize(parentHeightMeasureSpec);
|
||||||
let parentHeightMeasureMode = layout.getMeasureSpecMode(parentHeightMeasureSpec);
|
let parentHeightMeasureMode = layout.getMeasureSpecMode(parentHeightMeasureSpec);
|
||||||
let parentAvailableHeight = parentHeightMeasureMode === layout.UNSPECIFIED ? -1 : parentHeightMeasureSize;
|
let parentAvailableHeight = parentHeightMeasureMode === layout.UNSPECIFIED ? -1 : parentHeightMeasureSize;
|
||||||
style.effectiveHeight = PercentLength.toDevicePixels(style.height, -2, parentAvailableHeight);
|
|
||||||
style.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, 0, parentAvailableHeight);
|
child.effectiveHeight = PercentLength.toDevicePixels(style.height, -2, parentAvailableHeight);
|
||||||
style.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, 0, parentAvailableHeight);
|
child.effectiveMarginTop = PercentLength.toDevicePixels(style.marginTop, 0, parentAvailableHeight);
|
||||||
|
child.effectiveMarginBottom = PercentLength.toDevicePixels(style.marginBottom, 0, parentAvailableHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
function equalsCommon(a: Length, b: Length): boolean;
|
function equalsCommon(a: Length, b: Length): boolean;
|
||||||
@ -1051,6 +1070,7 @@ export namespace PercentLength {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const equals: { (a: PercentLength, b: PercentLength): boolean } = equalsCommon;
|
export const equals: { (a: PercentLength, b: PercentLength): boolean } = equalsCommon;
|
||||||
export const toDevicePixels: { (length: PercentLength, auto: number, parentAvailableWidth: number): number } = toDevicePixelsCommon;
|
export const toDevicePixels: { (length: PercentLength, auto: number, parentAvailableWidth: number): number } = toDevicePixelsCommon;
|
||||||
}
|
}
|
||||||
@ -1134,7 +1154,9 @@ export const zeroLength: Length = { value: 0, unit: "px" };
|
|||||||
export const minWidthProperty = new CssProperty<Style, Length>({
|
export const minWidthProperty = new CssProperty<Style, Length>({
|
||||||
name: "minWidth", cssName: "min-width", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
name: "minWidth", cssName: "min-width", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
||||||
valueChanged: (target, oldValue, newValue) => {
|
valueChanged: (target, oldValue, newValue) => {
|
||||||
target.effectiveMinWidth = Length.toDevicePixels(newValue, 0);
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectiveMinWidth = Length.toDevicePixels(newValue, 0);
|
||||||
|
}
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
});
|
});
|
||||||
minWidthProperty.register(Style);
|
minWidthProperty.register(Style);
|
||||||
@ -1142,7 +1164,9 @@ minWidthProperty.register(Style);
|
|||||||
export const minHeightProperty = new CssProperty<Style, Length>({
|
export const minHeightProperty = new CssProperty<Style, Length>({
|
||||||
name: "minHeight", cssName: "min-height", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
name: "minHeight", cssName: "min-height", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
||||||
valueChanged: (target, oldValue, newValue) => {
|
valueChanged: (target, oldValue, newValue) => {
|
||||||
target.effectiveMinHeight = Length.toDevicePixels(newValue, 0);
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectiveMinHeight = Length.toDevicePixels(newValue, 0);
|
||||||
|
}
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
});
|
});
|
||||||
minHeightProperty.register(Style);
|
minHeightProperty.register(Style);
|
||||||
@ -1184,7 +1208,9 @@ paddingProperty.register(Style);
|
|||||||
export const paddingLeftProperty = new CssProperty<Style, Length>({
|
export const paddingLeftProperty = new CssProperty<Style, Length>({
|
||||||
name: "paddingLeft", cssName: "padding-left", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
name: "paddingLeft", cssName: "padding-left", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
||||||
valueChanged: (target, oldValue, newValue) => {
|
valueChanged: (target, oldValue, newValue) => {
|
||||||
target.effectivePaddingLeft = Length.toDevicePixels(newValue, 0);
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectivePaddingLeft = Length.toDevicePixels(newValue, 0);
|
||||||
|
}
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
});
|
});
|
||||||
paddingLeftProperty.register(Style);
|
paddingLeftProperty.register(Style);
|
||||||
@ -1192,7 +1218,9 @@ paddingLeftProperty.register(Style);
|
|||||||
export const paddingRightProperty = new CssProperty<Style, Length>({
|
export const paddingRightProperty = new CssProperty<Style, Length>({
|
||||||
name: "paddingRight", cssName: "padding-right", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
name: "paddingRight", cssName: "padding-right", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
||||||
valueChanged: (target, oldValue, newValue) => {
|
valueChanged: (target, oldValue, newValue) => {
|
||||||
target.effectivePaddingRight = Length.toDevicePixels(newValue, 0);
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectivePaddingRight = Length.toDevicePixels(newValue, 0);
|
||||||
|
}
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
});
|
});
|
||||||
paddingRightProperty.register(Style);
|
paddingRightProperty.register(Style);
|
||||||
@ -1200,7 +1228,9 @@ paddingRightProperty.register(Style);
|
|||||||
export const paddingTopProperty = new CssProperty<Style, Length>({
|
export const paddingTopProperty = new CssProperty<Style, Length>({
|
||||||
name: "paddingTop", cssName: "padding-top", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
name: "paddingTop", cssName: "padding-top", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
||||||
valueChanged: (target, oldValue, newValue) => {
|
valueChanged: (target, oldValue, newValue) => {
|
||||||
target.effectivePaddingTop = Length.toDevicePixels(newValue, 0);
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectivePaddingTop = Length.toDevicePixels(newValue, 0);
|
||||||
|
}
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
});
|
});
|
||||||
paddingTopProperty.register(Style);
|
paddingTopProperty.register(Style);
|
||||||
@ -1208,7 +1238,9 @@ paddingTopProperty.register(Style);
|
|||||||
export const paddingBottomProperty = new CssProperty<Style, Length>({
|
export const paddingBottomProperty = new CssProperty<Style, Length>({
|
||||||
name: "paddingBottom", cssName: "padding-bottom", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
name: "paddingBottom", cssName: "padding-bottom", defaultValue: zeroLength, affectsLayout: isIOS, equalityComparer: Length.equals,
|
||||||
valueChanged: (target, oldValue, newValue) => {
|
valueChanged: (target, oldValue, newValue) => {
|
||||||
target.effectivePaddingBottom = Length.toDevicePixels(newValue, 0);
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectivePaddingBottom = Length.toDevicePixels(newValue, 0);
|
||||||
|
}
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
});
|
});
|
||||||
paddingBottomProperty.register(Style);
|
paddingBottomProperty.register(Style);
|
||||||
@ -1684,7 +1716,9 @@ export const borderTopWidthProperty = new CssProperty<Style, Length>({
|
|||||||
if (!isNonNegativeFiniteNumber(value)) {
|
if (!isNonNegativeFiniteNumber(value)) {
|
||||||
throw new Error(`border-top-width should be Non-Negative Finite number. Value: ${value}`);
|
throw new Error(`border-top-width should be Non-Negative Finite number. Value: ${value}`);
|
||||||
}
|
}
|
||||||
target.effectiveBorderTopWidth = value;
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectiveBorderTopWidth = value;
|
||||||
|
}
|
||||||
let background = target.backgroundInternal;
|
let background = target.backgroundInternal;
|
||||||
target.backgroundInternal = background.withBorderTopWidth(value);
|
target.backgroundInternal = background.withBorderTopWidth(value);
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
@ -1698,7 +1732,9 @@ export const borderRightWidthProperty = new CssProperty<Style, Length>({
|
|||||||
if (!isNonNegativeFiniteNumber(value)) {
|
if (!isNonNegativeFiniteNumber(value)) {
|
||||||
throw new Error(`border-right-width should be Non-Negative Finite number. Value: ${value}`);
|
throw new Error(`border-right-width should be Non-Negative Finite number. Value: ${value}`);
|
||||||
}
|
}
|
||||||
target.effectiveBorderRightWidth = value;
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectiveBorderRightWidth = value;
|
||||||
|
}
|
||||||
let background = target.backgroundInternal;
|
let background = target.backgroundInternal;
|
||||||
target.backgroundInternal = background.withBorderRightWidth(value);
|
target.backgroundInternal = background.withBorderRightWidth(value);
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
@ -1712,7 +1748,9 @@ export const borderBottomWidthProperty = new CssProperty<Style, Length>({
|
|||||||
if (!isNonNegativeFiniteNumber(value)) {
|
if (!isNonNegativeFiniteNumber(value)) {
|
||||||
throw new Error(`border-bottom-width should be Non-Negative Finite number. Value: ${value}`);
|
throw new Error(`border-bottom-width should be Non-Negative Finite number. Value: ${value}`);
|
||||||
}
|
}
|
||||||
target.effectiveBorderBottomWidth = value;
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectiveBorderBottomWidth = value;
|
||||||
|
}
|
||||||
let background = target.backgroundInternal;
|
let background = target.backgroundInternal;
|
||||||
target.backgroundInternal = background.withBorderBottomWidth(value);
|
target.backgroundInternal = background.withBorderBottomWidth(value);
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
@ -1726,7 +1764,9 @@ export const borderLeftWidthProperty = new CssProperty<Style, Length>({
|
|||||||
if (!isNonNegativeFiniteNumber(value)) {
|
if (!isNonNegativeFiniteNumber(value)) {
|
||||||
throw new Error(`border-left-width should be Non-Negative Finite number. Value: ${value}`);
|
throw new Error(`border-left-width should be Non-Negative Finite number. Value: ${value}`);
|
||||||
}
|
}
|
||||||
target.effectiveBorderLeftWidth = value;
|
if (target.view instanceof ViewCommon) {
|
||||||
|
target.view.effectiveBorderLeftWidth = value;
|
||||||
|
}
|
||||||
let background = target.backgroundInternal;
|
let background = target.backgroundInternal;
|
||||||
target.backgroundInternal = background.withBorderLeftWidth(value);
|
target.backgroundInternal = background.withBorderLeftWidth(value);
|
||||||
}, valueConverter: Length.parse
|
}, valueConverter: Length.parse
|
||||||
|
38
tns-core-modules/ui/core/view.d.ts
vendored
38
tns-core-modules/ui/core/view.d.ts
vendored
@ -1,24 +1,3 @@
|
|||||||
declare module "ui/styling/style" {
|
|
||||||
interface Style {
|
|
||||||
effectiveMinWidth: number;
|
|
||||||
effectiveMinHeight: number;
|
|
||||||
effectiveWidth: number;
|
|
||||||
effectiveHeight: number;
|
|
||||||
effectiveMarginTop: number;
|
|
||||||
effectiveMarginRight: number;
|
|
||||||
effectiveMarginBottom: number;
|
|
||||||
effectiveMarginLeft: number;
|
|
||||||
effectivePaddingTop: number;
|
|
||||||
effectivePaddingRight: number;
|
|
||||||
effectivePaddingBottom: number;
|
|
||||||
effectivePaddingLeft: number;
|
|
||||||
effectiveBorderTopWidth: number;
|
|
||||||
effectiveBorderRightWidth: number;
|
|
||||||
effectiveBorderBottomWidth: number;
|
|
||||||
effectiveBorderLeftWidth: number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module "ui/core/view" {
|
declare module "ui/core/view" {
|
||||||
import { GestureTypes, GesturesObserver, GestureEventData, TouchGestureEventData, TouchAction } from "ui/gestures";
|
import { GestureTypes, GesturesObserver, GestureEventData, TouchGestureEventData, TouchAction } from "ui/gestures";
|
||||||
import { Animation, AnimationDefinition, AnimationPromise } from "ui/animation";
|
import { Animation, AnimationDefinition, AnimationPromise } from "ui/animation";
|
||||||
@ -608,6 +587,23 @@ declare module "ui/core/view" {
|
|||||||
// _onStylePropertyChanged(property: dependencyObservable.Property): void;
|
// _onStylePropertyChanged(property: dependencyObservable.Property): void;
|
||||||
//@endprivate
|
//@endprivate
|
||||||
|
|
||||||
|
public effectiveMinWidth: number;
|
||||||
|
public effectiveMinHeight: number;
|
||||||
|
public effectiveWidth: number;
|
||||||
|
public effectiveHeight: number;
|
||||||
|
public effectiveMarginTop: number;
|
||||||
|
public effectiveMarginRight: number;
|
||||||
|
public effectiveMarginBottom: number;
|
||||||
|
public effectiveMarginLeft: number;
|
||||||
|
public effectivePaddingTop: number;
|
||||||
|
public effectivePaddingRight: number;
|
||||||
|
public effectivePaddingBottom: number;
|
||||||
|
public effectivePaddingLeft: number;
|
||||||
|
public effectiveBorderTopWidth: number;
|
||||||
|
public effectiveBorderRightWidth: number;
|
||||||
|
public effectiveBorderBottomWidth: number;
|
||||||
|
public effectiveBorderLeftWidth: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* __Obsolete:__ There is a new property system that does not rely on _getValue.
|
* __Obsolete:__ There is a new property system that does not rely on _getValue.
|
||||||
*/
|
*/
|
||||||
|
@ -114,9 +114,8 @@ export class View extends ViewCommon {
|
|||||||
nativeHeight = nativeSize.height;
|
nativeHeight = nativeSize.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = this.style;
|
let measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
|
||||||
let measureWidth = Math.max(nativeWidth, style.effectiveMinWidth);
|
let measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
|
||||||
let measureHeight = Math.max(nativeHeight, style.effectiveMinHeight);
|
|
||||||
|
|
||||||
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
|
@ -48,9 +48,8 @@ export class HtmlView extends HtmlViewBase {
|
|||||||
let labelWidth = nativeSize.width;
|
let labelWidth = nativeSize.width;
|
||||||
|
|
||||||
labelWidth = Math.min(labelWidth, width);
|
labelWidth = Math.min(labelWidth, width);
|
||||||
let style = this.style;
|
let measureWidth = Math.max(labelWidth, this.effectiveMinWidth);
|
||||||
let measureWidth = Math.max(labelWidth, style.effectiveMinWidth);
|
let measureHeight = Math.max(nativeSize.height, this.effectiveMinHeight);
|
||||||
let measureHeight = Math.max(nativeSize.height, style.effectiveMinHeight);
|
|
||||||
|
|
||||||
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
|
@ -53,9 +53,8 @@ export class Image extends ImageBase {
|
|||||||
let nativeWidth = this.imageSource ? this.imageSource.width : 0;
|
let nativeWidth = this.imageSource ? this.imageSource.width : 0;
|
||||||
let nativeHeight = this.imageSource ? this.imageSource.height : 0;
|
let nativeHeight = this.imageSource ? this.imageSource.height : 0;
|
||||||
|
|
||||||
let style = this.style;
|
let measureWidth = Math.max(nativeWidth, this.effectiveMinWidth);
|
||||||
let measureWidth = Math.max(nativeWidth, style.effectiveMinWidth);
|
let measureHeight = Math.max(nativeHeight, this.effectiveMinHeight);
|
||||||
let measureHeight = Math.max(nativeHeight, style.effectiveMinHeight);
|
|
||||||
|
|
||||||
let finiteWidth: boolean = widthMode !== layout.UNSPECIFIED;
|
let finiteWidth: boolean = widthMode !== layout.UNSPECIFIED;
|
||||||
let finiteHeight: boolean = heightMode !== layout.UNSPECIFIED;
|
let finiteHeight: boolean = heightMode !== layout.UNSPECIFIED;
|
||||||
|
@ -90,9 +90,8 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
labelWidth = Math.min(labelWidth, width);
|
labelWidth = Math.min(labelWidth, width);
|
||||||
}
|
}
|
||||||
|
|
||||||
let style = this.style;
|
let measureWidth = Math.max(labelWidth, this.effectiveMinWidth);
|
||||||
let measureWidth = Math.max(labelWidth, style.effectiveMinWidth);
|
let measureHeight = Math.max(nativeSize.height, this.effectiveMinHeight);
|
||||||
let measureHeight = Math.max(nativeSize.height, style.effectiveMinHeight);
|
|
||||||
|
|
||||||
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
@ -149,7 +148,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
let nativeView = this._nativeView;
|
let nativeView = this._nativeView;
|
||||||
let border = nativeView.borderThickness;
|
let border = nativeView.borderThickness;
|
||||||
nativeView.borderThickness = {
|
nativeView.borderThickness = {
|
||||||
top: this.style.effectiveBorderTopWidth,
|
top: this.effectiveBorderTopWidth,
|
||||||
right: border.right,
|
right: border.right,
|
||||||
bottom: border.bottom,
|
bottom: border.bottom,
|
||||||
left: border.left
|
left: border.left
|
||||||
@ -164,7 +163,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
let border = nativeView.borderThickness;
|
let border = nativeView.borderThickness;
|
||||||
nativeView.borderThickness = {
|
nativeView.borderThickness = {
|
||||||
top: border.top,
|
top: border.top,
|
||||||
right: this.style.effectiveBorderRightWidth,
|
right: this.effectiveBorderRightWidth,
|
||||||
bottom: border.bottom,
|
bottom: border.bottom,
|
||||||
left: border.left
|
left: border.left
|
||||||
};
|
};
|
||||||
@ -179,7 +178,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
nativeView.borderThickness = {
|
nativeView.borderThickness = {
|
||||||
top: border.top,
|
top: border.top,
|
||||||
right: border.right,
|
right: border.right,
|
||||||
bottom: this.style.effectiveBorderBottomWidth,
|
bottom: this.effectiveBorderBottomWidth,
|
||||||
left: border.left
|
left: border.left
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -194,7 +193,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
top: border.top,
|
top: border.top,
|
||||||
right: border.right,
|
right: border.right,
|
||||||
bottom: border.bottom,
|
bottom: border.bottom,
|
||||||
left: this.style.effectiveBorderLeftWidth
|
left: this.effectiveBorderLeftWidth
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +204,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
let nativeView = this._nativeView;
|
let nativeView = this._nativeView;
|
||||||
let padding = nativeView.padding;
|
let padding = nativeView.padding;
|
||||||
nativeView.padding = {
|
nativeView.padding = {
|
||||||
top: this.style.effectivePaddingTop,
|
top: this.effectivePaddingTop,
|
||||||
right: padding.right,
|
right: padding.right,
|
||||||
bottom: padding.bottom,
|
bottom: padding.bottom,
|
||||||
left: padding.left
|
left: padding.left
|
||||||
@ -220,7 +219,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
let padding = nativeView.padding;
|
let padding = nativeView.padding;
|
||||||
nativeView.padding = {
|
nativeView.padding = {
|
||||||
top: padding.top,
|
top: padding.top,
|
||||||
right: this.style.effectivePaddingRight,
|
right: this.effectivePaddingRight,
|
||||||
bottom: padding.bottom,
|
bottom: padding.bottom,
|
||||||
left: padding.left
|
left: padding.left
|
||||||
};
|
};
|
||||||
@ -235,7 +234,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
nativeView.padding = {
|
nativeView.padding = {
|
||||||
top: padding.top,
|
top: padding.top,
|
||||||
right: padding.right,
|
right: padding.right,
|
||||||
bottom: this.style.effectivePaddingBottom,
|
bottom: this.effectivePaddingBottom,
|
||||||
left: padding.left
|
left: padding.left
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -250,7 +249,7 @@ export class Label extends TextBase implements LabelDefinition {
|
|||||||
top: padding.top,
|
top: padding.top,
|
||||||
right: padding.right,
|
right: padding.right,
|
||||||
bottom: padding.bottom,
|
bottom: padding.bottom,
|
||||||
left: this.style.effectivePaddingLeft
|
left: this.effectivePaddingLeft
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -32,13 +32,11 @@ export class AbsoluteLayout extends AbsoluteLayoutBase {
|
|||||||
measureHeight = Math.max(measureHeight, child.effectiveTop + childSize.measuredHeight);
|
measureHeight = Math.max(measureHeight, child.effectiveTop + childSize.measuredHeight);
|
||||||
});
|
});
|
||||||
|
|
||||||
const style = this.style;
|
measureWidth += this.effectiveBorderLeftWidth + this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderRightWidth;
|
||||||
|
measureHeight += this.effectiveBorderTopWidth + this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderBottomWidth;
|
||||||
|
|
||||||
measureWidth += style.effectiveBorderLeftWidth + style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderRightWidth;
|
measureWidth = Math.max(measureWidth, this.effectiveMinWidth);
|
||||||
measureHeight += style.effectiveBorderTopWidth + style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderBottomWidth;
|
measureHeight = Math.max(measureHeight, this.effectiveMinHeight);
|
||||||
|
|
||||||
measureWidth = Math.max(measureWidth, style.effectiveMinWidth);
|
|
||||||
measureHeight = Math.max(measureHeight, style.effectiveMinHeight);
|
|
||||||
|
|
||||||
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
@ -49,16 +47,15 @@ export class AbsoluteLayout extends AbsoluteLayoutBase {
|
|||||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||||
super.onLayout(left, top, right, bottom);
|
super.onLayout(left, top, right, bottom);
|
||||||
|
|
||||||
const style = this.style;
|
|
||||||
this.eachLayoutChild((child, last) => {
|
this.eachLayoutChild((child, last) => {
|
||||||
|
|
||||||
const childWidth = child.getMeasuredWidth();
|
const childWidth = child.getMeasuredWidth();
|
||||||
const childHeight = child.getMeasuredHeight();
|
const childHeight = child.getMeasuredHeight();
|
||||||
|
|
||||||
const childLeft = style.effectiveBorderLeftWidth + style.effectivePaddingLeft + child.effectiveLeft;
|
const childLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft + child.effectiveLeft;
|
||||||
const childTop = style.effectiveBorderTopWidth + style.effectivePaddingTop + child.effectiveTop;
|
const childTop = this.effectiveBorderTopWidth + this.effectivePaddingTop + child.effectiveTop;
|
||||||
const childRight = childLeft + childWidth + style.effectiveMarginLeft + style.effectiveMarginRight;
|
const childRight = childLeft + childWidth + this.effectiveMarginLeft + this.effectiveMarginRight;
|
||||||
const childBottom = childTop + childHeight + style.effectiveMarginTop + style.effectiveMarginBottom;
|
const childBottom = childTop + childHeight + this.effectiveMarginTop + this.effectiveMarginBottom;
|
||||||
|
|
||||||
View.layoutChild(this, child, childLeft, childTop, childRight, childBottom);
|
View.layoutChild(this, child, childLeft, childTop, childRight, childBottom);
|
||||||
});
|
});
|
||||||
|
@ -20,9 +20,8 @@ export class DockLayout extends DockLayoutBase {
|
|||||||
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
||||||
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
|
|
||||||
const style = this.style;
|
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
const horizontalPaddingsAndMargins = style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
const verticalPaddingsAndMargins = style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
|
||||||
|
|
||||||
let remainingWidth = widthMode === layout.UNSPECIFIED ? Number.MAX_VALUE : width - horizontalPaddingsAndMargins;
|
let remainingWidth = widthMode === layout.UNSPECIFIED ? Number.MAX_VALUE : width - horizontalPaddingsAndMargins;
|
||||||
let remainingHeight = heightMode === layout.UNSPECIFIED ? Number.MAX_VALUE : height - verticalPaddingsAndMargins;
|
let remainingHeight = heightMode === layout.UNSPECIFIED ? Number.MAX_VALUE : height - verticalPaddingsAndMargins;
|
||||||
@ -68,8 +67,8 @@ export class DockLayout extends DockLayoutBase {
|
|||||||
measureWidth += horizontalPaddingsAndMargins;
|
measureWidth += horizontalPaddingsAndMargins;
|
||||||
measureHeight += verticalPaddingsAndMargins;
|
measureHeight += verticalPaddingsAndMargins;
|
||||||
|
|
||||||
measureWidth = Math.max(measureWidth, style.effectiveMinWidth);
|
measureWidth = Math.max(measureWidth, this.effectiveMinWidth);
|
||||||
measureHeight = Math.max(measureHeight, style.effectiveMinHeight);
|
measureHeight = Math.max(measureHeight, this.effectiveMinHeight);
|
||||||
|
|
||||||
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
@ -80,12 +79,11 @@ export class DockLayout extends DockLayoutBase {
|
|||||||
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
public onLayout(left: number, top: number, right: number, bottom: number): void {
|
||||||
super.onLayout(left, top, right, bottom);
|
super.onLayout(left, top, right, bottom);
|
||||||
|
|
||||||
const style = this.style;
|
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
const horizontalPaddingsAndMargins = style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
const verticalPaddingsAndMargins = style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
|
||||||
|
|
||||||
let childLeft = style.effectiveBorderLeftWidth + style.effectivePaddingLeft;
|
let childLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
|
||||||
let childTop = style.effectiveBorderTopWidth + style.effectivePaddingTop;
|
let childTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
|
||||||
|
|
||||||
let x = childLeft;
|
let x = childLeft;
|
||||||
let y = childTop;
|
let y = childTop;
|
||||||
@ -94,10 +92,9 @@ export class DockLayout extends DockLayoutBase {
|
|||||||
let remainingHeight = Math.max(0, bottom - top - verticalPaddingsAndMargins);
|
let remainingHeight = Math.max(0, bottom - top - verticalPaddingsAndMargins);
|
||||||
|
|
||||||
this.eachLayoutChild((child, last) => {
|
this.eachLayoutChild((child, last) => {
|
||||||
let childStlye = child.style;
|
|
||||||
|
|
||||||
let childWidth = child.getMeasuredWidth() + childStlye.effectiveMarginLeft + childStlye.effectiveMarginRight;
|
let childWidth = child.getMeasuredWidth() + child.effectiveMarginLeft + child.effectiveMarginRight;
|
||||||
let childHeight = child.getMeasuredHeight() + childStlye.effectiveMarginTop + childStlye.effectiveMarginBottom;
|
let childHeight = child.getMeasuredHeight() + child.effectiveMarginTop + child.effectiveMarginBottom;
|
||||||
|
|
||||||
if (last && this.stretchLastChild) {
|
if (last && this.stretchLastChild) {
|
||||||
// Last child with stretch - give it all the space and return;
|
// Last child with stretch - give it all the space and return;
|
||||||
|
@ -181,8 +181,7 @@ export function _setAndroidLayoutParams(lp: org.nativescript.widgets.FlexboxLayo
|
|||||||
lp.flexShrink = FlexboxLayout.getFlexShrink(view);
|
lp.flexShrink = FlexboxLayout.getFlexShrink(view);
|
||||||
lp.alignSelf = alignSelfMap[FlexboxLayout.getAlignSelf(view)];
|
lp.alignSelf = alignSelfMap[FlexboxLayout.getAlignSelf(view)];
|
||||||
lp.wrapBefore = FlexboxLayout.getFlexWrapBefore(view);
|
lp.wrapBefore = FlexboxLayout.getFlexWrapBefore(view);
|
||||||
const style = view.style;
|
|
||||||
|
|
||||||
lp.minWidth = layout.toDevicePixels(style.effectiveMinWidth);
|
lp.minWidth = layout.toDevicePixels(view.effectiveMinWidth);
|
||||||
lp.minHeight = layout.toDevicePixels(style.effectiveMinHeight);
|
lp.minHeight = layout.toDevicePixels(view.effectiveMinHeight);
|
||||||
}
|
}
|
@ -263,7 +263,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let lp = child.style;
|
let lp = child; // child.style;
|
||||||
if (FlexboxLayout.getAlignSelf(child) === AlignSelf.STRETCH) {
|
if (FlexboxLayout.getAlignSelf(child) === AlignSelf.STRETCH) {
|
||||||
flexLine._indicesAlignSelfStretch.push(i);
|
flexLine._indicesAlignSelfStretch.push(i);
|
||||||
}
|
}
|
||||||
@ -330,7 +330,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
let largestHeightInLine = Number.MIN_VALUE;
|
let largestHeightInLine = Number.MIN_VALUE;
|
||||||
for (let i = viewIndex; i < viewIndex + flexLine._itemCount; i++) {
|
for (let i = viewIndex; i < viewIndex + flexLine._itemCount; i++) {
|
||||||
let child = this._getReorderedChildAt(i);
|
let child = this._getReorderedChildAt(i);
|
||||||
const lp = child.style;
|
const lp = child; // .style;
|
||||||
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
if (this.flexWrap !== FlexWrap.WRAP_REVERSE) {
|
||||||
let marginTop = flexLine._maxBaseline - FlexboxLayout.getBaseline(child);
|
let marginTop = flexLine._maxBaseline - FlexboxLayout.getBaseline(child);
|
||||||
marginTop = Math.max(marginTop, lp.effectiveMarginTop);
|
marginTop = Math.max(marginTop, lp.effectiveMarginTop);
|
||||||
@ -346,8 +346,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const style = this.style;
|
this._determineCrossSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec, this.effectivePaddingTop + this.effectivePaddingBottom);
|
||||||
this._determineCrossSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec, style.effectivePaddingTop + style.effectivePaddingBottom);
|
|
||||||
this._stretchViews(this.flexDirection, this.alignItems);
|
this._stretchViews(this.flexDirection, this.alignItems);
|
||||||
this._setMeasuredDimensionForFlex(this.flexDirection, widthMeasureSpec, heightMeasureSpec, childState);
|
this._setMeasuredDimensionForFlex(this.flexDirection, widthMeasureSpec, heightMeasureSpec, childState);
|
||||||
}
|
}
|
||||||
@ -360,9 +359,8 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
this._flexLines.length = 0;
|
this._flexLines.length = 0;
|
||||||
|
|
||||||
let childCount = this.getChildrenCount();
|
let childCount = this.getChildrenCount();
|
||||||
const style = this.style;
|
let paddingTop = this.effectivePaddingTop;
|
||||||
let paddingTop = style.effectivePaddingTop;
|
let paddingBottom = this.effectivePaddingBottom;
|
||||||
let paddingBottom = style.effectivePaddingBottom;
|
|
||||||
let largestWidthInColumn = Number.MIN_VALUE;
|
let largestWidthInColumn = Number.MIN_VALUE;
|
||||||
let flexLine = new FlexLine();
|
let flexLine = new FlexLine();
|
||||||
flexLine._mainSize = paddingTop + paddingBottom;
|
flexLine._mainSize = paddingTop + paddingBottom;
|
||||||
@ -379,7 +377,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lp = child.style;
|
const lp = child; // .style;
|
||||||
if (FlexboxLayout.getAlignSelf(child) === AlignSelf.STRETCH) {
|
if (FlexboxLayout.getAlignSelf(child) === AlignSelf.STRETCH) {
|
||||||
flexLine._indicesAlignSelfStretch.push(i);
|
flexLine._indicesAlignSelfStretch.push(i);
|
||||||
}
|
}
|
||||||
@ -391,10 +389,10 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let childWidthMeasureSpec = FlexboxLayout.getChildMeasureSpec(widthMeasureSpec,
|
let childWidthMeasureSpec = FlexboxLayout.getChildMeasureSpec(widthMeasureSpec,
|
||||||
style.effectivePaddingLeft + style.effectivePaddingRight + lp.effectiveMarginLeft
|
this.effectivePaddingLeft + this.effectivePaddingRight + lp.effectiveMarginLeft
|
||||||
+ lp.effectiveMarginRight, lp.effectiveWidth < 0 ? WRAP_CONTENT : lp.effectiveWidth);
|
+ lp.effectiveMarginRight, lp.effectiveWidth < 0 ? WRAP_CONTENT : lp.effectiveWidth);
|
||||||
let childHeightMeasureSpec = FlexboxLayout.getChildMeasureSpec(heightMeasureSpec,
|
let childHeightMeasureSpec = FlexboxLayout.getChildMeasureSpec(heightMeasureSpec,
|
||||||
style.effectivePaddingTop + style.effectivePaddingBottom + lp.effectiveMarginTop
|
this.effectivePaddingTop + this.effectivePaddingBottom + lp.effectiveMarginTop
|
||||||
+ lp.effectiveMarginBottom, childHeight < 0 ? WRAP_CONTENT : childHeight);
|
+ lp.effectiveMarginBottom, childHeight < 0 ? WRAP_CONTENT : childHeight);
|
||||||
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
child.measure(childWidthMeasureSpec, childHeightMeasureSpec);
|
||||||
|
|
||||||
@ -433,7 +431,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this._determineMainSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec);
|
this._determineMainSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec);
|
||||||
this._determineCrossSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec, style.effectivePaddingLeft + style.effectivePaddingRight);
|
this._determineCrossSize(this.flexDirection, widthMeasureSpec, heightMeasureSpec, this.effectivePaddingLeft + this.effectivePaddingRight);
|
||||||
this._stretchViews(this.flexDirection, this.alignItems);
|
this._stretchViews(this.flexDirection, this.alignItems);
|
||||||
this._setMeasuredDimensionForFlex(this.flexDirection, widthMeasureSpec, heightMeasureSpec, childState);
|
this._setMeasuredDimensionForFlex(this.flexDirection, widthMeasureSpec, heightMeasureSpec, childState);
|
||||||
}
|
}
|
||||||
@ -443,8 +441,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
let childWidth = view.getMeasuredWidth();
|
let childWidth = view.getMeasuredWidth();
|
||||||
let childHeight = view.getMeasuredHeight();
|
let childHeight = view.getMeasuredHeight();
|
||||||
|
|
||||||
const style = view.style;
|
let minWidth = view.effectiveMinWidth;
|
||||||
let minWidth = style.effectiveMinWidth;
|
|
||||||
if (view.getMeasuredWidth() < minWidth) {
|
if (view.getMeasuredWidth() < minWidth) {
|
||||||
needsMeasure = true;
|
needsMeasure = true;
|
||||||
childWidth = minWidth;
|
childWidth = minWidth;
|
||||||
@ -453,7 +450,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
childWidth = MAX_SIZE /*lp.maxWidth*/;
|
childWidth = MAX_SIZE /*lp.maxWidth*/;
|
||||||
}
|
}
|
||||||
|
|
||||||
let minHeight = style.effectiveMinHeight;
|
let minHeight = view.effectiveMinHeight;
|
||||||
if (childHeight < minHeight) {
|
if (childHeight < minHeight) {
|
||||||
needsMeasure = true;
|
needsMeasure = true;
|
||||||
childHeight = minHeight;
|
childHeight = minHeight;
|
||||||
@ -480,7 +477,6 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
private _determineMainSize(flexDirection: FlexDirection, widthMeasureSpec: number, heightMeasureSpec: number) {
|
private _determineMainSize(flexDirection: FlexDirection, widthMeasureSpec: number, heightMeasureSpec: number) {
|
||||||
let mainSize: number;
|
let mainSize: number;
|
||||||
let paddingAlongMainAxis: number;
|
let paddingAlongMainAxis: number;
|
||||||
const style = this.style;
|
|
||||||
|
|
||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case FlexDirection.ROW:
|
case FlexDirection.ROW:
|
||||||
@ -492,7 +488,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
} else {
|
} else {
|
||||||
mainSize = this._getLargestMainSize();
|
mainSize = this._getLargestMainSize();
|
||||||
}
|
}
|
||||||
paddingAlongMainAxis = style.effectivePaddingLeft + style.effectivePaddingRight;
|
paddingAlongMainAxis = this.effectivePaddingLeft + this.effectivePaddingRight;
|
||||||
break;
|
break;
|
||||||
case FlexDirection.COLUMN:
|
case FlexDirection.COLUMN:
|
||||||
case FlexDirection.COLUMN_REVERSE:
|
case FlexDirection.COLUMN_REVERSE:
|
||||||
@ -503,7 +499,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
} else {
|
} else {
|
||||||
mainSize = this._getLargestMainSize();
|
mainSize = this._getLargestMainSize();
|
||||||
}
|
}
|
||||||
paddingAlongMainAxis = style.effectivePaddingTop + style.effectivePaddingBottom;
|
paddingAlongMainAxis = this.effectivePaddingTop + this.effectivePaddingBottom;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid flex direction: " + flexDirection);
|
throw new Error("Invalid flex direction: " + flexDirection);
|
||||||
@ -539,7 +535,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
childIndex++;
|
childIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const lp = child.style;
|
const lp = child; // .style;
|
||||||
if (this._isMainAxisDirectionHorizontal(flexDirection)) {
|
if (this._isMainAxisDirectionHorizontal(flexDirection)) {
|
||||||
if (!this._childrenFrozen[childIndex]) {
|
if (!this._childrenFrozen[childIndex]) {
|
||||||
let flexGrow = FlexboxLayout.getFlexGrow(child);
|
let flexGrow = FlexboxLayout.getFlexGrow(child);
|
||||||
@ -603,14 +599,14 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
childIndex++;
|
childIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const lp = child.style;
|
const lp = child; // .style;
|
||||||
if (this._isMainAxisDirectionHorizontal(flexDirection)) {
|
if (this._isMainAxisDirectionHorizontal(flexDirection)) {
|
||||||
// The direction of main axis is horizontal
|
// The direction of main axis is horizontal
|
||||||
if (!this._childrenFrozen[childIndex]) {
|
if (!this._childrenFrozen[childIndex]) {
|
||||||
let flexShrink = FlexboxLayout.getFlexShrink(child);
|
let flexShrink = FlexboxLayout.getFlexShrink(child);
|
||||||
let rawCalculatedWidth = child.getMeasuredWidth() - unitShrink * flexShrink + accumulatedRoundError;
|
let rawCalculatedWidth = child.getMeasuredWidth() - unitShrink * flexShrink + accumulatedRoundError;
|
||||||
let roundedCalculatedWidth = Math.round(rawCalculatedWidth);
|
let roundedCalculatedWidth = Math.round(rawCalculatedWidth);
|
||||||
let minWidth = child.style.effectiveMinWidth;
|
let minWidth = child.effectiveMinWidth;
|
||||||
if (roundedCalculatedWidth < minWidth) {
|
if (roundedCalculatedWidth < minWidth) {
|
||||||
needsReshrink = true;
|
needsReshrink = true;
|
||||||
roundedCalculatedWidth = minWidth;
|
roundedCalculatedWidth = minWidth;
|
||||||
@ -627,7 +623,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
let flexShrink = FlexboxLayout.getFlexShrink(child);
|
let flexShrink = FlexboxLayout.getFlexShrink(child);
|
||||||
let rawCalculatedHeight = child.getMeasuredHeight() - unitShrink * flexShrink + accumulatedRoundError;
|
let rawCalculatedHeight = child.getMeasuredHeight() - unitShrink * flexShrink + accumulatedRoundError;
|
||||||
let roundedCalculatedHeight = Math.round(rawCalculatedHeight);
|
let roundedCalculatedHeight = Math.round(rawCalculatedHeight);
|
||||||
const minHeight = child.style.effectiveMinHeight;
|
const minHeight = child.effectiveMinHeight;
|
||||||
if (roundedCalculatedHeight < minHeight) {
|
if (roundedCalculatedHeight < minHeight) {
|
||||||
needsReshrink = true;
|
needsReshrink = true;
|
||||||
roundedCalculatedHeight = minHeight;
|
roundedCalculatedHeight = minHeight;
|
||||||
@ -822,21 +818,18 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _stretchViewVertically(view: View, crossSize: number) {
|
private _stretchViewVertically(view: View, crossSize: number) {
|
||||||
let lp = view.style;
|
let newHeight = crossSize - view.effectiveMarginTop - view.effectiveMarginBottom;
|
||||||
let newHeight = crossSize - lp.effectiveMarginTop - lp.effectiveMarginBottom;
|
|
||||||
newHeight = Math.max(newHeight, 0);
|
newHeight = Math.max(newHeight, 0);
|
||||||
view.measure(makeMeasureSpec(view.getMeasuredWidth(), EXACTLY), makeMeasureSpec(newHeight, EXACTLY));
|
view.measure(makeMeasureSpec(view.getMeasuredWidth(), EXACTLY), makeMeasureSpec(newHeight, EXACTLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _stretchViewHorizontally(view: View, crossSize: number) {
|
private _stretchViewHorizontally(view: View, crossSize: number) {
|
||||||
let lp = view.style;
|
let newWidth = crossSize - view.effectiveMarginLeft - view.effectiveMarginRight;
|
||||||
let newWidth = crossSize - lp.effectiveMarginLeft - lp.effectiveMarginRight;
|
|
||||||
newWidth = Math.max(newWidth, 0);
|
newWidth = Math.max(newWidth, 0);
|
||||||
view.measure(makeMeasureSpec(newWidth, EXACTLY), makeMeasureSpec(view.getMeasuredHeight(), EXACTLY));
|
view.measure(makeMeasureSpec(newWidth, EXACTLY), makeMeasureSpec(view.getMeasuredHeight(), EXACTLY));
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setMeasuredDimensionForFlex(flexDirection: FlexDirection, widthMeasureSpec: number, heightMeasureSpec: number, childState: number) {
|
private _setMeasuredDimensionForFlex(flexDirection: FlexDirection, widthMeasureSpec: number, heightMeasureSpec: number, childState: number) {
|
||||||
const style = this.style;
|
|
||||||
let widthMode = getMeasureSpecMode(widthMeasureSpec);
|
let widthMode = getMeasureSpecMode(widthMeasureSpec);
|
||||||
let widthSize = getMeasureSpecSize(widthMeasureSpec);
|
let widthSize = getMeasureSpecSize(widthMeasureSpec);
|
||||||
let heightMode = getMeasureSpecMode(heightMeasureSpec);
|
let heightMode = getMeasureSpecMode(heightMeasureSpec);
|
||||||
@ -846,13 +839,13 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
switch (flexDirection) {
|
switch (flexDirection) {
|
||||||
case FlexDirection.ROW:
|
case FlexDirection.ROW:
|
||||||
case FlexDirection.ROW_REVERSE:
|
case FlexDirection.ROW_REVERSE:
|
||||||
calculatedMaxHeight = this._getSumOfCrossSize() + style.effectivePaddingTop + style.effectivePaddingBottom;
|
calculatedMaxHeight = this._getSumOfCrossSize() + this.effectivePaddingTop + this.effectivePaddingBottom;
|
||||||
calculatedMaxWidth = this._getLargestMainSize();
|
calculatedMaxWidth = this._getLargestMainSize();
|
||||||
break;
|
break;
|
||||||
case FlexDirection.COLUMN:
|
case FlexDirection.COLUMN:
|
||||||
case FlexDirection.COLUMN_REVERSE:
|
case FlexDirection.COLUMN_REVERSE:
|
||||||
calculatedMaxHeight = this._getLargestMainSize();
|
calculatedMaxHeight = this._getLargestMainSize();
|
||||||
calculatedMaxWidth = this._getSumOfCrossSize() + style.effectivePaddingLeft + style.effectivePaddingRight;
|
calculatedMaxWidth = this._getSumOfCrossSize() + this.effectivePaddingLeft + this.effectivePaddingRight;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new Error("Invalid flex direction: " + flexDirection);
|
throw new Error("Invalid flex direction: " + flexDirection);
|
||||||
@ -970,9 +963,8 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _layoutHorizontal(isRtl: boolean, left: number, top: number, right: number, bottom: number) {
|
private _layoutHorizontal(isRtl: boolean, left: number, top: number, right: number, bottom: number) {
|
||||||
const style = this.style;
|
let paddingLeft = this.effectivePaddingLeft;
|
||||||
let paddingLeft = style.effectivePaddingLeft;
|
let paddingRight = this.effectivePaddingRight;
|
||||||
let paddingRight = style.effectivePaddingRight;
|
|
||||||
|
|
||||||
let childLeft;
|
let childLeft;
|
||||||
let currentViewIndex = 0;
|
let currentViewIndex = 0;
|
||||||
@ -980,8 +972,8 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
let height = bottom - top;
|
let height = bottom - top;
|
||||||
let width = right - left;
|
let width = right - left;
|
||||||
|
|
||||||
let childBottom = height - style.effectivePaddingBottom;
|
let childBottom = height - this.effectivePaddingBottom;
|
||||||
let childTop = style.effectivePaddingTop;
|
let childTop = this.effectivePaddingTop;
|
||||||
|
|
||||||
let childRight;
|
let childRight;
|
||||||
this._flexLines.forEach((flexLine, i) => {
|
this._flexLines.forEach((flexLine, i) => {
|
||||||
@ -1028,7 +1020,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
currentViewIndex++;
|
currentViewIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const lp = child.style;
|
const lp = child; // .style;
|
||||||
childLeft += lp.effectiveMarginLeft;
|
childLeft += lp.effectiveMarginLeft;
|
||||||
childRight -= lp.effectiveMarginRight;
|
childRight -= lp.effectiveMarginRight;
|
||||||
|
|
||||||
@ -1075,7 +1067,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _layoutSingleChildHorizontal(view: View, flexLine: FlexLine, flexWrap: FlexWrap, alignItems: AlignItems, left: number, top: number, right: number, bottom: number): void {
|
private _layoutSingleChildHorizontal(view: View, flexLine: FlexLine, flexWrap: FlexWrap, alignItems: AlignItems, left: number, top: number, right: number, bottom: number): void {
|
||||||
let lp = view.style;
|
let lp = view; // .style;
|
||||||
|
|
||||||
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
||||||
if (alignSelf !== AlignSelf.AUTO) {
|
if (alignSelf !== AlignSelf.AUTO) {
|
||||||
@ -1129,12 +1121,11 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _layoutVertical(isRtl: boolean, fromBottomToTop: boolean, left: number, top: number, right: number, bottom: number) {
|
private _layoutVertical(isRtl: boolean, fromBottomToTop: boolean, left: number, top: number, right: number, bottom: number) {
|
||||||
const style = this.style;
|
let paddingTop = this.effectivePaddingTop;
|
||||||
let paddingTop = style.effectivePaddingTop;
|
let paddingBottom = this.effectivePaddingBottom;
|
||||||
let paddingBottom = style.effectivePaddingBottom;
|
|
||||||
|
|
||||||
let paddingRight = style.effectivePaddingRight;
|
let paddingRight = this.effectivePaddingRight;
|
||||||
let childLeft = style.effectivePaddingLeft;
|
let childLeft = this.effectivePaddingLeft;
|
||||||
let currentViewIndex = 0;
|
let currentViewIndex = 0;
|
||||||
|
|
||||||
let width = right - left;
|
let width = right - left;
|
||||||
@ -1189,7 +1180,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
currentViewIndex++;
|
currentViewIndex++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const lp = child.style;
|
const lp = child; // .style;
|
||||||
childTop += lp.effectiveMarginTop;
|
childTop += lp.effectiveMarginTop;
|
||||||
childBottom -= lp.effectiveMarginBottom;
|
childBottom -= lp.effectiveMarginBottom;
|
||||||
|
|
||||||
@ -1235,7 +1226,7 @@ export class FlexboxLayout extends FlexboxLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private _layoutSingleChildVertical(view: View, flexLine: FlexLine, isRtl: boolean, alignItems: AlignItems, left: number, top: number, right: number, bottom: number) {
|
private _layoutSingleChildVertical(view: View, flexLine: FlexLine, isRtl: boolean, alignItems: AlignItems, left: number, top: number, right: number, bottom: number) {
|
||||||
let lp = view.style;
|
let lp = view; // .style;
|
||||||
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
let alignSelf = FlexboxLayout.getAlignSelf(view);
|
||||||
if (alignSelf !== AlignSelf.AUTO) {
|
if (alignSelf !== AlignSelf.AUTO) {
|
||||||
alignItems = alignSelf;
|
alignItems = alignSelf;
|
||||||
@ -1345,10 +1336,10 @@ export namespace FlexboxLayout {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getPaddingStart(child: View): number {
|
export function getPaddingStart(child: View): number {
|
||||||
return child.style.effectivePaddingLeft;
|
return child.effectivePaddingLeft;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getPaddingEnd(child: View): number {
|
export function getPaddingEnd(child: View): number {
|
||||||
return child.style.effectivePaddingRight;
|
return child.effectivePaddingRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -111,9 +111,8 @@ export class GridLayout extends GridLayoutBase {
|
|||||||
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
||||||
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
|
|
||||||
const style = this.style;
|
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
const horizontalPaddingsAndMargins = style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
const verticalPaddingsAndMargins = style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
|
||||||
|
|
||||||
let infinityWidth = widthMode === layout.UNSPECIFIED;
|
let infinityWidth = widthMode === layout.UNSPECIFIED;
|
||||||
let infinityHeight = heightMode === layout.UNSPECIFIED;
|
let infinityHeight = heightMode === layout.UNSPECIFIED;
|
||||||
@ -143,8 +142,8 @@ export class GridLayout extends GridLayoutBase {
|
|||||||
measureHeight = this.helper.measuredHeight + verticalPaddingsAndMargins;
|
measureHeight = this.helper.measuredHeight + verticalPaddingsAndMargins;
|
||||||
|
|
||||||
// Check against our minimum sizes
|
// Check against our minimum sizes
|
||||||
measureWidth = Math.max(measureWidth, style.effectiveMinWidth);
|
measureWidth = Math.max(measureWidth, this.effectiveMinWidth);
|
||||||
measureHeight = Math.max(measureHeight, style.effectiveMinHeight);
|
measureHeight = Math.max(measureHeight, this.effectiveMinHeight);
|
||||||
|
|
||||||
const widthSizeAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
const widthSizeAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
const heightSizeAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
const heightSizeAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
@ -157,8 +156,8 @@ export class GridLayout extends GridLayoutBase {
|
|||||||
|
|
||||||
const style = this.style;
|
const style = this.style;
|
||||||
|
|
||||||
let paddingLeft = style.effectiveBorderLeftWidth + style.effectivePaddingLeft;
|
let paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
|
||||||
let paddingTop = style.effectiveBorderTopWidth + style.effectivePaddingTop;
|
let paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
|
||||||
|
|
||||||
this.columnOffsets.length = 0;
|
this.columnOffsets.length = 0;
|
||||||
this.rowOffsets.length = 0;
|
this.rowOffsets.length = 0;
|
||||||
|
@ -18,9 +18,8 @@ export class StackLayout extends StackLayoutBase {
|
|||||||
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
|
|
||||||
const isVertical = this.orientation === "vertical";
|
const isVertical = this.orientation === "vertical";
|
||||||
const style = this.style;
|
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
const horizontalPaddingsAndMargins = style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
const verticalPaddingsAndMargins = style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
|
||||||
|
|
||||||
let measureSpec: number;
|
let measureSpec: number;
|
||||||
|
|
||||||
@ -71,8 +70,8 @@ export class StackLayout extends StackLayoutBase {
|
|||||||
measureHeight += verticalPaddingsAndMargins;
|
measureHeight += verticalPaddingsAndMargins;
|
||||||
|
|
||||||
// Check against our minimum sizes
|
// Check against our minimum sizes
|
||||||
measureWidth = Math.max(measureWidth, style.effectiveMinWidth);
|
measureWidth = Math.max(measureWidth, this.effectiveMinWidth);
|
||||||
measureHeight = Math.max(measureHeight, style.effectiveMinHeight);
|
measureHeight = Math.max(measureHeight, this.effectiveMinHeight);
|
||||||
|
|
||||||
this._totalLength = isVertical ? measureHeight : measureWidth;
|
this._totalLength = isVertical ? measureHeight : measureWidth;
|
||||||
|
|
||||||
@ -93,11 +92,10 @@ export class StackLayout extends StackLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private layoutVertical(left: number, top: number, right: number, bottom: number): void {
|
private layoutVertical(left: number, top: number, right: number, bottom: number): void {
|
||||||
const style = this.style;
|
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
|
||||||
const paddingLeft = style.effectiveBorderLeftWidth + style.effectivePaddingLeft;
|
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
|
||||||
const paddingTop = style.effectiveBorderTopWidth + style.effectivePaddingTop;
|
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight;
|
||||||
const paddingRight = style.effectiveBorderRightWidth + style.effectivePaddingRight;
|
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom;
|
||||||
const paddingBottom = style.effectiveBorderBottomWidth + style.effectivePaddingBottom;
|
|
||||||
|
|
||||||
let childTop: number;
|
let childTop: number;
|
||||||
let childLeft: number = paddingLeft;
|
let childLeft: number = paddingLeft;
|
||||||
@ -120,8 +118,7 @@ export class StackLayout extends StackLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.eachLayoutChild((child, last) => {
|
this.eachLayoutChild((child, last) => {
|
||||||
const childStyle = child.style;
|
const childHeight = child.getMeasuredHeight() + child.effectiveMarginTop + child.effectiveMarginBottom;
|
||||||
const childHeight = child.getMeasuredHeight() + childStyle.effectiveMarginTop + childStyle.effectiveMarginBottom;
|
|
||||||
|
|
||||||
View.layoutChild(this, child, childLeft, childTop, childRight, childTop + childHeight);
|
View.layoutChild(this, child, childLeft, childTop, childRight, childTop + childHeight);
|
||||||
childTop += childHeight;
|
childTop += childHeight;
|
||||||
@ -129,11 +126,10 @@ export class StackLayout extends StackLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private layoutHorizontal(left: number, top: number, right: number, bottom: number): void {
|
private layoutHorizontal(left: number, top: number, right: number, bottom: number): void {
|
||||||
const style = this.style;
|
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
|
||||||
const paddingLeft = style.effectiveBorderLeftWidth + style.effectivePaddingLeft;
|
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
|
||||||
const paddingTop = style.effectiveBorderTopWidth + style.effectivePaddingTop;
|
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight;
|
||||||
const paddingRight = style.effectiveBorderRightWidth + style.effectivePaddingRight;
|
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom;
|
||||||
const paddingBottom = style.effectiveBorderBottomWidth + style.effectivePaddingBottom;
|
|
||||||
|
|
||||||
let childTop: number = paddingTop;
|
let childTop: number = paddingTop;
|
||||||
let childLeft: number;
|
let childLeft: number;
|
||||||
@ -156,8 +152,7 @@ export class StackLayout extends StackLayoutBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.eachLayoutChild((child, last) => {
|
this.eachLayoutChild((child, last) => {
|
||||||
const childStyle = child.style;
|
const childWidth = child.getMeasuredWidth() + child.effectiveMarginLeft + child.effectiveMarginRight;
|
||||||
const childWidth = child.getMeasuredWidth() + childStyle.effectiveMarginLeft + childStyle.effectiveMarginRight;
|
|
||||||
|
|
||||||
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childBottom);
|
View.layoutChild(this, child, childLeft, childTop, childLeft + childWidth, childBottom);
|
||||||
childLeft += childWidth;
|
childLeft += childWidth;
|
||||||
|
@ -29,9 +29,8 @@ export class WrapLayout extends WrapLayoutBase {
|
|||||||
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
const height = layout.getMeasureSpecSize(heightMeasureSpec);
|
||||||
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
const heightMode = layout.getMeasureSpecMode(heightMeasureSpec);
|
||||||
|
|
||||||
const style = this.style;
|
const horizontalPaddingsAndMargins = this.effectivePaddingLeft + this.effectivePaddingRight + this.effectiveBorderLeftWidth + this.effectiveBorderRightWidth;
|
||||||
const horizontalPaddingsAndMargins = style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderLeftWidth + style.effectiveBorderRightWidth;
|
const verticalPaddingsAndMargins = this.effectivePaddingTop + this.effectivePaddingBottom + this.effectiveBorderTopWidth + this.effectiveBorderBottomWidth;
|
||||||
const verticalPaddingsAndMargins = style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderTopWidth + style.effectiveBorderBottomWidth;
|
|
||||||
|
|
||||||
const availableWidth = widthMode === layout.UNSPECIFIED ? Number.MAX_VALUE : width - horizontalPaddingsAndMargins;
|
const availableWidth = widthMode === layout.UNSPECIFIED ? Number.MAX_VALUE : width - horizontalPaddingsAndMargins;
|
||||||
const availableHeight = heightMode === layout.UNSPECIFIED ? Number.MAX_VALUE : height - verticalPaddingsAndMargins;
|
const availableHeight = heightMode === layout.UNSPECIFIED ? Number.MAX_VALUE : height - verticalPaddingsAndMargins;
|
||||||
@ -111,8 +110,8 @@ export class WrapLayout extends WrapLayoutBase {
|
|||||||
measureHeight += verticalPaddingsAndMargins;
|
measureHeight += verticalPaddingsAndMargins;
|
||||||
|
|
||||||
// Check against our minimum sizes
|
// Check against our minimum sizes
|
||||||
measureWidth = Math.max(measureWidth, style.effectiveMinWidth);
|
measureWidth = Math.max(measureWidth, this.effectiveMinWidth);
|
||||||
measureHeight = Math.max(measureHeight, style.effectiveMinHeight);
|
measureHeight = Math.max(measureHeight, this.effectiveMinHeight);
|
||||||
|
|
||||||
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
@ -124,11 +123,10 @@ export class WrapLayout extends WrapLayoutBase {
|
|||||||
super.onLayout(left, top, right, bottom);
|
super.onLayout(left, top, right, bottom);
|
||||||
|
|
||||||
const isVertical = this.orientation === "vertical";
|
const isVertical = this.orientation === "vertical";
|
||||||
const style = this.style;
|
const paddingLeft = this.effectiveBorderLeftWidth + this.effectivePaddingLeft;
|
||||||
const paddingLeft = style.effectiveBorderLeftWidth + style.effectivePaddingLeft;
|
const paddingTop = this.effectiveBorderTopWidth + this.effectivePaddingTop;
|
||||||
const paddingTop = style.effectiveBorderTopWidth + style.effectivePaddingTop;
|
const paddingRight = this.effectiveBorderRightWidth + this.effectivePaddingRight;
|
||||||
const paddingRight = style.effectiveBorderRightWidth + style.effectivePaddingRight;
|
const paddingBottom = this.effectiveBorderBottomWidth + this.effectivePaddingBottom;
|
||||||
const paddingBottom = style.effectiveBorderBottomWidth + style.effectivePaddingBottom;
|
|
||||||
|
|
||||||
let childLeft = paddingLeft;
|
let childLeft = paddingLeft;
|
||||||
let childTop = paddingTop;
|
let childTop = paddingTop;
|
||||||
@ -144,9 +142,8 @@ export class WrapLayout extends WrapLayoutBase {
|
|||||||
this.eachLayoutChild((child, last) => {
|
this.eachLayoutChild((child, last) => {
|
||||||
// Add margins because layoutChild will sustract them.
|
// Add margins because layoutChild will sustract them.
|
||||||
// * density converts them to device pixels.
|
// * density converts them to device pixels.
|
||||||
const childStyle = child.style;
|
let childHeight = child.getMeasuredHeight() + child.effectiveMarginTop + child.effectiveMarginBottom;
|
||||||
let childHeight = child.getMeasuredHeight() + childStyle.effectiveMarginTop + childStyle.effectiveMarginBottom;
|
let childWidth = child.getMeasuredWidth() + child.effectiveMarginLeft + child.effectiveMarginRight;
|
||||||
let childWidth = child.getMeasuredWidth() + childStyle.effectiveMarginLeft + childStyle.effectiveMarginRight;
|
|
||||||
|
|
||||||
let length = this._lengths[rowOrColumn];
|
let length = this._lengths[rowOrColumn];
|
||||||
if (isVertical) {
|
if (isVertical) {
|
||||||
|
@ -503,9 +503,8 @@ export class Page extends PageBase {
|
|||||||
// Measure content with height - navigationBarHeight. Here we could use actionBarSize.measuredHeight probably.
|
// Measure content with height - navigationBarHeight. Here we could use actionBarSize.measuredHeight probably.
|
||||||
let result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightSpec);
|
let result = View.measureChild(this, this.layoutView, widthMeasureSpec, heightSpec);
|
||||||
|
|
||||||
let style = this.style;
|
let measureWidth = Math.max(actionBarWidth, result.measuredWidth, this.effectiveMinWidth);
|
||||||
let measureWidth = Math.max(actionBarWidth, result.measuredWidth, style.effectiveMinWidth);
|
let measureHeight = Math.max(result.measuredHeight + actionBarHeight, this.effectiveMinHeight);
|
||||||
let measureHeight = Math.max(result.measuredHeight + actionBarHeight, style.effectiveMinHeight);
|
|
||||||
|
|
||||||
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
let widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
let heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
|
@ -103,10 +103,9 @@ export class ScrollView extends ScrollViewBase {
|
|||||||
|
|
||||||
const density = layout.getDisplayDensity();
|
const density = layout.getDisplayDensity();
|
||||||
const child = this.layoutView;
|
const child = this.layoutView;
|
||||||
const style = this.style;
|
|
||||||
if (!child) {
|
if (!child) {
|
||||||
this._contentMeasuredWidth = style.effectiveMinWidth * density;
|
this._contentMeasuredWidth = this.effectiveMinWidth * density;
|
||||||
this._contentMeasuredHeight = style.effectiveMinHeight * density;
|
this._contentMeasuredHeight = this.effectiveMinHeight * density;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let childSize: { measuredWidth: number; measuredHeight: number };
|
let childSize: { measuredWidth: number; measuredHeight: number };
|
||||||
@ -118,8 +117,8 @@ export class ScrollView extends ScrollViewBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.nativeView.contentSize = CGSizeMake(childSize.measuredWidth, childSize.measuredHeight);
|
this.nativeView.contentSize = CGSizeMake(childSize.measuredWidth, childSize.measuredHeight);
|
||||||
this._contentMeasuredWidth = Math.max(childSize.measuredWidth, style.effectiveMinWidth * density);
|
this._contentMeasuredWidth = Math.max(childSize.measuredWidth, this.effectiveMinWidth * density);
|
||||||
this._contentMeasuredHeight = Math.max(childSize.measuredHeight, style.effectiveMinHeight * density);
|
this._contentMeasuredHeight = Math.max(childSize.measuredHeight, this.effectiveMinHeight * density);
|
||||||
}
|
}
|
||||||
|
|
||||||
const widthAndState = View.resolveSizeAndState(this._contentMeasuredWidth, width, widthMode, 0);
|
const widthAndState = View.resolveSizeAndState(this._contentMeasuredWidth, width, widthMode, 0);
|
||||||
|
@ -28,16 +28,15 @@ export module ad {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function onBackgroundOrBorderPropertyChanged(v: View) {
|
export function onBackgroundOrBorderPropertyChanged(view: View) {
|
||||||
let nativeView = <android.view.View>v._nativeView;
|
let nativeView = <android.view.View>view._nativeView;
|
||||||
if (!nativeView) {
|
if (!nativeView) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let style = v.style;
|
|
||||||
|
|
||||||
let background = style.backgroundInternal;
|
let background = view.style.backgroundInternal;
|
||||||
let backgroundDrawable = nativeView.getBackground();
|
let backgroundDrawable = nativeView.getBackground();
|
||||||
let cache = <CacheLayerType>v._nativeView;
|
let cache = <CacheLayerType>view._nativeView;
|
||||||
|
|
||||||
if (isSetColorFilterOnlyWidget(nativeView)
|
if (isSetColorFilterOnlyWidget(nativeView)
|
||||||
&& !isNullOrUndefined(backgroundDrawable)
|
&& !isNullOrUndefined(backgroundDrawable)
|
||||||
@ -53,13 +52,13 @@ export module ad {
|
|||||||
}
|
}
|
||||||
else if (!background.isEmpty()) {
|
else if (!background.isEmpty()) {
|
||||||
if (!(backgroundDrawable instanceof org.nativescript.widgets.BorderDrawable)) {
|
if (!(backgroundDrawable instanceof org.nativescript.widgets.BorderDrawable)) {
|
||||||
let viewClass = getClass(v);
|
let viewClass = getClass(view);
|
||||||
if (!isSetColorFilterOnlyWidget(nativeView) && !_defaultBackgrounds.has(viewClass)) {
|
if (!isSetColorFilterOnlyWidget(nativeView) && !_defaultBackgrounds.has(viewClass)) {
|
||||||
_defaultBackgrounds.set(viewClass, nativeView.getBackground());
|
_defaultBackgrounds.set(viewClass, nativeView.getBackground());
|
||||||
}
|
}
|
||||||
|
|
||||||
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(1, v.toString());
|
backgroundDrawable = new org.nativescript.widgets.BorderDrawable(1, view.toString());
|
||||||
refreshBorderDrawable(v, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
refreshBorderDrawable(view, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
||||||
|
|
||||||
if (getSDK() >= 16) {
|
if (getSDK() >= 16) {
|
||||||
nativeView.setBackground(backgroundDrawable);
|
nativeView.setBackground(backgroundDrawable);
|
||||||
@ -68,7 +67,7 @@ export module ad {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
refreshBorderDrawable(v, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
refreshBorderDrawable(view, <org.nativescript.widgets.BorderDrawable>backgroundDrawable);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((background.hasBorderWidth() || background.hasBorderRadius() || background.clipPath) && getSDK() < 18) {
|
if ((background.hasBorderWidth() || background.hasBorderRadius() || background.clipPath) && getSDK() < 18) {
|
||||||
@ -90,7 +89,7 @@ export module ad {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let viewClass = getClass(v);
|
let viewClass = getClass(view);
|
||||||
if (_defaultBackgrounds.has(viewClass)) {
|
if (_defaultBackgrounds.has(viewClass)) {
|
||||||
if (getSDK() >= 16) {
|
if (getSDK() >= 16) {
|
||||||
nativeView.setBackground(_defaultBackgrounds.get(viewClass));
|
nativeView.setBackground(_defaultBackgrounds.get(viewClass));
|
||||||
@ -108,10 +107,10 @@ export module ad {
|
|||||||
|
|
||||||
// TODO: Can we move BorderWidths as separate native setter?
|
// TODO: Can we move BorderWidths as separate native setter?
|
||||||
// This way we could skip setPadding if borderWidth is not changed.
|
// This way we could skip setPadding if borderWidth is not changed.
|
||||||
let leftPadding = Math.round(style.effectiveBorderLeftWidth + style.effectivePaddingLeft);
|
let leftPadding = Math.round(view.effectiveBorderLeftWidth + view.effectivePaddingLeft);
|
||||||
let topPadding = Math.round(style.effectiveBorderTopWidth + style.effectivePaddingTop);
|
let topPadding = Math.round(view.effectiveBorderTopWidth + view.effectivePaddingTop);
|
||||||
let rightPadding = Math.round(style.effectiveBorderRightWidth + style.effectivePaddingRight);
|
let rightPadding = Math.round(view.effectiveBorderRightWidth + view.effectivePaddingRight);
|
||||||
let bottomPadding = Math.round(style.effectiveBorderBottomWidth + style.effectivePaddingBottom);
|
let bottomPadding = Math.round(view.effectiveBorderBottomWidth + view.effectivePaddingBottom);
|
||||||
|
|
||||||
nativeView.setPadding(
|
nativeView.setPadding(
|
||||||
leftPadding,
|
leftPadding,
|
||||||
|
@ -327,9 +327,8 @@ export class TabView extends TabViewBase {
|
|||||||
measureWidth = childSize.measuredWidth;
|
measureWidth = childSize.measuredWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
const style = this.style;
|
measureWidth = Math.max(measureWidth, this.effectiveMinWidth * density);
|
||||||
measureWidth = Math.max(measureWidth, style.effectiveMinWidth * density);
|
measureHeight = Math.max(measureHeight, this.effectiveMinHeight * density);
|
||||||
measureHeight = Math.max(measureHeight, style.effectiveMinHeight * density);
|
|
||||||
|
|
||||||
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
const widthAndState = View.resolveSizeAndState(measureWidth, width, widthMode, 0);
|
||||||
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
const heightAndState = View.resolveSizeAndState(measureHeight, height, heightMode, 0);
|
||||||
|
@ -102,10 +102,9 @@ class UITextFieldImpl extends UITextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let size = bounds.size;
|
let size = bounds.size;
|
||||||
let style = owner.style;
|
return CGRectMake(owner.effectiveBorderLeftWidth + owner.effectivePaddingLeft, owner.effectiveBorderTopWidth + owner.effectivePaddingTop,
|
||||||
return CGRectMake(style.effectiveBorderLeftWidth + style.effectivePaddingLeft, style.effectiveBorderTopWidth + style.effectivePaddingTop,
|
size.width - (owner.effectiveBorderLeftWidth + owner.effectivePaddingLeft + owner.effectivePaddingRight + owner.effectiveBorderRightWidth),
|
||||||
size.width - (style.effectiveBorderLeftWidth + style.effectivePaddingLeft + style.effectivePaddingRight + style.effectiveBorderRightWidth),
|
size.height - (owner.effectiveBorderTopWidth + owner.effectivePaddingTop + owner.effectivePaddingBottom + owner.effectiveBorderBottomWidth)
|
||||||
size.height - (style.effectiveBorderTopWidth + style.effectivePaddingTop + style.effectivePaddingBottom + style.effectiveBorderBottomWidth)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,8 +171,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [borderTopWidthProperty.native](value: Length) {
|
set [borderTopWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let top = this.effectivePaddingTop + this.effectiveBorderTopWidth;
|
||||||
let top = style.effectivePaddingTop + style.effectiveBorderTopWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.textContainerInset = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,8 +183,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [borderRightWidthProperty.native](value: Length) {
|
set [borderRightWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let right = this.effectivePaddingRight + this.effectiveBorderRightWidth;
|
||||||
let right = style.effectivePaddingRight + style.effectiveBorderRightWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -197,8 +195,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [borderBottomWidthProperty.native](value: Length) {
|
set [borderBottomWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let bottom = this.effectivePaddingBottom + this.effectiveBorderBottomWidth;
|
||||||
let bottom = style.effectivePaddingBottom + style.effectiveBorderBottomWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,8 +207,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [borderLeftWidthProperty.native](value: Length) {
|
set [borderLeftWidthProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let left = this.effectivePaddingLeft + this.effectiveBorderLeftWidth;
|
||||||
let left = style.effectivePaddingLeft + style.effectiveBorderLeftWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,8 +219,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [paddingTopProperty.native](value: Length) {
|
set [paddingTopProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let top = this.effectivePaddingTop + this.effectiveBorderTopWidth;
|
||||||
let top = style.effectivePaddingTop + style.effectiveBorderTopWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.textContainerInset = { top: top, left: inset.left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,8 +231,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [paddingRightProperty.native](value: Length) {
|
set [paddingRightProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let right = this.effectivePaddingRight + this.effectiveBorderRightWidth;
|
||||||
let right = style.effectivePaddingRight + style.effectiveBorderRightWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: inset.bottom, right: right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,8 +243,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [paddingBottomProperty.native](value: Length) {
|
set [paddingBottomProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let bottom = this.effectivePaddingBottom + this.effectiveBorderBottomWidth;
|
||||||
let bottom = style.effectivePaddingBottom + style.effectiveBorderBottomWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
this.nativeView.textContainerInset = { top: inset.top, left: inset.left, bottom: bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -262,8 +255,7 @@ export class TextView extends EditableTextBase implements TextViewDefinition {
|
|||||||
}
|
}
|
||||||
set [paddingLeftProperty.native](value: Length) {
|
set [paddingLeftProperty.native](value: Length) {
|
||||||
let inset = this.nativeView.textContainerInset;
|
let inset = this.nativeView.textContainerInset;
|
||||||
let style = this.style;
|
let left = this.effectivePaddingLeft + this.effectiveBorderLeftWidth;
|
||||||
let left = style.effectivePaddingLeft + style.effectiveBorderLeftWidth;
|
|
||||||
this.nativeView.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
this.nativeView.textContainerInset = { top: inset.top, left: left, bottom: inset.bottom, right: inset.right };
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user