public void ApplyUnsetValue(StylePropertyId id, ComputedStyle parentStyle) { switch (id) { case StylePropertyId.Color: inheritedData.color = parentStyle.color; break; case StylePropertyId.FontSize: inheritedData.fontSize = parentStyle.fontSize; break; case StylePropertyId.UnityFont: inheritedData.unityFont = parentStyle.unityFont; break; case StylePropertyId.UnityFontStyleAndWeight: inheritedData.unityFontStyleAndWeight = parentStyle.unityFontStyleAndWeight; break; case StylePropertyId.UnityTextAlign: inheritedData.unityTextAlign = parentStyle.unityTextAlign; break; case StylePropertyId.Visibility: inheritedData.visibility = parentStyle.visibility; break; case StylePropertyId.WhiteSpace: inheritedData.whiteSpace = parentStyle.whiteSpace; break; default: ApplyInitialValue(id); break; } }
public static object GetComputedStyleValue(ComputedStyle computedStyle, StylePropertyId id) { switch (id) { case StylePropertyId.AlignContent: return(computedStyle.alignContent); case StylePropertyId.AlignItems: return(computedStyle.alignItems); case StylePropertyId.AlignSelf: return(computedStyle.alignSelf); case StylePropertyId.BackgroundColor: return(computedStyle.backgroundColor); case StylePropertyId.BackgroundImage: return(computedStyle.backgroundImage); case StylePropertyId.BorderBottomColor: return(computedStyle.borderBottomColor); case StylePropertyId.BorderBottomLeftRadius: return(computedStyle.borderBottomLeftRadius); case StylePropertyId.BorderBottomRightRadius: return(computedStyle.borderBottomRightRadius); case StylePropertyId.BorderBottomWidth: return(computedStyle.borderBottomWidth); case StylePropertyId.BorderLeftColor: return(computedStyle.borderLeftColor); case StylePropertyId.BorderLeftWidth: return(computedStyle.borderLeftWidth); case StylePropertyId.BorderRightColor: return(computedStyle.borderRightColor); case StylePropertyId.BorderRightWidth: return(computedStyle.borderRightWidth); case StylePropertyId.BorderTopColor: return(computedStyle.borderTopColor); case StylePropertyId.BorderTopLeftRadius: return(computedStyle.borderTopLeftRadius); case StylePropertyId.BorderTopRightRadius: return(computedStyle.borderTopRightRadius); case StylePropertyId.BorderTopWidth: return(computedStyle.borderTopWidth); case StylePropertyId.Bottom: return(computedStyle.bottom); case StylePropertyId.Color: return(computedStyle.color); case StylePropertyId.Cursor: return(computedStyle.cursor); case StylePropertyId.Display: return(computedStyle.display); case StylePropertyId.FlexBasis: return(computedStyle.flexBasis); case StylePropertyId.FlexDirection: return(computedStyle.flexDirection); case StylePropertyId.FlexGrow: return(computedStyle.flexGrow); case StylePropertyId.FlexShrink: return(computedStyle.flexShrink); case StylePropertyId.FlexWrap: return(computedStyle.flexWrap); case StylePropertyId.FontSize: return(computedStyle.fontSize); case StylePropertyId.Height: return(computedStyle.height); case StylePropertyId.JustifyContent: return(computedStyle.justifyContent); case StylePropertyId.Left: return(computedStyle.left); case StylePropertyId.MarginBottom: return(computedStyle.marginBottom); case StylePropertyId.MarginLeft: return(computedStyle.marginLeft); case StylePropertyId.MarginRight: return(computedStyle.marginRight); case StylePropertyId.MarginTop: return(computedStyle.marginTop); case StylePropertyId.MaxHeight: return(computedStyle.maxHeight); case StylePropertyId.MaxWidth: return(computedStyle.maxWidth); case StylePropertyId.MinHeight: return(computedStyle.minHeight); case StylePropertyId.MinWidth: return(computedStyle.minWidth); case StylePropertyId.Opacity: return(computedStyle.opacity); case StylePropertyId.Overflow: return(computedStyle.overflow); case StylePropertyId.PaddingBottom: return(computedStyle.paddingBottom); case StylePropertyId.PaddingLeft: return(computedStyle.paddingLeft); case StylePropertyId.PaddingRight: return(computedStyle.paddingRight); case StylePropertyId.PaddingTop: return(computedStyle.paddingTop); case StylePropertyId.Position: return(computedStyle.position); case StylePropertyId.Right: return(computedStyle.right); case StylePropertyId.Top: return(computedStyle.top); case StylePropertyId.UnityBackgroundImageTintColor: return(computedStyle.unityBackgroundImageTintColor); case StylePropertyId.UnityBackgroundScaleMode: return(computedStyle.unityBackgroundScaleMode); case StylePropertyId.UnityFont: return(computedStyle.unityFont); case StylePropertyId.UnityFontStyleAndWeight: return(computedStyle.unityFontStyleAndWeight); case StylePropertyId.UnityOverflowClipBox: return(computedStyle.unityOverflowClipBox); case StylePropertyId.UnitySliceBottom: return(computedStyle.unitySliceBottom); case StylePropertyId.UnitySliceLeft: return(computedStyle.unitySliceLeft); case StylePropertyId.UnitySliceRight: return(computedStyle.unitySliceRight); case StylePropertyId.UnitySliceTop: return(computedStyle.unitySliceTop); case StylePropertyId.UnityTextAlign: return(computedStyle.unityTextAlign); case StylePropertyId.Visibility: return(computedStyle.visibility); case StylePropertyId.WhiteSpace: return(computedStyle.whiteSpace); case StylePropertyId.Width: return(computedStyle.width); default: { Debug.LogAssertion($"Cannot get computed style value for property id {id}"); return(null); } } }
public static object GetComputedStyleValue(ComputedStyle computedStyle, StylePropertyId id) { switch (id) { case StylePropertyId.AlignContent: return(new StyleEnum <Align>((Align)computedStyle.alignContent)); case StylePropertyId.AlignItems: return(new StyleEnum <Align>((Align)computedStyle.alignItems)); case StylePropertyId.AlignSelf: return(new StyleEnum <Align>((Align)computedStyle.alignSelf)); case StylePropertyId.BackgroundColor: return(new StyleColor(computedStyle.backgroundColor)); case StylePropertyId.BackgroundImage: return(new StyleBackground(computedStyle.backgroundImage)); case StylePropertyId.BorderBottomColor: return(new StyleColor(computedStyle.borderBottomColor)); case StylePropertyId.BorderBottomLeftRadius: return(new StyleLength(computedStyle.borderBottomLeftRadius)); case StylePropertyId.BorderBottomRightRadius: return(new StyleLength(computedStyle.borderBottomRightRadius)); case StylePropertyId.BorderBottomWidth: return(new StyleFloat(computedStyle.borderBottomWidth)); case StylePropertyId.BorderLeftColor: return(new StyleColor(computedStyle.borderLeftColor)); case StylePropertyId.BorderLeftWidth: return(new StyleFloat(computedStyle.borderLeftWidth)); case StylePropertyId.BorderRightColor: return(new StyleColor(computedStyle.borderRightColor)); case StylePropertyId.BorderRightWidth: return(new StyleFloat(computedStyle.borderRightWidth)); case StylePropertyId.BorderTopColor: return(new StyleColor(computedStyle.borderTopColor)); case StylePropertyId.BorderTopLeftRadius: return(new StyleLength(computedStyle.borderTopLeftRadius)); case StylePropertyId.BorderTopRightRadius: return(new StyleLength(computedStyle.borderTopRightRadius)); case StylePropertyId.BorderTopWidth: return(new StyleFloat(computedStyle.borderTopWidth)); case StylePropertyId.Bottom: return(new StyleLength(computedStyle.bottom)); case StylePropertyId.Color: return(new StyleColor(computedStyle.color)); case StylePropertyId.Cursor: return(new StyleCursor(computedStyle.cursor)); case StylePropertyId.Display: return(new StyleEnum <DisplayStyle>((DisplayStyle)computedStyle.display)); case StylePropertyId.FlexBasis: return(new StyleLength(computedStyle.flexBasis)); case StylePropertyId.FlexDirection: return(new StyleEnum <FlexDirection>((FlexDirection)computedStyle.flexDirection)); case StylePropertyId.FlexGrow: return(new StyleFloat(computedStyle.flexGrow)); case StylePropertyId.FlexShrink: return(new StyleFloat(computedStyle.flexShrink)); case StylePropertyId.FlexWrap: return(new StyleEnum <Wrap>((Wrap)computedStyle.flexWrap)); case StylePropertyId.FontSize: return(new StyleLength(computedStyle.fontSize)); case StylePropertyId.Height: return(new StyleLength(computedStyle.height)); case StylePropertyId.JustifyContent: return(new StyleEnum <Justify>((Justify)computedStyle.justifyContent)); case StylePropertyId.Left: return(new StyleLength(computedStyle.left)); case StylePropertyId.LetterSpacing: return(new StyleLength(computedStyle.letterSpacing)); case StylePropertyId.MarginBottom: return(new StyleLength(computedStyle.marginBottom)); case StylePropertyId.MarginLeft: return(new StyleLength(computedStyle.marginLeft)); case StylePropertyId.MarginRight: return(new StyleLength(computedStyle.marginRight)); case StylePropertyId.MarginTop: return(new StyleLength(computedStyle.marginTop)); case StylePropertyId.MaxHeight: return(new StyleLength(computedStyle.maxHeight)); case StylePropertyId.MaxWidth: return(new StyleLength(computedStyle.maxWidth)); case StylePropertyId.MinHeight: return(new StyleLength(computedStyle.minHeight)); case StylePropertyId.MinWidth: return(new StyleLength(computedStyle.minWidth)); case StylePropertyId.Opacity: return(new StyleFloat(computedStyle.opacity)); case StylePropertyId.Overflow: return(new StyleEnum <Overflow>((Overflow)computedStyle.overflow)); case StylePropertyId.PaddingBottom: return(new StyleLength(computedStyle.paddingBottom)); case StylePropertyId.PaddingLeft: return(new StyleLength(computedStyle.paddingLeft)); case StylePropertyId.PaddingRight: return(new StyleLength(computedStyle.paddingRight)); case StylePropertyId.PaddingTop: return(new StyleLength(computedStyle.paddingTop)); case StylePropertyId.Position: return(new StyleEnum <Position>((Position)computedStyle.position)); case StylePropertyId.Right: return(new StyleLength(computedStyle.right)); case StylePropertyId.TextOverflow: return(new StyleEnum <TextOverflow>((TextOverflow)computedStyle.textOverflow)); case StylePropertyId.TextShadow: return(new StyleTextShadow(computedStyle.textShadow)); case StylePropertyId.Top: return(new StyleLength(computedStyle.top)); case StylePropertyId.UnityBackgroundImageTintColor: return(new StyleColor(computedStyle.unityBackgroundImageTintColor)); case StylePropertyId.UnityBackgroundScaleMode: return(new StyleEnum <ScaleMode>((ScaleMode)computedStyle.unityBackgroundScaleMode)); case StylePropertyId.UnityFont: return(new StyleFont(computedStyle.unityFont)); case StylePropertyId.UnityFontDefinition: return(new StyleFontDefinition(computedStyle.unityFontDefinition)); case StylePropertyId.UnityFontStyleAndWeight: return(new StyleEnum <FontStyle>((FontStyle)computedStyle.unityFontStyleAndWeight)); case StylePropertyId.UnityOverflowClipBox: return(new StyleEnum <OverflowClipBox>((OverflowClipBox)computedStyle.unityOverflowClipBox)); case StylePropertyId.UnityParagraphSpacing: return(new StyleLength(computedStyle.unityParagraphSpacing)); case StylePropertyId.UnitySliceBottom: return(new StyleInt(computedStyle.unitySliceBottom)); case StylePropertyId.UnitySliceLeft: return(new StyleInt(computedStyle.unitySliceLeft)); case StylePropertyId.UnitySliceRight: return(new StyleInt(computedStyle.unitySliceRight)); case StylePropertyId.UnitySliceTop: return(new StyleInt(computedStyle.unitySliceTop)); case StylePropertyId.UnityTextAlign: return(new StyleEnum <TextAnchor>((TextAnchor)computedStyle.unityTextAlign)); case StylePropertyId.UnityTextOutlineColor: return(new StyleColor(computedStyle.unityTextOutlineColor)); case StylePropertyId.UnityTextOutlineWidth: return(new StyleFloat(computedStyle.unityTextOutlineWidth)); case StylePropertyId.UnityTextOverflowPosition: return(new StyleEnum <TextOverflowPosition>((TextOverflowPosition)computedStyle.unityTextOverflowPosition)); case StylePropertyId.Visibility: return(new StyleEnum <Visibility>((Visibility)computedStyle.visibility)); case StylePropertyId.WhiteSpace: return(new StyleEnum <WhiteSpace>((WhiteSpace)computedStyle.whiteSpace)); case StylePropertyId.Width: return(new StyleLength(computedStyle.width)); case StylePropertyId.WordSpacing: return(new StyleLength(computedStyle.wordSpacing)); default: { Debug.LogAssertion($"Cannot get computed style value for property id {id}"); return(null); } } }
public void ApplyProperties(StylePropertyReader reader, ComputedStyle parentStyle) { for (var id = reader.propertyId; id != StylePropertyId.Unknown; id = reader.MoveNextProperty()) { if (ApplyGlobalKeyword(reader, parentStyle)) { continue; } switch (id) { case StylePropertyId.AlignContent: nonInheritedData.alignContent = (Align)reader.ReadStyleEnum(StyleEnumType.Align, 0).value; break; case StylePropertyId.AlignItems: nonInheritedData.alignItems = (Align)reader.ReadStyleEnum(StyleEnumType.Align, 0).value; break; case StylePropertyId.AlignSelf: nonInheritedData.alignSelf = (Align)reader.ReadStyleEnum(StyleEnumType.Align, 0).value; break; case StylePropertyId.BackgroundColor: nonInheritedData.backgroundColor = reader.ReadStyleColor(0); break; case StylePropertyId.BackgroundImage: nonInheritedData.backgroundImage = reader.ReadStyleBackground(0); break; case StylePropertyId.BorderBottomColor: nonInheritedData.borderBottomColor = reader.ReadStyleColor(0); break; case StylePropertyId.BorderBottomLeftRadius: nonInheritedData.borderBottomLeftRadius = reader.ReadStyleLength(0); break; case StylePropertyId.BorderBottomRightRadius: nonInheritedData.borderBottomRightRadius = reader.ReadStyleLength(0); break; case StylePropertyId.BorderBottomWidth: nonInheritedData.borderBottomWidth = reader.ReadStyleFloat(0); break; case StylePropertyId.BorderColor: ShorthandApplicator.ApplyBorderColor(reader, this); break; case StylePropertyId.BorderLeftColor: nonInheritedData.borderLeftColor = reader.ReadStyleColor(0); break; case StylePropertyId.BorderLeftWidth: nonInheritedData.borderLeftWidth = reader.ReadStyleFloat(0); break; case StylePropertyId.BorderRadius: ShorthandApplicator.ApplyBorderRadius(reader, this); break; case StylePropertyId.BorderRightColor: nonInheritedData.borderRightColor = reader.ReadStyleColor(0); break; case StylePropertyId.BorderRightWidth: nonInheritedData.borderRightWidth = reader.ReadStyleFloat(0); break; case StylePropertyId.BorderTopColor: nonInheritedData.borderTopColor = reader.ReadStyleColor(0); break; case StylePropertyId.BorderTopLeftRadius: nonInheritedData.borderTopLeftRadius = reader.ReadStyleLength(0); break; case StylePropertyId.BorderTopRightRadius: nonInheritedData.borderTopRightRadius = reader.ReadStyleLength(0); break; case StylePropertyId.BorderTopWidth: nonInheritedData.borderTopWidth = reader.ReadStyleFloat(0); break; case StylePropertyId.BorderWidth: ShorthandApplicator.ApplyBorderWidth(reader, this); break; case StylePropertyId.Bottom: nonInheritedData.bottom = reader.ReadStyleLength(0); break; case StylePropertyId.Color: inheritedData.color = reader.ReadStyleColor(0); break; case StylePropertyId.Cursor: nonInheritedData.cursor = reader.ReadStyleCursor(0); break; case StylePropertyId.Display: nonInheritedData.display = (DisplayStyle)reader.ReadStyleEnum(StyleEnumType.DisplayStyle, 0).value; break; case StylePropertyId.Flex: ShorthandApplicator.ApplyFlex(reader, this); break; case StylePropertyId.FlexBasis: nonInheritedData.flexBasis = reader.ReadStyleLength(0); break; case StylePropertyId.FlexDirection: nonInheritedData.flexDirection = (FlexDirection)reader.ReadStyleEnum(StyleEnumType.FlexDirection, 0).value; break; case StylePropertyId.FlexGrow: nonInheritedData.flexGrow = reader.ReadStyleFloat(0); break; case StylePropertyId.FlexShrink: nonInheritedData.flexShrink = reader.ReadStyleFloat(0); break; case StylePropertyId.FlexWrap: nonInheritedData.flexWrap = (Wrap)reader.ReadStyleEnum(StyleEnumType.Wrap, 0).value; break; case StylePropertyId.FontSize: inheritedData.fontSize = reader.ReadStyleLength(0); break; case StylePropertyId.Height: nonInheritedData.height = reader.ReadStyleLength(0); break; case StylePropertyId.JustifyContent: nonInheritedData.justifyContent = (Justify)reader.ReadStyleEnum(StyleEnumType.Justify, 0).value; break; case StylePropertyId.Left: nonInheritedData.left = reader.ReadStyleLength(0); break; case StylePropertyId.Margin: ShorthandApplicator.ApplyMargin(reader, this); break; case StylePropertyId.MarginBottom: nonInheritedData.marginBottom = reader.ReadStyleLength(0); break; case StylePropertyId.MarginLeft: nonInheritedData.marginLeft = reader.ReadStyleLength(0); break; case StylePropertyId.MarginRight: nonInheritedData.marginRight = reader.ReadStyleLength(0); break; case StylePropertyId.MarginTop: nonInheritedData.marginTop = reader.ReadStyleLength(0); break; case StylePropertyId.MaxHeight: nonInheritedData.maxHeight = reader.ReadStyleLength(0); break; case StylePropertyId.MaxWidth: nonInheritedData.maxWidth = reader.ReadStyleLength(0); break; case StylePropertyId.MinHeight: nonInheritedData.minHeight = reader.ReadStyleLength(0); break; case StylePropertyId.MinWidth: nonInheritedData.minWidth = reader.ReadStyleLength(0); break; case StylePropertyId.Opacity: nonInheritedData.opacity = reader.ReadStyleFloat(0); break; case StylePropertyId.Overflow: nonInheritedData.overflow = (OverflowInternal)reader.ReadStyleEnum(StyleEnumType.OverflowInternal, 0).value; break; case StylePropertyId.Padding: ShorthandApplicator.ApplyPadding(reader, this); break; case StylePropertyId.PaddingBottom: nonInheritedData.paddingBottom = reader.ReadStyleLength(0); break; case StylePropertyId.PaddingLeft: nonInheritedData.paddingLeft = reader.ReadStyleLength(0); break; case StylePropertyId.PaddingRight: nonInheritedData.paddingRight = reader.ReadStyleLength(0); break; case StylePropertyId.PaddingTop: nonInheritedData.paddingTop = reader.ReadStyleLength(0); break; case StylePropertyId.Position: nonInheritedData.position = (Position)reader.ReadStyleEnum(StyleEnumType.Position, 0).value; break; case StylePropertyId.Right: nonInheritedData.right = reader.ReadStyleLength(0); break; case StylePropertyId.TextOverflow: nonInheritedData.textOverflow = (TextOverflow)reader.ReadStyleEnum(StyleEnumType.TextOverflow, 0).value; break; case StylePropertyId.Top: nonInheritedData.top = reader.ReadStyleLength(0); break; case StylePropertyId.UnityBackgroundImageTintColor: nonInheritedData.unityBackgroundImageTintColor = reader.ReadStyleColor(0); break; case StylePropertyId.UnityBackgroundScaleMode: nonInheritedData.unityBackgroundScaleMode = (ScaleMode)reader.ReadStyleEnum(StyleEnumType.ScaleMode, 0).value; break; case StylePropertyId.UnityFont: inheritedData.unityFont = reader.ReadStyleFont(0); break; case StylePropertyId.UnityFontStyleAndWeight: inheritedData.unityFontStyleAndWeight = (FontStyle)reader.ReadStyleEnum(StyleEnumType.FontStyle, 0).value; break; case StylePropertyId.UnityOverflowClipBox: nonInheritedData.unityOverflowClipBox = (OverflowClipBox)reader.ReadStyleEnum(StyleEnumType.OverflowClipBox, 0).value; break; case StylePropertyId.UnitySliceBottom: nonInheritedData.unitySliceBottom = reader.ReadStyleInt(0); break; case StylePropertyId.UnitySliceLeft: nonInheritedData.unitySliceLeft = reader.ReadStyleInt(0); break; case StylePropertyId.UnitySliceRight: nonInheritedData.unitySliceRight = reader.ReadStyleInt(0); break; case StylePropertyId.UnitySliceTop: nonInheritedData.unitySliceTop = reader.ReadStyleInt(0); break; case StylePropertyId.UnityTextAlign: inheritedData.unityTextAlign = (TextAnchor)reader.ReadStyleEnum(StyleEnumType.TextAnchor, 0).value; break; case StylePropertyId.UnityTextOverflowPosition: nonInheritedData.unityTextOverflowPosition = (TextOverflowPosition)reader.ReadStyleEnum(StyleEnumType.TextOverflowPosition, 0).value; break; case StylePropertyId.Visibility: inheritedData.visibility = (Visibility)reader.ReadStyleEnum(StyleEnumType.Visibility, 0).value; break; case StylePropertyId.WhiteSpace: inheritedData.whiteSpace = (WhiteSpace)reader.ReadStyleEnum(StyleEnumType.WhiteSpace, 0).value; break; case StylePropertyId.Width: nonInheritedData.width = reader.ReadStyleLength(0); break; case StylePropertyId.Custom: ApplyCustomStyleProperty(reader); break; default: Debug.LogAssertion($"Unknown property id {id}"); break; } } }
public static void FindSpecifiedStyles(ComputedStyle computedStyle, IEnumerable <SelectorMatchRecord> matchRecords, Dictionary <StylePropertyId, int> result) { result.Clear(); bool flag = computedStyle == null; if (!flag) { foreach (SelectorMatchRecord current in matchRecords) { int value = current.complexSelector.specificity; bool isUnityStyleSheet = current.sheet.isUnityStyleSheet; if (isUnityStyleSheet) { value = -1; } StyleProperty[] properties = current.complexSelector.rule.properties; StyleProperty[] array = properties; for (int i = 0; i < array.Length; i++) { StyleProperty styleProperty = array[i]; StylePropertyId stylePropertyId; bool flag2 = StylePropertyUtil.s_NameToId.TryGetValue(styleProperty.name, out stylePropertyId); if (flag2) { bool flag3 = StyleDebug.IsShorthandProperty(stylePropertyId); if (flag3) { string[] longhandPropertyNames = StyleDebug.GetLonghandPropertyNames(stylePropertyId); string[] array2 = longhandPropertyNames; for (int j = 0; j < array2.Length; j++) { string name = array2[j]; StylePropertyId stylePropertyIdFromName = StyleDebug.GetStylePropertyIdFromName(name); result[stylePropertyIdFromName] = value; } } else { result[stylePropertyId] = value; } } } } StylePropertyId[] inheritedProperties = StyleDebug.GetInheritedProperties(); StylePropertyId[] array3 = inheritedProperties; for (int k = 0; k < array3.Length; k++) { StylePropertyId stylePropertyId2 = array3[k]; bool flag4 = result.ContainsKey(stylePropertyId2); if (!flag4) { object computedStyleValue = StyleDebug.GetComputedStyleValue(computedStyle, stylePropertyId2); object computedStyleValue2 = StyleDebug.GetComputedStyleValue(InitialStyle.Get(), stylePropertyId2); bool flag5 = !computedStyleValue.Equals(computedStyleValue2); if (flag5) { result[stylePropertyId2] = 2147483646; } } } } }
public static bool StartAnimationInlineTransformOrigin(VisualElement element, ref ComputedStyle computedStyle, StyleTransformOrigin transformOrigin, int durationMs, int delayMs, Func <float, float> easingCurve) { var to = transformOrigin.keyword == StyleKeyword.Initial ? InitialStyle.transformOrigin : transformOrigin.value; return(element.styleAnimation.Start(StylePropertyId.TransformOrigin, computedStyle.transformData.Read().transformOrigin, to, durationMs, delayMs, easingCurve)); }
public static bool StartAnimationInlineTextShadow(VisualElement element, ref ComputedStyle computedStyle, StyleTextShadow textShadow, int durationMs, int delayMs, Func <float, float> easingCurve) { var to = textShadow.keyword == StyleKeyword.Initial ? InitialStyle.textShadow : textShadow.value; return(element.styleAnimation.Start(StylePropertyId.TextShadow, computedStyle.inheritedData.Read().textShadow, to, durationMs, delayMs, easingCurve)); }
public static void SetValue(Int64 hash, ComputedStyle data) { s_ComputedStyleCache[hash] = data; }
public static void SetValue(long hash, ComputedStyle data) { StyleCache.s_ComputedStyleCache[hash] = data; }
public static bool TryGetValue(long hash, out ComputedStyle data) { return(StyleCache.s_ComputedStyleCache.TryGetValue(hash, out data)); }
private VisualElement CloneSetupRecursively(VisualElementAsset root, Dictionary <int, List <VisualElementAsset> > idToChildren, CreationContext context) { VisualElement ve = Create(root, context); // context.target is the created templateContainer if (root.id == context.visualTreeAsset.contentContainerId) { if (context.target is TemplateContainer) { ((TemplateContainer)context.target).SetContentContainer(ve); } else { Debug.LogError( "Trying to clone a VisualTreeAsset with a custom content container into a element which is not a template container"); } } // if the current element had a slot-name attribute, put it in the resulting slot mapping string slotName; if (context.slotInsertionPoints != null && TryGetSlotInsertionPoint(root.id, out slotName)) { context.slotInsertionPoints.Add(slotName, ve); } if (root.ruleIndex != -1) { if (inlineSheet == null) { Debug.LogWarning("VisualElementAsset has a RuleIndex but no inlineStyleSheet"); } else { StyleRule r = inlineSheet.rules[root.ruleIndex]; var stylesData = ComputedStyle.Create(false); ve.SetInlineRule(inlineSheet, r); } } var templateAsset = root as TemplateAsset; List <VisualElementAsset> children; if (idToChildren.TryGetValue(root.id, out children)) { children.Sort(CompareForOrder); foreach (VisualElementAsset childVea in children) { // this will fill the slotInsertionPoints mapping VisualElement childVe = CloneSetupRecursively(childVea, idToChildren, context); if (childVe == null) { continue; } // if the parent is not a template asset, just add the child to whatever hierarchy we currently have // if ve is a scrollView (with contentViewport as contentContainer), this will go to the right place if (templateAsset == null) { ve.Add(childVe); continue; } int index = templateAsset.slotUsages == null ? -1 : templateAsset.slotUsages.FindIndex(u => u.assetId == childVea.id); if (index != -1) { VisualElement parentSlot; string key = templateAsset.slotUsages[index].slotName; Assert.IsFalse(String.IsNullOrEmpty(key), "a lost name should not be null or empty, this probably points to an importer or serialization bug"); if (context.slotInsertionPoints == null || !context.slotInsertionPoints.TryGetValue(key, out parentSlot)) { Debug.LogErrorFormat("Slot '{0}' was not found. Existing slots: {1}", key, context.slotInsertionPoints == null ? String.Empty : String.Join(", ", System.Linq.Enumerable.ToArray(context.slotInsertionPoints.Keys))); ve.Add(childVe); } else { parentSlot.Add(childVe); } } else { ve.Add(childVe); } } } if (templateAsset != null && context.slotInsertionPoints != null) { context.slotInsertionPoints.Clear(); } return(ve); }
public void ApplyStyleValue(StyleValue sv, ComputedStyle parentStyle) { if (ApplyGlobalKeyword(sv, parentStyle)) { return; } switch (sv.id) { case StylePropertyId.AlignContent: nonInheritedData.alignContent = (Align)sv.number; if (sv.keyword == StyleKeyword.Auto) { nonInheritedData.alignContent = Align.Auto; } break; case StylePropertyId.AlignItems: nonInheritedData.alignItems = (Align)sv.number; if (sv.keyword == StyleKeyword.Auto) { nonInheritedData.alignItems = Align.Auto; } break; case StylePropertyId.AlignSelf: nonInheritedData.alignSelf = (Align)sv.number; if (sv.keyword == StyleKeyword.Auto) { nonInheritedData.alignSelf = Align.Auto; } break; case StylePropertyId.BackgroundColor: nonInheritedData.backgroundColor = sv.color; break; case StylePropertyId.BackgroundImage: nonInheritedData.backgroundImage = sv.resource.IsAllocated ? Background.FromObject(sv.resource.Target) : new Background(); break; case StylePropertyId.BorderBottomColor: nonInheritedData.borderBottomColor = sv.color; break; case StylePropertyId.BorderBottomLeftRadius: nonInheritedData.borderBottomLeftRadius = sv.length; break; case StylePropertyId.BorderBottomRightRadius: nonInheritedData.borderBottomRightRadius = sv.length; break; case StylePropertyId.BorderBottomWidth: nonInheritedData.borderBottomWidth = sv.number; break; case StylePropertyId.BorderLeftColor: nonInheritedData.borderLeftColor = sv.color; break; case StylePropertyId.BorderLeftWidth: nonInheritedData.borderLeftWidth = sv.number; break; case StylePropertyId.BorderRightColor: nonInheritedData.borderRightColor = sv.color; break; case StylePropertyId.BorderRightWidth: nonInheritedData.borderRightWidth = sv.number; break; case StylePropertyId.BorderTopColor: nonInheritedData.borderTopColor = sv.color; break; case StylePropertyId.BorderTopLeftRadius: nonInheritedData.borderTopLeftRadius = sv.length; break; case StylePropertyId.BorderTopRightRadius: nonInheritedData.borderTopRightRadius = sv.length; break; case StylePropertyId.BorderTopWidth: nonInheritedData.borderTopWidth = sv.number; break; case StylePropertyId.Bottom: nonInheritedData.bottom = sv.length; break; case StylePropertyId.Color: inheritedData.color = sv.color; break; case StylePropertyId.Display: nonInheritedData.display = (DisplayStyle)sv.number; if (sv.keyword == StyleKeyword.None) { nonInheritedData.display = DisplayStyle.None; } break; case StylePropertyId.FlexBasis: nonInheritedData.flexBasis = sv.length; break; case StylePropertyId.FlexDirection: nonInheritedData.flexDirection = (FlexDirection)sv.number; break; case StylePropertyId.FlexGrow: nonInheritedData.flexGrow = sv.number; break; case StylePropertyId.FlexShrink: nonInheritedData.flexShrink = sv.number; break; case StylePropertyId.FlexWrap: nonInheritedData.flexWrap = (Wrap)sv.number; break; case StylePropertyId.FontSize: inheritedData.fontSize = sv.length; break; case StylePropertyId.Height: nonInheritedData.height = sv.length; break; case StylePropertyId.JustifyContent: nonInheritedData.justifyContent = (Justify)sv.number; break; case StylePropertyId.Left: nonInheritedData.left = sv.length; break; case StylePropertyId.LetterSpacing: inheritedData.letterSpacing = sv.length; break; case StylePropertyId.MarginBottom: nonInheritedData.marginBottom = sv.length; break; case StylePropertyId.MarginLeft: nonInheritedData.marginLeft = sv.length; break; case StylePropertyId.MarginRight: nonInheritedData.marginRight = sv.length; break; case StylePropertyId.MarginTop: nonInheritedData.marginTop = sv.length; break; case StylePropertyId.MaxHeight: nonInheritedData.maxHeight = sv.length; break; case StylePropertyId.MaxWidth: nonInheritedData.maxWidth = sv.length; break; case StylePropertyId.MinHeight: nonInheritedData.minHeight = sv.length; break; case StylePropertyId.MinWidth: nonInheritedData.minWidth = sv.length; break; case StylePropertyId.Opacity: nonInheritedData.opacity = sv.number; break; case StylePropertyId.Overflow: nonInheritedData.overflow = (OverflowInternal)sv.number; break; case StylePropertyId.PaddingBottom: nonInheritedData.paddingBottom = sv.length; break; case StylePropertyId.PaddingLeft: nonInheritedData.paddingLeft = sv.length; break; case StylePropertyId.PaddingRight: nonInheritedData.paddingRight = sv.length; break; case StylePropertyId.PaddingTop: nonInheritedData.paddingTop = sv.length; break; case StylePropertyId.Position: nonInheritedData.position = (Position)sv.number; break; case StylePropertyId.Right: nonInheritedData.right = sv.length; break; case StylePropertyId.TextOverflow: nonInheritedData.textOverflow = (TextOverflow)sv.number; break; case StylePropertyId.Top: nonInheritedData.top = sv.length; break; case StylePropertyId.UnityBackgroundImageTintColor: nonInheritedData.unityBackgroundImageTintColor = sv.color; break; case StylePropertyId.UnityBackgroundScaleMode: nonInheritedData.unityBackgroundScaleMode = (ScaleMode)sv.number; break; case StylePropertyId.UnityFont: inheritedData.unityFont = sv.resource.IsAllocated ? sv.resource.Target as Font : null; break; case StylePropertyId.UnityFontDefinition: inheritedData.unityFontDefinition = sv.resource.IsAllocated ? FontDefinition.FromObject(sv.resource.Target) : new FontDefinition(); break; case StylePropertyId.UnityFontStyleAndWeight: inheritedData.unityFontStyleAndWeight = (FontStyle)sv.number; break; case StylePropertyId.UnityOverflowClipBox: nonInheritedData.unityOverflowClipBox = (OverflowClipBox)sv.number; break; case StylePropertyId.UnityParagraphSpacing: inheritedData.unityParagraphSpacing = sv.length; break; case StylePropertyId.UnitySliceBottom: nonInheritedData.unitySliceBottom = (int)sv.number; break; case StylePropertyId.UnitySliceLeft: nonInheritedData.unitySliceLeft = (int)sv.number; break; case StylePropertyId.UnitySliceRight: nonInheritedData.unitySliceRight = (int)sv.number; break; case StylePropertyId.UnitySliceTop: nonInheritedData.unitySliceTop = (int)sv.number; break; case StylePropertyId.UnityTextAlign: inheritedData.unityTextAlign = (TextAnchor)sv.number; break; case StylePropertyId.UnityTextOutlineColor: inheritedData.unityTextOutlineColor = sv.color; break; case StylePropertyId.UnityTextOutlineWidth: inheritedData.unityTextOutlineWidth = sv.number; break; case StylePropertyId.UnityTextOverflowPosition: nonInheritedData.unityTextOverflowPosition = (TextOverflowPosition)sv.number; break; case StylePropertyId.Visibility: inheritedData.visibility = (Visibility)sv.number; break; case StylePropertyId.WhiteSpace: inheritedData.whiteSpace = (WhiteSpace)sv.number; break; case StylePropertyId.Width: nonInheritedData.width = sv.length; break; case StylePropertyId.WordSpacing: inheritedData.wordSpacing = sv.length; break; default: Debug.LogAssertion($"Unexpected property id {sv.id}"); break; } }
public void ApplyUnsetValue(StylePropertyId id, ComputedStyle parentStyle) { switch (id) { case StylePropertyId.Color: inheritedData.color = parentStyle.color; break; case StylePropertyId.FontSize: inheritedData.fontSize = parentStyle.fontSize; break; case StylePropertyId.LetterSpacing: inheritedData.letterSpacing = parentStyle.letterSpacing; break; case StylePropertyId.TextShadow: inheritedData.textShadow = parentStyle.textShadow; break; case StylePropertyId.UnityFont: inheritedData.unityFont = parentStyle.unityFont; break; case StylePropertyId.UnityFontDefinition: inheritedData.unityFontDefinition = parentStyle.unityFontDefinition; break; case StylePropertyId.UnityFontStyleAndWeight: inheritedData.unityFontStyleAndWeight = parentStyle.unityFontStyleAndWeight; break; case StylePropertyId.UnityParagraphSpacing: inheritedData.unityParagraphSpacing = parentStyle.unityParagraphSpacing; break; case StylePropertyId.UnityTextAlign: inheritedData.unityTextAlign = parentStyle.unityTextAlign; break; case StylePropertyId.UnityTextOutlineColor: inheritedData.unityTextOutlineColor = parentStyle.unityTextOutlineColor; break; case StylePropertyId.UnityTextOutlineWidth: inheritedData.unityTextOutlineWidth = parentStyle.unityTextOutlineWidth; break; case StylePropertyId.Visibility: inheritedData.visibility = parentStyle.visibility; break; case StylePropertyId.WhiteSpace: inheritedData.whiteSpace = parentStyle.whiteSpace; break; case StylePropertyId.WordSpacing: inheritedData.wordSpacing = parentStyle.wordSpacing; break; default: ApplyInitialValue(id); break; } }
public static object GetComputedStyleValue(ComputedStyle computedStyle, StylePropertyId id) { object result; switch (id) { case StylePropertyId.Color: result = computedStyle.color; break; case StylePropertyId.FontSize: result = computedStyle.fontSize; break; case StylePropertyId.UnityFont: result = computedStyle.unityFont; break; case StylePropertyId.UnityFontStyleAndWeight: result = computedStyle.unityFontStyleAndWeight; break; case StylePropertyId.UnityTextAlign: result = computedStyle.unityTextAlign; break; case StylePropertyId.Visibility: result = computedStyle.visibility; break; case StylePropertyId.WhiteSpace: result = computedStyle.whiteSpace; break; default: switch (id) { case StylePropertyId.AlignContent: result = computedStyle.alignContent; break; case StylePropertyId.AlignItems: result = computedStyle.alignItems; break; case StylePropertyId.AlignSelf: result = computedStyle.alignSelf; break; case StylePropertyId.BackgroundColor: result = computedStyle.backgroundColor; break; case StylePropertyId.BackgroundImage: result = computedStyle.backgroundImage; break; case StylePropertyId.BorderBottomColor: result = computedStyle.borderBottomColor; break; case StylePropertyId.BorderBottomLeftRadius: result = computedStyle.borderBottomLeftRadius; break; case StylePropertyId.BorderBottomRightRadius: result = computedStyle.borderBottomRightRadius; break; case StylePropertyId.BorderBottomWidth: result = computedStyle.borderBottomWidth; break; case StylePropertyId.BorderLeftColor: result = computedStyle.borderLeftColor; break; case StylePropertyId.BorderLeftWidth: result = computedStyle.borderLeftWidth; break; case StylePropertyId.BorderRightColor: result = computedStyle.borderRightColor; break; case StylePropertyId.BorderRightWidth: result = computedStyle.borderRightWidth; break; case StylePropertyId.BorderTopColor: result = computedStyle.borderTopColor; break; case StylePropertyId.BorderTopLeftRadius: result = computedStyle.borderTopLeftRadius; break; case StylePropertyId.BorderTopRightRadius: result = computedStyle.borderTopRightRadius; break; case StylePropertyId.BorderTopWidth: result = computedStyle.borderTopWidth; break; case StylePropertyId.Bottom: result = computedStyle.bottom; break; case StylePropertyId.Cursor: result = computedStyle.cursor; break; case StylePropertyId.Display: result = computedStyle.display; break; case StylePropertyId.FlexBasis: result = computedStyle.flexBasis; break; case StylePropertyId.FlexDirection: result = computedStyle.flexDirection; break; case StylePropertyId.FlexGrow: result = computedStyle.flexGrow; break; case StylePropertyId.FlexShrink: result = computedStyle.flexShrink; break; case StylePropertyId.FlexWrap: result = computedStyle.flexWrap; break; case StylePropertyId.Height: result = computedStyle.height; break; case StylePropertyId.JustifyContent: result = computedStyle.justifyContent; break; case StylePropertyId.Left: result = computedStyle.left; break; case StylePropertyId.MarginBottom: result = computedStyle.marginBottom; break; case StylePropertyId.MarginLeft: result = computedStyle.marginLeft; break; case StylePropertyId.MarginRight: result = computedStyle.marginRight; break; case StylePropertyId.MarginTop: result = computedStyle.marginTop; break; case StylePropertyId.MaxHeight: result = computedStyle.maxHeight; break; case StylePropertyId.MaxWidth: result = computedStyle.maxWidth; break; case StylePropertyId.MinHeight: result = computedStyle.minHeight; break; case StylePropertyId.MinWidth: result = computedStyle.minWidth; break; case StylePropertyId.Opacity: result = computedStyle.opacity; break; case StylePropertyId.Overflow: result = computedStyle.overflow; break; case StylePropertyId.PaddingBottom: result = computedStyle.paddingBottom; break; case StylePropertyId.PaddingLeft: result = computedStyle.paddingLeft; break; case StylePropertyId.PaddingRight: result = computedStyle.paddingRight; break; case StylePropertyId.PaddingTop: result = computedStyle.paddingTop; break; case StylePropertyId.Position: result = computedStyle.position; break; case StylePropertyId.Right: result = computedStyle.right; break; case StylePropertyId.TextOverflow: result = computedStyle.textOverflow; break; case StylePropertyId.Top: result = computedStyle.top; break; case StylePropertyId.UnityBackgroundImageTintColor: result = computedStyle.unityBackgroundImageTintColor; break; case StylePropertyId.UnityBackgroundScaleMode: result = computedStyle.unityBackgroundScaleMode; break; case StylePropertyId.UnityOverflowClipBox: result = computedStyle.unityOverflowClipBox; break; case StylePropertyId.UnitySliceBottom: result = computedStyle.unitySliceBottom; break; case StylePropertyId.UnitySliceLeft: result = computedStyle.unitySliceLeft; break; case StylePropertyId.UnitySliceRight: result = computedStyle.unitySliceRight; break; case StylePropertyId.UnitySliceTop: result = computedStyle.unitySliceTop; break; case StylePropertyId.UnityTextOverflowPosition: result = computedStyle.unityTextOverflowPosition; break; case StylePropertyId.Width: result = computedStyle.width; break; default: Debug.LogAssertion(string.Format("Cannot get computed style value for property id {0}", id)); result = null; break; } break; } return(result); }
public static void SetFromStyle(ref BorderParameters border, ComputedStyle style) { border.SetWidth(style.borderTopWidth.value, style.borderRightWidth.value, style.borderBottomWidth.value, style.borderLeftWidth.value); border.SetRadius(style.borderTopLeftRadius.value.value, style.borderTopRightRadius.value.value, style.borderBottomRightRadius.value.value, style.borderBottomLeftRadius.value.value); }
private void ResolveInheritance(VisualElement element) { var specifiedStyle = element.specifiedStyle; var currentInheritedStyle = m_StyleMatchingContext.inheritedStyle; element.inheritedStyle = currentInheritedStyle; m_ResolveInheritData.CopyFrom(currentInheritedStyle); if (specifiedStyle.color.specificity != StyleValueExtensions.UndefinedSpecificity) { m_ResolveInheritData.color = specifiedStyle.color; } if (specifiedStyle.unityFont.specificity != StyleValueExtensions.UndefinedSpecificity) { m_ResolveInheritData.font = specifiedStyle.unityFont; } if (specifiedStyle.fontSize.specificity != StyleValueExtensions.UndefinedSpecificity) { // Only calculated value can be inherited // Thus if it's a percentage the real value needs to be propagated // See: https://developer.mozilla.org/en-US/docs/Web/CSS/percentage m_ResolveInheritData.fontSize = new StyleLength(ComputedStyle.CalculatePixelFontSize(element)); m_ResolveInheritData.fontSize.specificity = specifiedStyle.fontSize.specificity; } if (specifiedStyle.unityFontStyleAndWeight.specificity != StyleValueExtensions.UndefinedSpecificity) { m_ResolveInheritData.unityFontStyle = specifiedStyle.unityFontStyleAndWeight; } if (specifiedStyle.unityTextAlign.specificity != StyleValueExtensions.UndefinedSpecificity) { m_ResolveInheritData.unityTextAlign = specifiedStyle.unityTextAlign; } if (specifiedStyle.visibility.specificity != StyleValueExtensions.UndefinedSpecificity) { m_ResolveInheritData.visibility = specifiedStyle.visibility; } if (specifiedStyle.whiteSpace.specificity != StyleValueExtensions.UndefinedSpecificity) { m_ResolveInheritData.whiteSpace = specifiedStyle.whiteSpace; } if (!m_ResolveInheritData.Equals(currentInheritedStyle)) { InheritedStylesData inheritData = null; int hash = m_ResolveInheritData.GetHashCode(); if (!StyleCache.TryGetValue(hash, out inheritData)) { inheritData = new InheritedStylesData(m_ResolveInheritData); StyleCache.SetValue(hash, inheritData); } m_StyleMatchingContext.inheritedStyle = inheritData; } element.propagatedStyle = m_StyleMatchingContext.inheritedStyle; }
public static bool TryGetValue(Int64 hash, out ComputedStyle data) { return(s_ComputedStyleCache.TryGetValue(hash, out data)); }
public static bool StartAnimationInlineTransformOrigin(VisualElement element, ref ComputedStyle computedStyle, StyleTransformOrigin transformOrigin, int durationMs, int delayMs, Func <float, float> easingCurve) { var to = transformOrigin.keyword == StyleKeyword.Initial ? InitialStyle.transformOrigin : transformOrigin.value; var result = element.styleAnimation.Start(StylePropertyId.TransformOrigin, computedStyle.transformData.Read().transformOrigin, to, durationMs, delayMs, easingCurve); if (result && (element.usageHints & UsageHints.DynamicTransform) == 0) { element.usageHints |= UsageHints.DynamicTransform; } return(result); }
void ProcessMatchedRules(VisualElement element, List <SelectorMatchRecord> matchingSelectors) { matchingSelectors.Sort((a, b) => SelectorMatchRecord.Compare(a, b)); Int64 matchingRulesHash = element.fullTypeName.GetHashCode(); // Let current DPI contribute to the hash so cache is invalidated when this changes matchingRulesHash = (matchingRulesHash * 397) ^ currentPixelsPerPoint.GetHashCode(); int oldVariablesHash = m_StyleMatchingContext.variableContext.GetVariableHash(); int customPropertiesCount = 0; foreach (var record in matchingSelectors) { StyleRule rule = record.complexSelector.rule; int specificity = record.complexSelector.specificity; matchingRulesHash = (matchingRulesHash * 397) ^ rule.GetHashCode(); matchingRulesHash = (matchingRulesHash * 397) ^ specificity; if (rule.customPropertiesCount > 0) { customPropertiesCount += rule.customPropertiesCount; ProcessMatchedVariables(record.sheet, rule); } } var parent = element.hierarchy.parent; int inheritedStyleHash = parent != null ? parent.inheritedStylesHash : 0; matchingRulesHash = (matchingRulesHash * 397) ^ inheritedStyleHash; int variablesHash = oldVariablesHash; if (customPropertiesCount > 0) { // Element defines new variables, add the parents variables at the beginning of the processing context m_ProcessVarContext.InsertRange(0, m_StyleMatchingContext.variableContext); variablesHash = m_ProcessVarContext.GetVariableHash(); } matchingRulesHash = (matchingRulesHash * 397) ^ variablesHash; if (oldVariablesHash != variablesHash) { StyleVariableContext ctx; if (!StyleCache.TryGetValue(variablesHash, out ctx)) { ctx = new StyleVariableContext(m_ProcessVarContext); StyleCache.SetValue(variablesHash, ctx); } m_StyleMatchingContext.variableContext = ctx; } element.variableContext = m_StyleMatchingContext.variableContext; m_ProcessVarContext.Clear(); ComputedStyle resolvedStyles; if (StyleCache.TryGetValue(matchingRulesHash, out resolvedStyles)) { element.SetSharedStyles(resolvedStyles); } else { var parentStyle = parent?.computedStyle; resolvedStyles = ComputedStyle.Create(parentStyle, true); float dpiScaling = element.scaledPixelsPerPoint; foreach (var record in matchingSelectors) { m_StylePropertyReader.SetContext(record.sheet, record.complexSelector, m_StyleMatchingContext.variableContext, dpiScaling); resolvedStyles.ApplyProperties(m_StylePropertyReader, parentStyle); } resolvedStyles.FinalizeApply(parentStyle); StyleCache.SetValue(matchingRulesHash, resolvedStyles); element.SetSharedStyles(resolvedStyles); } }
public void ApplyStyleValue(StyleValue sv, ComputedStyle parentStyle) { if (ApplyGlobalKeyword(sv, parentStyle)) { return; } switch (sv.id) { case StylePropertyId.AlignContent: nonInheritedData.alignContent = new StyleEnum <Align>((Align)sv.number, sv.keyword); if (sv.keyword == StyleKeyword.Auto) { nonInheritedData.alignContent = Align.Auto; } break; case StylePropertyId.AlignItems: nonInheritedData.alignItems = new StyleEnum <Align>((Align)sv.number, sv.keyword); if (sv.keyword == StyleKeyword.Auto) { nonInheritedData.alignItems = Align.Auto; } break; case StylePropertyId.AlignSelf: nonInheritedData.alignSelf = new StyleEnum <Align>((Align)sv.number, sv.keyword); if (sv.keyword == StyleKeyword.Auto) { nonInheritedData.alignSelf = Align.Auto; } break; case StylePropertyId.BackgroundColor: nonInheritedData.backgroundColor = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.BackgroundImage: nonInheritedData.backgroundImage = new StyleBackground(sv.resource, sv.keyword); break; case StylePropertyId.BorderBottomColor: nonInheritedData.borderBottomColor = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.BorderBottomLeftRadius: nonInheritedData.borderBottomLeftRadius = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.BorderBottomRightRadius: nonInheritedData.borderBottomRightRadius = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.BorderBottomWidth: nonInheritedData.borderBottomWidth = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.BorderLeftColor: nonInheritedData.borderLeftColor = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.BorderLeftWidth: nonInheritedData.borderLeftWidth = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.BorderRightColor: nonInheritedData.borderRightColor = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.BorderRightWidth: nonInheritedData.borderRightWidth = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.BorderTopColor: nonInheritedData.borderTopColor = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.BorderTopLeftRadius: nonInheritedData.borderTopLeftRadius = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.BorderTopRightRadius: nonInheritedData.borderTopRightRadius = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.BorderTopWidth: nonInheritedData.borderTopWidth = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.Bottom: nonInheritedData.bottom = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.Color: inheritedData.color = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.Display: nonInheritedData.display = new StyleEnum <DisplayStyle>((DisplayStyle)sv.number, sv.keyword); if (sv.keyword == StyleKeyword.None) { nonInheritedData.display = DisplayStyle.None; } break; case StylePropertyId.FlexBasis: nonInheritedData.flexBasis = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.FlexDirection: nonInheritedData.flexDirection = new StyleEnum <FlexDirection>((FlexDirection)sv.number, sv.keyword); break; case StylePropertyId.FlexGrow: nonInheritedData.flexGrow = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.FlexShrink: nonInheritedData.flexShrink = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.FlexWrap: nonInheritedData.flexWrap = new StyleEnum <Wrap>((Wrap)sv.number, sv.keyword); break; case StylePropertyId.FontSize: inheritedData.fontSize = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.Height: nonInheritedData.height = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.JustifyContent: nonInheritedData.justifyContent = new StyleEnum <Justify>((Justify)sv.number, sv.keyword); break; case StylePropertyId.Left: nonInheritedData.left = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MarginBottom: nonInheritedData.marginBottom = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MarginLeft: nonInheritedData.marginLeft = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MarginRight: nonInheritedData.marginRight = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MarginTop: nonInheritedData.marginTop = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MaxHeight: nonInheritedData.maxHeight = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MaxWidth: nonInheritedData.maxWidth = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MinHeight: nonInheritedData.minHeight = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.MinWidth: nonInheritedData.minWidth = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.Opacity: nonInheritedData.opacity = new StyleFloat(sv.number, sv.keyword); break; case StylePropertyId.Overflow: nonInheritedData.overflow = new StyleEnum <OverflowInternal>((OverflowInternal)sv.number, sv.keyword); break; case StylePropertyId.PaddingBottom: nonInheritedData.paddingBottom = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.PaddingLeft: nonInheritedData.paddingLeft = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.PaddingRight: nonInheritedData.paddingRight = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.PaddingTop: nonInheritedData.paddingTop = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.Position: nonInheritedData.position = new StyleEnum <Position>((Position)sv.number, sv.keyword); break; case StylePropertyId.Right: nonInheritedData.right = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.TextOverflow: nonInheritedData.textOverflow = new StyleEnum <TextOverflow>((TextOverflow)sv.number, sv.keyword); break; case StylePropertyId.Top: nonInheritedData.top = new StyleLength(sv.length, sv.keyword); break; case StylePropertyId.UnityBackgroundImageTintColor: nonInheritedData.unityBackgroundImageTintColor = new StyleColor(sv.color, sv.keyword); break; case StylePropertyId.UnityBackgroundScaleMode: nonInheritedData.unityBackgroundScaleMode = new StyleEnum <ScaleMode>((ScaleMode)sv.number, sv.keyword); break; case StylePropertyId.UnityFont: inheritedData.unityFont = new StyleFont(sv.resource, sv.keyword); break; case StylePropertyId.UnityFontStyleAndWeight: inheritedData.unityFontStyleAndWeight = new StyleEnum <FontStyle>((FontStyle)sv.number, sv.keyword); break; case StylePropertyId.UnityOverflowClipBox: nonInheritedData.unityOverflowClipBox = new StyleEnum <OverflowClipBox>((OverflowClipBox)sv.number, sv.keyword); break; case StylePropertyId.UnitySliceBottom: nonInheritedData.unitySliceBottom = new StyleInt((int)sv.number, sv.keyword); break; case StylePropertyId.UnitySliceLeft: nonInheritedData.unitySliceLeft = new StyleInt((int)sv.number, sv.keyword); break; case StylePropertyId.UnitySliceRight: nonInheritedData.unitySliceRight = new StyleInt((int)sv.number, sv.keyword); break; case StylePropertyId.UnitySliceTop: nonInheritedData.unitySliceTop = new StyleInt((int)sv.number, sv.keyword); break; case StylePropertyId.UnityTextAlign: inheritedData.unityTextAlign = new StyleEnum <TextAnchor>((TextAnchor)sv.number, sv.keyword); break; case StylePropertyId.UnityTextOverflowPosition: nonInheritedData.unityTextOverflowPosition = new StyleEnum <TextOverflowPosition>((TextOverflowPosition)sv.number, sv.keyword); break; case StylePropertyId.Visibility: inheritedData.visibility = new StyleEnum <Visibility>((Visibility)sv.number, sv.keyword); break; case StylePropertyId.WhiteSpace: inheritedData.whiteSpace = new StyleEnum <WhiteSpace>((WhiteSpace)sv.number, sv.keyword); break; case StylePropertyId.Width: nonInheritedData.width = new StyleLength(sv.length, sv.keyword); break; default: Debug.LogAssertion($"Unexpected property id {sv.id}"); break; } }
public static bool StartAnimationInlineRotate(VisualElement element, ref ComputedStyle computedStyle, StyleRotate rotate, int durationMs, int delayMs, Func <float, float> easingCurve) { var to = rotate.keyword == StyleKeyword.Initial ? InitialStyle.rotate : rotate.value; return(element.styleAnimation.Start(StylePropertyId.Rotate, computedStyle.transformData.Read().rotate, to, durationMs, delayMs, easingCurve)); }
public void CopyFrom(ComputedStyle other) { inheritedData = other.inheritedData; nonInheritedData = other.nonInheritedData; }
public void ApplyInlineStyles(ref ComputedStyle computedStyle) { // Apply inline rule coming from UXML if any var parent = ve.hierarchy.parent; ref var parentStyle = ref parent?.computedStyle != null ? ref parent.computedStyle : ref InitialStyle.Get();
public static void SetValue(Int64 hash, ref ComputedStyle data) { // No need to acquire ComputedStyle here because it's freshly created and already has the correct ref count s_ComputedStyleCache[hash] = data; }