import styling = require("ui/styling"); import types = require("utils/types"); import trace = require("trace"); import {DependencyObservable, PropertyMetadata, PropertyMetadataSettings, PropertyChangeData, Property, ValueSource, NativeValueResult} from "ui/core/dependency-observable"; import {View} from "ui/core/view"; import {Color} from "color"; import stylers = require("ui/styling/stylers"); import styleProperty = require("ui/styling/style-property"); import converters = require("./converters"); import enums = require("ui/enums"); import imageSource = require("image-source"); import utils = require("utils/utils"); import font = require("ui/styling/font"); import background = require("ui/styling/background"); import platform = require("platform"); // key is the property id and value is Dictionary; var _registeredHandlers = Array(); // key is a className + property id and value is StylePropertyChangedHandler; var _handlersCache = {}; // classes like Frame that does not need to handle styling properties. var noStylingClasses = {}; // on Android we explicitly set propertySettings to None because android will invalidate its layout (skip unnecessary native call). var AffectsLayout = platform.device.os === platform.platformNames.android ? PropertyMetadataSettings.None : PropertyMetadataSettings.AffectsLayout; export interface Thickness { left: number; top: number; right: number; bottom: number; } export interface CommonLayoutParams { width: number; height: number; leftMargin: number; topMargin: number; rightMargin: number; bottomMargin: number; horizontalAlignment: string; verticalAlignment: string; } function parseThickness(value: any): Thickness { var result: Thickness = { top: 0, right: 0, bottom: 0, left: 0 }; if (types.isString(value)) { var arr = value.split(/[ ,]+/); var top = parseInt(arr[0]); top = isNaN(top) ? 0 : top; var right = parseInt(arr[1]); right = isNaN(right) ? top : right; var bottom = parseInt(arr[2]); bottom = isNaN(bottom) ? top : bottom; var left = parseInt(arr[3]); left = isNaN(left) ? right : left; result.top = top; result.right = right; result.bottom = bottom; result.left = left; } else if (types.isNumber(value)) { result.top = result.right = result.bottom = result.left = value; } else { result = value; } return result; } function layoutParamsComparer(x: CommonLayoutParams, y: CommonLayoutParams): boolean { return x.width === y.width && x.height === y.height && x.leftMargin === y.leftMargin && x.topMargin === y.topMargin && x.rightMargin === y.rightMargin && x.bottomMargin === y.bottomMargin && x.horizontalAlignment === y.horizontalAlignment && x.verticalAlignment === y.verticalAlignment } function onLayoutParamsChanged(data: PropertyChangeData) { var style =