public static bool ApplyAndCompare <T>(ref StyleValue <T> current, StyleValue <T> other) where T : Object { T oldValue = current.value; if (current.Apply(other, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity)) { return(oldValue != other.value); } return(false); }
// Note: this should not box values since we use a generic constraint public static bool ApplyAndCompare <T>(ref StyleValue <T> current, StyleValue <T> other) where T : struct, IEquatable <T> { T oldValue = current.value; if (current.Apply(other, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity)) { return(!oldValue.Equals(other.value)); } return(false); }
public static bool ApplyAndCompare(ref StyleValue <CursorStyle> current, StyleValue <CursorStyle> other) { CursorStyle oldValue = current.value; if (current.Apply(other, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity)) { return(oldValue != other.value); } return(false); }
public void ApplyCustomProperty(string propertyName, ref StyleValue <Texture2D> target) { CustomProperty property; StyleValue <Texture2D> tmp = new StyleValue <Texture2D>(); if (m_CustomProperties != null && m_CustomProperties.TryGetValue(propertyName, out property)) { property.data.Apply(property.handles, property.specificity, ref tmp, StyleSheetApplicator.ApplyImage); } target.Apply(tmp, StylePropertyApplyMode.CopyIfNotInline); }
public void ApplyCustomProperty(string propertyName, ref StyleValue <string> target) { CustomProperty property; StyleValue <string> tmp = new StyleValue <string>(string.Empty); if (m_CustomProperties != null && m_CustomProperties.TryGetValue(propertyName, out property)) { tmp.value = property.data.ReadAsString(property.handles[0]); tmp.specificity = property.specificity; } target.Apply(tmp, StylePropertyApplyMode.CopyIfNotInline); }
internal void ApplyCustomProperty <T>(string propertyName, ref StyleValue <T> target, StyleValueType valueType, HandlesApplicatorFunction <T> applicatorFunc) { CustomProperty property; StyleValue <T> tmp = new StyleValue <T>(); if (m_CustomProperties != null && m_CustomProperties.TryGetValue(propertyName, out property)) { // CustomProperty only support one value var handle = property.handles[0]; if (handle.valueType == valueType) { property.data.Apply(property.handles, property.specificity, ref tmp, applicatorFunc); } else { Debug.LogWarning(string.Format("Trying to read value as {0} while parsed type is {1}", valueType, handle.valueType)); } } target.Apply(tmp, StylePropertyApplyMode.CopyIfNotInline); }
static void Apply <T>(T val, int specificity, ref StyleValue <T> property) { property.Apply(new StyleValue <T>(val, specificity), StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); }
public void Apply(VisualElementStylesData other, StylePropertyApplyMode mode) { // Always just copy the reference to custom properties, since they can't be overriden per instance m_CustomProperties = other.m_CustomProperties; width.Apply(other.width, mode); height.Apply(other.height, mode); maxWidth.Apply(other.maxWidth, mode); maxHeight.Apply(other.maxHeight, mode); minWidth.Apply(other.minWidth, mode); minHeight.Apply(other.minHeight, mode); flex.Apply(other.flex, mode); flexBasis.Apply(other.flexBasis, mode); flexGrow.Apply(other.flexGrow, mode); flexShrink.Apply(other.flexShrink, mode); overflow.Apply(other.overflow, mode); positionLeft.Apply(other.positionLeft, mode); positionTop.Apply(other.positionTop, mode); positionRight.Apply(other.positionRight, mode); positionBottom.Apply(other.positionBottom, mode); marginLeft.Apply(other.marginLeft, mode); marginTop.Apply(other.marginTop, mode); marginRight.Apply(other.marginRight, mode); marginBottom.Apply(other.marginBottom, mode); borderLeft.Apply(other.borderLeft, mode); borderTop.Apply(other.borderTop, mode); borderRight.Apply(other.borderRight, mode); borderBottom.Apply(other.borderBottom, mode); paddingLeft.Apply(other.paddingLeft, mode); paddingTop.Apply(other.paddingTop, mode); paddingRight.Apply(other.paddingRight, mode); paddingBottom.Apply(other.paddingBottom, mode); positionType.Apply(other.positionType, mode); alignSelf.Apply(other.alignSelf, mode); textAlignment.Apply(other.textAlignment, mode); fontStyle.Apply(other.fontStyle, mode); textClipping.Apply(other.textClipping, mode); fontSize.Apply(other.fontSize, mode); font.Apply(other.font, mode); wordWrap.Apply(other.wordWrap, mode); textColor.Apply(other.textColor, mode); flexDirection.Apply(other.flexDirection, mode); backgroundColor.Apply(other.backgroundColor, mode); borderColor.Apply(other.borderColor, mode); backgroundImage.Apply(other.backgroundImage, mode); backgroundSize.Apply(other.backgroundSize, mode); alignItems.Apply(other.alignItems, mode); alignContent.Apply(other.alignContent, mode); justifyContent.Apply(other.justifyContent, mode); flexWrap.Apply(other.flexWrap, mode); borderLeftWidth.Apply(other.borderLeftWidth, mode); borderTopWidth.Apply(other.borderTopWidth, mode); borderRightWidth.Apply(other.borderRightWidth, mode); borderBottomWidth.Apply(other.borderBottomWidth, mode); borderTopLeftRadius.Apply(other.borderTopLeftRadius, mode); borderTopRightRadius.Apply(other.borderTopRightRadius, mode); borderBottomRightRadius.Apply(other.borderBottomRightRadius, mode); borderBottomLeftRadius.Apply(other.borderBottomLeftRadius, mode); sliceLeft.Apply(other.sliceLeft, mode); sliceTop.Apply(other.sliceTop, mode); sliceRight.Apply(other.sliceRight, mode); sliceBottom.Apply(other.sliceBottom, mode); opacity.Apply(other.opacity, mode); cursor.Apply(other.cursor, mode); }
public static bool ApplyAndCompare(ref StyleValue <float> current, StyleValue <float> other) { float value = current.value; return(current.Apply(other, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity) && value != other.value); }
public static bool ApplyAndCompare <T>(ref StyleValue <T> current, StyleValue <T> other) where T : UnityEngine.Object { T value = current.value; return(current.Apply(other, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity) && value != other.value); }