Exemple #1
0
        private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
        {
            // We should consider not exposing image as a style at all, since it's intimately tied to uv/sourceRect
            Texture2D    textureValue = null;
            string       scaleModeValue;
            Color        tintValue   = Color.white;
            ICustomStyle customStyle = e.customStyle;

            if (!m_ImageIsInline && customStyle.TryGetValue(s_ImageProperty, out textureValue))
            {
                m_Image = textureValue;
            }

            if (!m_ScaleModeIsInline && customStyle.TryGetValue(s_ScaleModeProperty, out scaleModeValue))
            {
                int scaleModeIntValue;

                if (StyleSheetCache.TryParseEnum <ScaleMode>(scaleModeValue, out scaleModeIntValue))
                {
                    m_ScaleMode = (ScaleMode)scaleModeIntValue;
                }
            }

            if (!m_TintColorIsInline && customStyle.TryGetValue(s_TintColorProperty, out tintValue))
            {
                m_TintColor = tintValue;
            }
        }
        private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
        {
            int height = 0;

            if (!m_ItemHeightIsInline && e.customStyle.TryGetValue(s_ItemHeightProperty, out height))
            {
                itemHeight = height;
            }
        }
        private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
        {
            var oldHeight = m_ListView.itemHeight;
            int height    = 0;

            if (!m_ListView.m_ItemHeightIsInline && e.customStyle.TryGetValue(ListView.s_ItemHeightProperty, out height))
            {
                m_ListView.m_ItemHeight = height;
            }

            if (m_ListView.m_ItemHeight != oldHeight)
            {
                m_ListView.Refresh();
            }
        }
Exemple #4
0
        private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
        {
            int  itemHeight = this.m_ListView.itemHeight;
            int  itemHeight2;
            bool flag = !this.m_ListView.m_ItemHeightIsInline && e.customStyle.TryGetValue(ListView.s_ItemHeightProperty, out itemHeight2);

            if (flag)
            {
                this.m_ListView.m_ItemHeight = itemHeight2;
            }
            bool flag2 = this.m_ListView.m_ItemHeight != itemHeight;

            if (flag2)
            {
                this.m_ListView.Refresh();
            }
        }
            private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
            {
                Color selectionValue = Color.clear;
                Color cursorValue    = Color.clear;

                ICustomStyle customStyle = e.customStyle;

                if (customStyle.TryGetValue(s_SelectionColorProperty, out selectionValue))
                {
                    m_SelectionColor = selectionValue;
                }

                if (customStyle.TryGetValue(s_CursorColorProperty, out cursorValue))
                {
                    m_CursorColor = cursorValue;
                }

                SyncGUIStyle(this, editorEngine.style);
            }
            private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
            {
                Color        clear       = Color.clear;
                Color        clear2      = Color.clear;
                ICustomStyle customStyle = e.customStyle;
                bool         flag        = customStyle.TryGetValue(TextInputBaseField <TValueType> .s_SelectionColorProperty, out clear);

                if (flag)
                {
                    this.m_SelectionColor = clear;
                }
                bool flag2 = customStyle.TryGetValue(TextInputBaseField <TValueType> .s_CursorColorProperty, out clear2);

                if (flag2)
                {
                    this.m_CursorColor = clear2;
                }
                TextInputBaseField <TValueType> .TextInputBase.SyncGUIStyle(this, this.editorEngine.style);
            }
Exemple #7
0
        private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
        {
            // We should consider not exposing image as a style at all, since it's intimately tied to uv/sourceRect
            Texture2D    textureValue     = null;
            Sprite       spriteValue      = null;
            VectorImage  vectorImageValue = null;
            string       scaleModeValue;
            Color        tintValue   = Color.white;
            ICustomStyle customStyle = e.customStyle;

            if (!m_ImageIsInline && customStyle.TryGetValue(s_ImageProperty, out textureValue))
            {
                m_Image       = textureValue;
                m_Sprite      = null;
                m_VectorImage = null;
            }

            if (!m_ImageIsInline && customStyle.TryGetValue(s_SpriteProperty, out spriteValue))
            {
                m_Image       = null;
                m_Sprite      = spriteValue;
                m_VectorImage = null;
            }

            if (!m_ImageIsInline && customStyle.TryGetValue(s_VectorImageProperty, out vectorImageValue))
            {
                m_Image       = null;
                m_Sprite      = null;
                m_VectorImage = vectorImageValue;
            }

            if (!m_ScaleModeIsInline && customStyle.TryGetValue(s_ScaleModeProperty, out scaleModeValue))
            {
                StylePropertyUtil.TryGetEnumIntValue(StyleEnumType.ScaleMode, scaleModeValue, out var intValue);
                SetScaleMode((ScaleMode)intValue);
            }

            if (!m_TintColorIsInline && customStyle.TryGetValue(s_TintColorProperty, out tintValue))
            {
                m_TintColor = tintValue;
            }
        }
        private void OnCustomStyleResolved(CustomStyleResolvedEvent e)
        {
            Texture2D    image       = null;
            VectorImage  vectorImage = null;
            Color        white       = Color.white;
            ICustomStyle customStyle = e.customStyle;
            bool         flag        = !this.m_ImageIsInline && customStyle.TryGetValue(Image.s_ImageProperty, out image);

            if (flag)
            {
                this.m_Image = image;
                bool flag2 = this.m_Image != null;
                if (flag2)
                {
                    this.m_VectorImage = null;
                }
            }
            bool flag3 = !this.m_ImageIsInline && customStyle.TryGetValue(Image.s_VectorImageProperty, out vectorImage);

            if (flag3)
            {
                this.m_VectorImage = vectorImage;
                bool flag4 = this.m_VectorImage != null;
                if (flag4)
                {
                    this.m_Image = null;
                }
            }
            string value;
            bool   flag5 = !this.m_ScaleModeIsInline && customStyle.TryGetValue(Image.s_ScaleModeProperty, out value);

            if (flag5)
            {
                this.m_ScaleMode = (ScaleMode)StylePropertyUtil.GetEnumIntValue(StyleEnumType.ScaleMode, value);
            }
            bool flag6 = !this.m_TintColorIsInline && customStyle.TryGetValue(Image.s_TintColorProperty, out white);

            if (flag6)
            {
                this.m_TintColor = white;
            }
        }
Exemple #9
0
        public override void TraverseRecursive(VisualElement element, int depth)
        {
            if (ShouldSkipElement(element))
            {
                return;
            }

            // If the element is fully dirty, we need to erase those flags since the full element and its subtree
            // will be re-styled.
            // If the element is not in the update list, it's a parent of something dirty and therefore it won't be restyled.
            bool updateElement = m_UpdateList.Contains(element);

            if (updateElement)
            {
                element.triggerPseudoMask    = 0;
                element.dependencyPseudoMask = 0;
            }

            int originalStyleSheetCount = m_StyleMatchingContext.styleSheetStack.Count;

            if (element.styleSheetList != null)
            {
                for (var index = 0; index < element.styleSheetList.Count; index++)
                {
                    var styleSheetData = element.styleSheetList[index];
                    m_StyleMatchingContext.styleSheetStack.Add(styleSheetData);
                }
            }

            // Store the number of custom style before processing rules in case an element stop
            // to have matching custom styles the event still need to be sent and only looking
            // at the matched custom styles won't suffice.
            int originalCustomStyleCount = element.computedStyle.customPropertiesCount;

            if (updateElement)
            {
                m_StyleMatchingContext.currentElement = element;

                StyleSelectorHelper.FindMatches(m_StyleMatchingContext, m_TempMatchResults);

                ProcessMatchedRules(element, m_TempMatchResults);

                element.inheritedStylesHash           = element.computedStyle.inheritedData.GetHashCode();
                m_StyleMatchingContext.currentElement = null;
                m_TempMatchResults.Clear();
            }
            else
            {
                m_StyleMatchingContext.variableContext = element.variableContext;
            }

            // Need to send the custom styles event after the inheritance is resolved because an element
            // may want to read standard styles too (TextInputFieldBase callback depends on it).
            if (updateElement && (originalCustomStyleCount > 0 || element.computedStyle.customPropertiesCount > 0))
            {
                using (var evt = CustomStyleResolvedEvent.GetPooled())
                {
                    evt.target = element;
                    element.SendEvent(evt);
                }
            }

            Recurse(element, depth);


            if (m_StyleMatchingContext.styleSheetStack.Count > originalStyleSheetCount)
            {
                m_StyleMatchingContext.styleSheetStack.RemoveRange(originalStyleSheetCount, m_StyleMatchingContext.styleSheetStack.Count - originalStyleSheetCount);
            }
        }
 private void OnFieldCustomStyleResolved(CustomStyleResolvedEvent e)
 {
     m_TextInputBase.OnInputCustomStyleResolved(e);
 }