コード例 #1
0
        private bool InterceptEvents(Event ev)
        {
            if (!m_CurPanel.HasValue)
            {
                return(false);
            }
            if (Event.current == null || !Event.current.isMouse)
            {
                return(false);
            }
            VisualElement e = m_CurPanel.Value.Panel.Pick(ev.mousePosition);

            if (e != null)
            {
                ((PanelDebug)m_CurPanel.Value.Panel.panelDebug).highlightedElement = e.controlid;
            }

            // stop intercepting events
            if (ev.clickCount > 0 && ev.button == 0)
            {
                m_CurPanel.Value.Panel.panelDebug.interceptEvents = null;
                m_PickingElementInPanel = false;
                m_VisualTreeTreeView.ExpandAll();
                VisualTreeItem node = m_VisualTreeTreeView.GetRows()
                                      .OfType <VisualTreeItem>()
                                      .FirstOrDefault(vti => e != null && vti.elt.controlid == e.controlid);
                if (node != null)
                {
                    m_VisualTreeTreeView.SetSelection(new List <int> {
                        node.id
                    }, TreeViewSelectionOptions.RevealAndFrame);
                }
            }
            return(true);
        }
コード例 #2
0
        private void Recurse(TreeViewItem tree, VisualElement elt)
        {
            VisualTreeItem visualTreeItem = new VisualTreeItem(elt, tree.depth + 1);

            tree.AddChild(visualTreeItem);
            IEnumerable <VisualElement> enumerable = (!this.includeShadowHierarchy) ? ((elt.contentContainer != null) ? elt.Children() : Enumerable.Empty <VisualElement>()) : elt.shadow.Children();

            foreach (VisualElement current in enumerable)
            {
                this.Recurse(visualTreeItem, current);
            }
        }
コード例 #3
0
        private void Recurse(TreeViewItem tree, VisualElement elt)
        {
            var child = new VisualTreeItem(elt, tree.depth + 1);

            tree.AddChild(child);

            IEnumerable <VisualElement> childElements = includeShadowHierarchy
                ? elt.shadow.Children()
                : (elt.contentContainer == null ? Enumerable.Empty <VisualElement>() : elt.Children());

            foreach (VisualElement childElement in childElements)
            {
                Recurse(child, childElement);
            }
        }
コード例 #4
0
        private void CacheData()
        {
            if (!m_VisualTreeTreeView.HasSelection())
            {
                m_SelectedElement  = null;
                m_UxmlDumpExpanded = false;
                m_ClassList        = null;

                if (!m_PickingElementInPanel && m_CurPanel.HasValue && m_CurPanel.Value.Panel != null && m_CurPanel.Value.Panel.panelDebug != null)
                {
                    ((PanelDebug)m_CurPanel.Value.Panel.panelDebug).highlightedElement = 0;
                }
                return;
            }

            int            selectedId   = m_VisualTreeTreeView.GetSelection().First();
            VisualTreeItem selectedItem = m_VisualTreeTreeView.GetNodeFor(selectedId);

            if (selectedItem == null)
            {
                return;
            }

            VisualElement element = selectedItem.elt;

            if (element == null)
            {
                return;
            }

            if (!m_CurPanel.HasValue)
            {
                return;
            }
            if (m_SelectedElement != element)
            {
                m_SelectedElement     = element;
                m_SelectedElementUxml = null;
                m_ClassList           = null;
            }

            // element picking uses the highlight
            if (!m_PickingElementInPanel)
            {
                ((PanelDebug)m_CurPanel.Value.Panel.panelDebug).highlightedElement = element.controlid;
            }
            GetElementMatchers();
        }
コード例 #5
0
 private void CacheData()
 {
     if (!this.m_VisualTreeTreeView.HasSelection())
     {
         this.m_SelectedElement  = null;
         this.m_UxmlDumpExpanded = false;
         this.m_ClassList        = null;
         if (!this.m_PickingElementInPanel && this.m_CurPanel.HasValue && this.m_CurPanel.Value.Panel != null && this.m_CurPanel.Value.Panel.panelDebug != null)
         {
             ((PanelDebug)this.m_CurPanel.Value.Panel.panelDebug).highlightedElement = 0u;
         }
     }
     else
     {
         int            selectedId = this.m_VisualTreeTreeView.GetSelection().First <int>();
         VisualTreeItem nodeFor    = this.m_VisualTreeTreeView.GetNodeFor(selectedId);
         if (nodeFor != null)
         {
             VisualElement elt = nodeFor.elt;
             if (elt != null)
             {
                 if (this.m_CurPanel.HasValue)
                 {
                     if (this.m_SelectedElement != elt)
                     {
                         this.m_SelectedElement     = elt;
                         this.m_SelectedElementUxml = null;
                         this.m_ClassList           = null;
                     }
                     if (!this.m_PickingElementInPanel)
                     {
                         ((PanelDebug)this.m_CurPanel.Value.Panel.panelDebug).highlightedElement = elt.controlid;
                     }
                     this.GetElementMatchers();
                 }
             }
         }
     }
 }
コード例 #6
0
        private bool InterceptEvents(Event ev)
        {
            bool result;

            if (!this.m_CurPanel.HasValue)
            {
                result = false;
            }
            else if (Event.current == null || !Event.current.isMouse)
            {
                result = false;
            }
            else
            {
                VisualElement e = this.m_CurPanel.Value.Panel.Pick(ev.mousePosition);
                if (e != null)
                {
                    ((PanelDebug)this.m_CurPanel.Value.Panel.panelDebug).highlightedElement = e.controlid;
                }
                if (ev.clickCount > 0 && ev.button == 0)
                {
                    this.m_CurPanel.Value.Panel.panelDebug.interceptEvents = null;
                    this.m_PickingElementInPanel = false;
                    this.m_VisualTreeTreeView.ExpandAll();
                    VisualTreeItem visualTreeItem = this.m_VisualTreeTreeView.GetRows().OfType <VisualTreeItem>().FirstOrDefault((VisualTreeItem vti) => e != null && vti.elt.controlid == e.controlid);
                    if (visualTreeItem != null)
                    {
                        this.m_VisualTreeTreeView.SetSelection(new List <int>
                        {
                            visualTreeItem.id
                        }, TreeViewSelectionOptions.RevealAndFrame);
                    }
                }
                result = true;
            }
            return(result);
        }
コード例 #7
0
 public VisualTreeItem(VisualElement elt, int depth) : base((int)elt.controlid, depth, VisualTreeItem.GetDisplayName(elt))
 {
     this.elt = elt;
 }