示例#1
0
        public void RefreshUI()
        {
            // On the first RefreshUI, if an element is already selected, we need to make sure it
            // has a valid style. If not, we need to delay our UI building until it is properly initialized.
            if (currentVisualElement != null && float.IsNaN(currentVisualElement.layout.width))
            {
                currentVisualElement.RegisterCallback <GeometryChangedEvent>(RefreshAfterFirstInit);
                return;
            }

            // Determine what to show based on selection.
            ResetSections();
            switch (m_Selection.selectionType)
            {
            case BuilderSelectionType.Nothing:
                EnableSections(Section.NothingSelected);
                return;

            case BuilderSelectionType.StyleSheet:
                EnableSections(Section.StyleSheet);
                return;

            case BuilderSelectionType.StyleSelector:
                EnableSections(
                    Section.StyleSelector |
                    Section.LocalStyles);
                break;

            case BuilderSelectionType.ElementInTemplateInstance:
            case BuilderSelectionType.Element:
                EnableSections(
                    Section.ElementAttributes |
                    Section.ElementInheritedStyles |
                    Section.LocalStyles);
                break;

            case BuilderSelectionType.VisualTreeAsset:
                EnableSections(Section.VisualTreeAsset);
                return;
            }
            if (m_Selection.selectionType == BuilderSelectionType.ElementInTemplateInstance)
            {
                DisableFields();
            }

            // Bind the style selector controls.
            m_SelectorSection.Refresh();

            // Recreate Attribute Fields
            m_AttributesSection.Refresh();

            // Reset current style rule.
            currentRule = null;

            // Get all shared style selectors and draw their fields.
            m_MatchingSelectors.GetElementMatchers();
            m_InheritedStyleSection.Refresh();

            // Create the fields for the overridable styles.
            m_LocalStylesSection.Refresh();
        }
示例#2
0
        public void RefreshUI()
        {
            // On the first RefreshUI, if an element is already selected, we need to make sure it
            // has a valid style. If not, we need to delay our UI building until it is properly initialized.
            if (currentVisualElement != null &&
                // TODO: This is just for tests to pass. When adding selectors via the fake events
                // we sometimes get selector elements that have no layout and will not layout
                // no matter how many yields we add. They do have the correct panel.
                m_Selection.selectionType != BuilderSelectionType.StyleSelector &&
                float.IsNaN(currentVisualElement.layout.width))
            {
                currentVisualElement.RegisterCallback <GeometryChangedEvent>(RefreshAfterFirstInit);
                return;
            }

            // Determine what to show based on selection.
            ResetSections();
            if (m_Selection.selectionCount > 1)
            {
                EnableSections(Section.MultiSelection);
                return;
            }
            switch (m_Selection.selectionType)
            {
            case BuilderSelectionType.Nothing:
                EnableSections(Section.NothingSelected);
                return;

            case BuilderSelectionType.StyleSheet:
                EnableSections(Section.StyleSheet);
                return;

            case BuilderSelectionType.StyleSelector:
                EnableSections(
                    Section.StyleSelector |
                    Section.LocalStyles);
                break;

            case BuilderSelectionType.ElementInTemplateInstance:
            case BuilderSelectionType.Element:
                EnableSections(
                    Section.ElementAttributes |
                    Section.ElementInheritedStyles |
                    Section.LocalStyles);
                break;

            case BuilderSelectionType.VisualTreeAsset:
                EnableSections(Section.VisualTreeAsset);
                m_CanvasSection.Refresh();
                return;
            }
            if (m_Selection.selectionType == BuilderSelectionType.ElementInTemplateInstance)
            {
                DisableFields();
            }

            // Bind the style selector controls.
            m_SelectorSection.Refresh();

            // Recreate Attribute Fields
            m_AttributesSection.Refresh();

            // Reset current style rule.
            currentRule = null;

            // Get all shared style selectors and draw their fields.
            m_MatchingSelectors.GetElementMatchers();
            m_InheritedStyleSection.Refresh();

            // Create the fields for the overridable styles.
            m_LocalStylesSection.Refresh();

            m_CanvasSection.Refresh();
        }