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