public static void ApplyDisplay(IStylePropertyReader reader, ref StyleInt property) { if (reader.IsKeyword(0, StyleValueKeyword.None)) { StyleInt none = new StyleInt((int)DisplayStyle.None) { specificity = reader.specificity }; property = none; return; } if (!reader.IsValueType(0, StyleValueType.Enum)) { Debug.LogError("Invalid value for display property " + reader.ReadAsString(0)); return; } property = reader.ReadStyleEnum <DisplayStyle>(0); }
public static void ApplyAlign(IStylePropertyReader reader, ref StyleInt property) { if (reader.IsKeyword(0, StyleValueKeyword.Auto)) { StyleInt auto = new StyleInt((int)Align.Auto) { specificity = reader.specificity }; property = auto; return; } if (!reader.IsValueType(0, StyleValueType.Enum)) { Debug.LogError("Invalid value for align property " + reader.ReadAsString(0)); return; } property = reader.ReadStyleEnum <Align>(0); }
internal void ApplyStyleProperty(IStylePropertyReader reader) { switch (reader.propertyID) { case StylePropertyID.AlignContent: StyleSheetApplicator.ApplyAlign(reader, ref alignContent); break; case StylePropertyID.AlignItems: StyleSheetApplicator.ApplyAlign(reader, ref alignItems); break; case StylePropertyID.AlignSelf: StyleSheetApplicator.ApplyAlign(reader, ref alignSelf); break; case StylePropertyID.BackgroundImage: backgroundImage = reader.ReadStyleBackground(0); break; case StylePropertyID.FlexBasis: flexBasis = reader.ReadStyleLength(0); break; case StylePropertyID.FlexGrow: flexGrow = reader.ReadStyleFloat(0); break; case StylePropertyID.FlexShrink: flexShrink = reader.ReadStyleFloat(0); break; case StylePropertyID.Font: unityFont = reader.ReadStyleFont(0); break; case StylePropertyID.FontSize: fontSize = reader.ReadStyleLength(0); break; case StylePropertyID.FontStyleAndWeight: unityFontStyleAndWeight = reader.ReadStyleEnum <FontStyle>(0); break; case StylePropertyID.FlexDirection: flexDirection = reader.ReadStyleEnum <FlexDirection>(0); break; case StylePropertyID.FlexWrap: flexWrap = reader.ReadStyleEnum <Wrap>(0); break; case StylePropertyID.Height: height = reader.ReadStyleLength(0); break; case StylePropertyID.JustifyContent: justifyContent = reader.ReadStyleEnum <Justify>(0); break; case StylePropertyID.MarginLeft: marginLeft = reader.ReadStyleLength(0); break; case StylePropertyID.MarginTop: marginTop = reader.ReadStyleLength(0); break; case StylePropertyID.MarginRight: marginRight = reader.ReadStyleLength(0); break; case StylePropertyID.MarginBottom: marginBottom = reader.ReadStyleLength(0); break; case StylePropertyID.MaxHeight: maxHeight = reader.ReadStyleLength(0); break; case StylePropertyID.MaxWidth: maxWidth = reader.ReadStyleLength(0); break; case StylePropertyID.MinHeight: minHeight = reader.ReadStyleLength(0); break; case StylePropertyID.MinWidth: minWidth = reader.ReadStyleLength(0); break; case StylePropertyID.Overflow: overflow = reader.ReadStyleEnum <OverflowInternal>(0); break; case StylePropertyID.OverflowClipBox: unityOverflowClipBox = reader.ReadStyleEnum <OverflowClipBox>(0); break; case StylePropertyID.PaddingLeft: paddingLeft = reader.ReadStyleLength(0); break; case StylePropertyID.PaddingTop: paddingTop = reader.ReadStyleLength(0); break; case StylePropertyID.PaddingRight: paddingRight = reader.ReadStyleLength(0); break; case StylePropertyID.PaddingBottom: paddingBottom = reader.ReadStyleLength(0); break; case StylePropertyID.Position: position = reader.ReadStyleEnum <Position>(0); break; case StylePropertyID.PositionTop: top = reader.ReadStyleLength(0); break; case StylePropertyID.PositionBottom: bottom = reader.ReadStyleLength(0); break; case StylePropertyID.PositionLeft: left = reader.ReadStyleLength(0); break; case StylePropertyID.PositionRight: right = reader.ReadStyleLength(0); break; case StylePropertyID.UnityTextAlign: unityTextAlign = reader.ReadStyleEnum <TextAnchor>(0); break; case StylePropertyID.Color: color = reader.ReadStyleColor(0); break; case StylePropertyID.Width: width = reader.ReadStyleLength(0); break; case StylePropertyID.WhiteSpace: whiteSpace = reader.ReadStyleEnum <WhiteSpace>(0); break; case StylePropertyID.BackgroundColor: backgroundColor = reader.ReadStyleColor(0); break; case StylePropertyID.BackgroundScaleMode: unityBackgroundScaleMode = reader.ReadStyleEnum <ScaleMode>(0); break; case StylePropertyID.BackgroundImageTintColor: unityBackgroundImageTintColor = reader.ReadStyleColor(0); break; case StylePropertyID.BorderLeftColor: borderLeftColor = reader.ReadStyleColor(0); break; case StylePropertyID.BorderTopColor: borderTopColor = reader.ReadStyleColor(0); break; case StylePropertyID.BorderRightColor: borderRightColor = reader.ReadStyleColor(0); break; case StylePropertyID.BorderBottomColor: borderBottomColor = reader.ReadStyleColor(0); break; case StylePropertyID.BorderLeftWidth: borderLeftWidth = reader.ReadStyleFloat(0); break; case StylePropertyID.BorderTopWidth: borderTopWidth = reader.ReadStyleFloat(0); break; case StylePropertyID.BorderRightWidth: borderRightWidth = reader.ReadStyleFloat(0); break; case StylePropertyID.BorderBottomWidth: borderBottomWidth = reader.ReadStyleFloat(0); break; case StylePropertyID.BorderTopLeftRadius: borderTopLeftRadius = reader.ReadStyleLength(0); break; case StylePropertyID.BorderTopRightRadius: borderTopRightRadius = reader.ReadStyleLength(0); break; case StylePropertyID.BorderBottomRightRadius: borderBottomRightRadius = reader.ReadStyleLength(0); break; case StylePropertyID.BorderBottomLeftRadius: borderBottomLeftRadius = reader.ReadStyleLength(0); break; case StylePropertyID.Cursor: cursor = reader.ReadStyleCursor(0); break; case StylePropertyID.SliceLeft: unitySliceLeft = reader.ReadStyleInt(0); break; case StylePropertyID.SliceTop: unitySliceTop = reader.ReadStyleInt(0); break; case StylePropertyID.SliceRight: unitySliceRight = reader.ReadStyleInt(0); break; case StylePropertyID.SliceBottom: unitySliceBottom = reader.ReadStyleInt(0); break; case StylePropertyID.Opacity: opacity = reader.ReadStyleFloat(0); break; case StylePropertyID.Visibility: visibility = reader.ReadStyleEnum <Visibility>(0); break; case StylePropertyID.Display: StyleSheetApplicator.ApplyDisplay(reader, ref display); break; default: throw new ArgumentException(string.Format("Non exhaustive switch statement (value={0})", reader.propertyID)); } }