コード例 #1
0
            public override void ProcessMatchedRules(VisualElement element)
            {
                VisualElementStylesData resolvedStyles;

                if (s_StyleCache.TryGetValue(m_MatchingRulesHash, out resolvedStyles))
                {
                    // we should not new it in StyleTree
                    element.SetSharedStyles(resolvedStyles);
                }
                else
                {
                    resolvedStyles = new VisualElementStylesData(isShared: true);

                    for (int i = 0, ruleCount = m_MatchedRules.Count; i < ruleCount; i++)
                    {
                        RuleRef           ruleRef     = m_MatchedRules[i];
                        StylePropertyID[] propertyIDs = StyleSheetCache.GetPropertyIDs(ruleRef.sheet, ruleRef.selector.ruleIndex);
                        resolvedStyles.ApplyRule(ruleRef.sheet, ruleRef.selector.specificity, ruleRef.selector.rule, propertyIDs);
                    }

                    s_StyleCache[m_MatchingRulesHash] = resolvedStyles;

                    element.SetSharedStyles(resolvedStyles);
                }
            }
コード例 #2
0
            public override void ProcessMatchedRules(VisualElement element)
            {
                VisualElementStylesData visualElementStylesData;

                if (StyleContext.s_StyleCache.TryGetValue(this.m_MatchingRulesHash, out visualElementStylesData))
                {
                    element.SetSharedStyles(visualElementStylesData);
                }
                else
                {
                    visualElementStylesData = new VisualElementStylesData(true);
                    int i     = 0;
                    int count = this.m_MatchedRules.Count;
                    while (i < count)
                    {
                        StyleContext.RuleRef ruleRef     = this.m_MatchedRules[i];
                        StylePropertyID[]    propertyIDs = StyleSheetCache.GetPropertyIDs(ruleRef.sheet, ruleRef.selector.ruleIndex);
                        visualElementStylesData.ApplyRule(ruleRef.sheet, ruleRef.selector.specificity, ruleRef.selector.rule, propertyIDs);
                        i++;
                    }
                    StyleContext.s_StyleCache[this.m_MatchingRulesHash] = visualElementStylesData;
                    element.SetSharedStyles(visualElementStylesData);
                }
            }
コード例 #3
0
            public static void ApplyBorderRadius(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData)
            {
                float topLeft;
                float topRight;
                float bottomLeft;
                float bottomRight;

                ReadFourSidesArea(sheet, handles, out topLeft, out topRight, out bottomRight, out bottomLeft);

                Apply(topLeft, specificity, ref styleData.borderTopLeftRadius);
                Apply(topRight, specificity, ref styleData.borderTopRightRadius);
                Apply(bottomLeft, specificity, ref styleData.borderBottomLeftRadius);
                Apply(bottomRight, specificity, ref styleData.borderBottomRightRadius);
            }
コード例 #4
0
            public static void ApplyPadding(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData)
            {
                float top;
                float right;
                float bottom;
                float left;

                ReadFourSidesArea(sheet, handles, out top, out right, out bottom, out left);

                Apply(top, specificity, ref styleData.paddingTop);
                Apply(right, specificity, ref styleData.paddingRight);
                Apply(bottom, specificity, ref styleData.paddingBottom);
                Apply(left, specificity, ref styleData.paddingLeft);
            }
コード例 #5
0
        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);
        }
コード例 #6
0
        public static void ApplyFlexShorthand(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData)
        {
            float          grow;
            float          shrink;
            FloatOrKeyword basis;
            bool           valid = CompileFlexShorthand(sheet, handles, out grow, out shrink, out basis);

            if (valid)
            {
                ApplyValue(specificity, ref styleData.flexGrow, grow);
                ApplyValue(specificity, ref styleData.flexShrink, shrink);
                ApplyValue(specificity, ref styleData.flexBasis, basis);
            }
        }
コード例 #7
0
 public static void ApplyShorthand(this StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData, ShorthandApplicatorFunction applicatorFunc)
 {
     if (handles[0].valueType != StyleValueType.Keyword && handles[0].valueIndex != 2)
     {
         applicatorFunc(sheet, handles, specificity, styleData);
     }
 }
コード例 #8
0
            public static void ApplyPadding(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData)
            {
                float val;
                float val2;
                float val3;
                float val4;

                StyleSheetApplicator.Shorthand.ReadFourSidesArea(sheet, handles, out val, out val2, out val3, out val4);
                StyleSheetApplicator.Apply <float>(val, specificity, ref styleData.paddingTop);
                StyleSheetApplicator.Apply <float>(val2, specificity, ref styleData.paddingRight);
                StyleSheetApplicator.Apply <float>(val3, specificity, ref styleData.paddingBottom);
                StyleSheetApplicator.Apply <float>(val4, specificity, ref styleData.paddingLeft);
            }
コード例 #9
0
            public static void ApplyBorderRadius(StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData)
            {
                float val;
                float val2;
                float val3;
                float val4;

                StyleSheetApplicator.Shorthand.ReadFourSidesArea(sheet, handles, out val, out val2, out val3, out val4);
                StyleSheetApplicator.Apply <float>(val, specificity, ref styleData.borderTopLeftRadius);
                StyleSheetApplicator.Apply <float>(val2, specificity, ref styleData.borderTopRightRadius);
                StyleSheetApplicator.Apply <float>(val4, specificity, ref styleData.borderBottomLeftRadius);
                StyleSheetApplicator.Apply <float>(val3, specificity, ref styleData.borderBottomRightRadius);
            }
コード例 #10
0
 public static void ApplyShorthand(this StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData, ShorthandApplicatorFunction applicatorFunc)
 {
     // applicatorFunc should handle Unset.
     applicatorFunc(sheet, handles, specificity, styleData);
 }
コード例 #11
0
 public static void ApplyShorthand(this StyleSheet sheet, StyleValueHandle[] handles, int specificity, VisualElementStylesData styleData, ShorthandApplicatorFunction applicatorFunc)
 {
     // Do not apply anything if shorthand is equal to unset
     if (handles[0].valueType != StyleValueType.Keyword && handles[0].valueIndex != (int)StyleValueKeyword.Unset)
     {
         applicatorFunc(sheet, handles, specificity, styleData);
     }
 }