public void NotifyOfHierarchyChange( IBuilderSelectionNotifier source = null, VisualElement element = null, BuilderHierarchyChangeType changeType = BuilderHierarchyChangeType.All) { if (m_Notifiers == null || m_Notifiers.Count == 0) { return; } VisualElementAsset vea = element?.GetVisualElementAsset(); if (vea != null && vea.ruleIndex >= 0 && changeType.HasFlag(BuilderHierarchyChangeType.InlineStyle)) { var vta = m_PaneWindow.document.visualTreeAsset; var rule = vta.GetOrCreateInlineStyleRule(vea); #if UNITY_2020_1_OR_NEWER element.SetInlineRule(vta.inlineSheet, rule); // Need to enforce this specific style is updated. element.IncrementVersion(VersionChangeType.Opacity | VersionChangeType.Overflow); #elif UNITY_2019_3_OR_NEWER var stylesData = new UnityEngine.UIElements.StyleSheets.VisualElementStylesData(false); element.m_Style = stylesData; s_StylePropertyReader.SetInlineContext(vta.inlineSheet, rule, vea.ruleIndex); stylesData.ApplyProperties(s_StylePropertyReader, null); // Need to enforce this specific style is updated. element.IncrementVersion(VersionChangeType.Opacity | VersionChangeType.Overflow); #else var stylesData = new UnityEngine.UIElements.StyleSheets.VisualElementStylesData(false); element.m_Style = stylesData; var propIds = UnityEngine.UIElements.StyleSheets.StyleSheetCache.GetPropertyIDs(vta.inlineSheet, vea.ruleIndex); element.specifiedStyle.ApplyRule(vta.inlineSheet, Int32.MaxValue, rule, propIds); // Need to enforce this specific style is updated. element.IncrementVersion(VersionChangeType.Overflow); #endif } if (m_DocumentElement != null) { m_PaneWindow.document.RefreshStyle(m_DocumentElement); } // This is so anyone interested can refresh their use of this UXML with // the latest (unsaved to disk) changes. EditorUtility.SetDirty(m_PaneWindow.document.visualTreeAsset); foreach (var notifier in m_Notifiers) { if (notifier != source) { notifier.HierarchyChanged(element, changeType); } } }
public static void ApplyBorderRadius(StylePropertyReader reader, VisualElementStylesData styleData) { StyleLength topLeft; StyleLength topRight; StyleLength bottomLeft; StyleLength bottomRight; CompileBoxArea(reader, out topLeft, out topRight, out bottomRight, out bottomLeft); // border-radius doesn't support any keyword, revert to 0 in that case if (topLeft.keyword != StyleKeyword.Undefined) { topLeft.value = 0f; } if (topRight.keyword != StyleKeyword.Undefined) { topRight.value = 0f; } if (bottomLeft.keyword != StyleKeyword.Undefined) { bottomLeft.value = 0f; } if (bottomRight.keyword != StyleKeyword.Undefined) { bottomRight.value = 0f; } styleData.borderTopLeftRadius = topLeft; styleData.borderTopRightRadius = topRight; styleData.borderBottomLeftRadius = bottomLeft; styleData.borderBottomRightRadius = bottomRight; }
public static void ApplyBorderColor(StylePropertyReader reader, VisualElementStylesData styleData) { StyleColor top; StyleColor right; StyleColor bottom; StyleColor left; CompileBoxArea(reader, out top, out right, out bottom, out left); // border-color doesn't support any keyword, revert to Color.clear in that case if (top.keyword != StyleKeyword.Undefined) { top.value = Color.clear; } if (right.keyword != StyleKeyword.Undefined) { right.value = Color.clear; } if (bottom.keyword != StyleKeyword.Undefined) { bottom.value = Color.clear; } if (left.keyword != StyleKeyword.Undefined) { left.value = Color.clear; } styleData.borderTopColor.Apply(top, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderRightColor.Apply(right, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderBottomColor.Apply(bottom, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderLeftColor.Apply(left, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); }
public static void ApplyBorderWidth(StylePropertyReader reader, VisualElementStylesData styleData) { StyleLength top; StyleLength right; StyleLength bottom; StyleLength left; CompileBoxArea(reader, out top, out right, out bottom, out left); // border-width doesn't support any keyword, revert to 0 in that case if (top.keyword != StyleKeyword.Undefined) { top.value = 0f; } if (right.keyword != StyleKeyword.Undefined) { right.value = 0f; } if (bottom.keyword != StyleKeyword.Undefined) { bottom.value = 0f; } if (left.keyword != StyleKeyword.Undefined) { left.value = 0f; } styleData.borderTopWidth = top.ToStyleFloat(); styleData.borderRightWidth = right.ToStyleFloat(); styleData.borderBottomWidth = bottom.ToStyleFloat(); styleData.borderLeftWidth = left.ToStyleFloat(); }
public static void ApplyPadding(StylePropertyReader reader, VisualElementStylesData styleData) { StyleLength top; StyleLength right; StyleLength bottom; StyleLength left; CompileBoxArea(reader, out top, out right, out bottom, out left); styleData.paddingTop = top; styleData.paddingRight = right; styleData.paddingBottom = bottom; styleData.paddingLeft = left; }
public static void ApplyFlex(StylePropertyReader reader, VisualElementStylesData styleData) { StyleFloat grow; StyleFloat shrink; StyleLength basis; bool valid = CompileFlexShorthand(reader, out grow, out shrink, out basis); if (valid) { styleData.flexGrow = grow; styleData.flexShrink = shrink; styleData.flexBasis = basis; } }
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); flexBasis.Apply(other.flexBasis, mode); flexGrow.Apply(other.flexGrow, mode); flexShrink.Apply(other.flexShrink, mode); overflow.Apply(other.overflow, mode); unityOverflowClipBox.Apply(other.unityOverflowClipBox, mode); left.Apply(other.left, mode); top.Apply(other.top, mode); right.Apply(other.right, mode); bottom.Apply(other.bottom, mode); marginLeft.Apply(other.marginLeft, mode); marginTop.Apply(other.marginTop, mode); marginRight.Apply(other.marginRight, mode); marginBottom.Apply(other.marginBottom, mode); paddingLeft.Apply(other.paddingLeft, mode); paddingTop.Apply(other.paddingTop, mode); paddingRight.Apply(other.paddingRight, mode); paddingBottom.Apply(other.paddingBottom, mode); position.Apply(other.position, mode); alignSelf.Apply(other.alignSelf, mode); unityTextAlign.Apply(other.unityTextAlign, mode); unityFontStyleAndWeight.Apply(other.unityFontStyleAndWeight, mode); fontSize.Apply(other.fontSize, mode); unityFont.Apply(other.unityFont, mode); whiteSpace.Apply(other.whiteSpace, mode); color.Apply(other.color, mode); flexDirection.Apply(other.flexDirection, mode); backgroundColor.Apply(other.backgroundColor, mode); backgroundImage.Apply(other.backgroundImage, mode); unityBackgroundScaleMode.Apply(other.unityBackgroundScaleMode, mode); unityBackgroundImageTintColor.Apply(other.unityBackgroundImageTintColor, mode); alignItems.Apply(other.alignItems, mode); alignContent.Apply(other.alignContent, mode); justifyContent.Apply(other.justifyContent, mode); flexWrap.Apply(other.flexWrap, mode); borderLeftColor.Apply(other.borderLeftColor, mode); borderTopColor.Apply(other.borderTopColor, mode); borderRightColor.Apply(other.borderRightColor, mode); borderBottomColor.Apply(other.borderBottomColor, 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); unitySliceLeft.Apply(other.unitySliceLeft, mode); unitySliceTop.Apply(other.unitySliceTop, mode); unitySliceRight.Apply(other.unitySliceRight, mode); unitySliceBottom.Apply(other.unitySliceBottom, mode); opacity.Apply(other.opacity, mode); cursor.Apply(other.cursor, mode); visibility.Apply(other.visibility, mode); display.Apply(other.display, mode); }
public static void ApplyPadding(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData) { StyleLength top; StyleLength right; StyleLength bottom; StyleLength left; CompileBoxArea(sheet, handles, specificity, out top, out right, out bottom, out left); styleData.paddingTop.Apply(top, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.paddingRight.Apply(right, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.paddingBottom.Apply(bottom, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.paddingLeft.Apply(left, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); }
public static void ApplyFlex(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData) { StyleFloat grow; StyleFloat shrink; StyleLength basis; bool valid = CompileFlexShorthand(sheet, handles, specificity, out grow, out shrink, out basis); if (valid) { styleData.flexGrow.Apply(grow, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.flexShrink.Apply(shrink, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.flexBasis.Apply(basis, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); } }
public static void ApplyBorderWidth(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData) { StyleLength top; StyleLength right; StyleLength bottom; StyleLength left; CompileBoxArea(sheet, handles, specificity, out top, out right, out bottom, out left); // border-width doesn't support any keyword, revert to 0 in that case if (top.keyword != StyleKeyword.Undefined) { top.value = 0f; } if (right.keyword != StyleKeyword.Undefined) { right.value = 0f; } if (bottom.keyword != StyleKeyword.Undefined) { bottom.value = 0f; } if (left.keyword != StyleKeyword.Undefined) { left.value = 0f; } styleData.borderTopWidth.Apply(top.ToStyleFloat(), StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderRightWidth.Apply(right.ToStyleFloat(), StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderBottomWidth.Apply(bottom.ToStyleFloat(), StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderLeftWidth.Apply(left.ToStyleFloat(), StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); }
public static void ApplyBorderRadius(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData) { StyleLength topLeft; StyleLength topRight; StyleLength bottomLeft; StyleLength bottomRight; CompileBoxArea(sheet, handles, specificity, out topLeft, out topRight, out bottomRight, out bottomLeft); // border-radius doesn't support any keyword, revert to 0 in that case if (topLeft.keyword != StyleKeyword.Undefined) { topLeft.value = 0f; } if (topRight.keyword != StyleKeyword.Undefined) { topRight.value = 0f; } if (bottomLeft.keyword != StyleKeyword.Undefined) { bottomLeft.value = 0f; } if (bottomRight.keyword != StyleKeyword.Undefined) { bottomRight.value = 0f; } styleData.borderTopLeftRadius.Apply(topLeft, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderTopRightRadius.Apply(topRight, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderBottomLeftRadius.Apply(bottomLeft, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); styleData.borderBottomRightRadius.Apply(bottomRight, StylePropertyApplyMode.CopyIfEqualOrGreaterSpecificity); }