Esempio n. 1
0
        public void Draw(GUIView currentInspectedView, Func <GUIView, bool> inspectableViewPredicator)
        {
            using (new GUILayout.HorizontalScope(EditorStyles.toolbar))
            {
                var selectedName = currentInspectedView is GUIView?currentInspectedView.GetViewTitleName() : "<Please Select>";

                var selectedNameLabel = GUIContentUtility.UseCached(selectedName);

                GUILayout.Label("Inspected View: ", GUILayout.ExpandWidth(false));

                var popupPosition = GUILayoutUtility.GetRect(selectedNameLabel, EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(true));
                if (GUI.Button(popupPosition, selectedNameLabel, EditorStyles.toolbarDropDown))
                {
                    var views = new List <GUIView>();
                    GUIViewDebuggerHelper.GetViews(views);
                    views = views.Where(inspectableViewPredicator).ToList();

                    var options = views
                                  .Select(x => x.GetViewTitleName())
                                  .Prepend("None")
                                  .Select(x => new GUIContent(x))
                                  .ToArray();

                    var selectedIndex = views.IndexOf(currentInspectedView) + 1;

                    EditorUtility.DisplayCustomMenu(popupPosition, options, selectedIndex, OnSelectInspectionValue.Invoke, views);
                }
            }
        }
Esempio n. 2
0
        public void ApplyHighlighting_ToUnmaskedViews_WhenPageOnlyContainsNarrativeParagraphs()
        {
            firstPage.m_Paragraphs[0].m_Type = ParagraphType.Narrative;
            firstPage.m_Paragraphs[0].maskingSettings.SetUnmaskedViews(new[] { UnmaskedView.CreateInstanceForGUIView <Toolbar>() });
            firstPage.m_Paragraphs[0].maskingSettings.enabled = true;
            firstPage.RaiseTutorialPageMaskingSettingsChangedEvent();

            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);

            // only the specified unmasked view should be highlighted
            var rects = new List <Rect>();

            foreach (var view in views)
            {
                if (view == Toolbar.get)
                {
                    Assert.IsTrue(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
                else
                {
                    Assert.IsFalse(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
            }
        }
Esempio n. 3
0
        public static IEnumerable <T> GetGraphViewWindows <T>(Type typeFilter) where T : EditorWindow
        {
            var guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);

            // Get all GraphViews used by existing tool windows of our type
            using (var it = UIElementsUtility.GetPanelsIterator())
            {
                while (it.MoveNext())
                {
                    var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea;
                    if (dockArea == null)
                    {
                        continue;
                    }

                    if (typeFilter == null)
                    {
                        foreach (var window in dockArea.m_Panes.OfType <T>())
                        {
                            yield return(window);
                        }
                    }
                    else
                    {
                        foreach (var window in dockArea.m_Panes.Where(p => p.GetType() == typeFilter).Cast <T>())
                        {
                            yield return(window);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void ApplyHighlighting_ToTutorialWindow_WhenAllTasksAreComplete()
        {
            firstPage.m_Paragraphs[0].maskingSettings.SetUnmaskedViews(new[] { UnmaskedView.CreateInstanceForGUIView <Toolbar>() });
            firstPage.m_Paragraphs[0].maskingSettings.enabled = true;
            firstPage.RaiseTutorialPageMaskingSettingsChangedEvent();

            firstPageCriterion.Complete(true);

            m_Window.RepaintImmediately();

            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);

            // only the tutorial window should be highlighted
            var rects = new List <Rect>();

            foreach (var view in views)
            {
                if (view == m_Window.m_Parent)
                {
                    Assert.IsTrue(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
                else
                {
                    Assert.IsFalse(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
            }
        }
Esempio n. 5
0
        public void ApplyMasking_WhenPageIsActivated()
        {
            firstPage.m_Paragraphs[0].maskingSettings.SetUnmaskedViews(new[] { UnmaskedView.CreateInstanceForGUIView <Toolbar>() });
            firstPage.m_Paragraphs[0].maskingSettings.enabled = true;
            firstPage.RaiseTutorialPageMaskingSettingsChangedEvent();
            //m_Window.RepaintImmediately(); TODO disabled, was causing problems after adding localisation support

            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);

            // the tutorial window and the specified unmasked view should both be unmasked
            var rects = new List <Rect>();

            foreach (var view in views)
            {
                if (view == m_Window.m_Parent || view == Toolbar.get || view is TooltipView)
                {
                    Assert.IsFalse(MaskingManager.IsMasked(new GUIViewProxy(view), rects));
                }
                else
                {
                    Assert.IsTrue(MaskingManager.IsMasked(new GUIViewProxy(view), rects));
                }
            }
        }
        public static void GetViews(List <GUIViewProxy> views)
        {
            var guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            views.AddRange(guiViews.Select(view => new GUIViewProxy(view)));
        }
Esempio n. 7
0
        public static T FindBoundGraphViewToolWindow <T>(VisualElement gv) where T : GraphViewToolWindowBridge
        {
            var guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);

            FieldInfo fieldInfo = typeof(T).GetField("m_SelectedGraphView", BindingFlags.Instance | BindingFlags.NonPublic);

            Assert.IsNotNull(fieldInfo);

            using (var it = UIElementsUtility.GetPanelsIterator())
            {
                while (it.MoveNext())
                {
                    var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea;
                    if (dockArea == null)
                    {
                        continue;
                    }

                    foreach (var graphViewTool in dockArea.m_Panes.OfType <T>())
                    {
                        var usedGv = (VisualElement)fieldInfo.GetValue(graphViewTool);
                        if (usedGv == gv)
                        {
                            return(graphViewTool);
                        }
                    }
                }
            }

            return(null);
        }
Esempio n. 8
0
        private void RefreshVisualTrees()
        {
            m_VisualTrees.Clear();

            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                HostView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as HostView;
                if (view == null)
                {
                    continue;
                }

                // Skip this window
                if (view.actualView == this)
                {
                    continue;
                }

                var panel     = it.Current.Value;
                var panelMode = UIRDebugUtility.GetPanelRepaintMode(panel);
                if (panelMode != RepaintMode.Standard)
                {
                    m_VisualTrees.Add(new VisualTreeDebug()
                    {
                        panel = panel
                    });
                }
            }
        }
Esempio n. 9
0
        public void ApplyHighlighting_ToAllUnmaskedWindowsAndViews_WhenMaskingSettingsOnlySpecifyEntireWindowsAndViews()
        {
            firstPage.m_Paragraphs[0].maskingSettings.SetUnmaskedViews(
                new[]
            {
                UnmaskedView.CreateInstanceForGUIView <Toolbar>(),
                UnmaskedView.CreateInstanceForGUIView <AppStatusBar>()
            }
                );
            firstPage.m_Paragraphs[0].maskingSettings.enabled = true;
            firstPage.RaiseTutorialPageMaskingSettingsChangedEvent();

            m_Window.RepaintImmediately();

            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);

            // both the toolbar and status bar should be highlighted
            var rects = new List <Rect>();

            foreach (var view in views)
            {
                if (view == Toolbar.get || view is AppStatusBar)
                {
                    Assert.IsTrue(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
                else
                {
                    Assert.IsFalse(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
            }
        }
Esempio n. 10
0
        public IEnumerator ApplyMasking_ToAllViewsExceptTutorialWindowAndTooltips_WhenRevisitingCompletedPage()
        {
            firstPage.m_Paragraphs[0].maskingSettings.SetUnmaskedViews(new[] { UnmaskedView.CreateInstanceForGUIView <Toolbar>() });
            firstPage.m_Paragraphs[0].maskingSettings.enabled = true;
            firstPage.RaiseTutorialPageMaskingSettingsChangedEvent();

            firstPageCriterion.Complete(true);

            m_Window.RepaintImmediately();

            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);

            // masking of final instruction still applied when it is complete
            var rects = new List <Rect>();

            foreach (var view in views)
            {
                if (view == m_Window.m_Parent || view == Toolbar.get || view is TooltipView)
                {
                    Assert.IsFalse(MaskingManager.IsMasked(new GUIViewProxy(view), rects));
                }
                else
                {
                    Assert.IsTrue(MaskingManager.IsMasked(new GUIViewProxy(view), rects));
                }
            }

            using (var automatedWindow = new AutomatedWindow <TutorialWindow>(m_Window))
            {
                m_Window.RepaintImmediately();

                // go to next page and then come back
                automatedWindow.Click(FindElementWithText(automatedWindow, nextButtonText, "next button"));
                yield return(null);

                m_Window.RepaintImmediately();
                automatedWindow.Click(FindElementWithStyle(automatedWindow, m_Window.allTutorialStyles.backButton, "back button"));
                yield return(null);

                m_Window.RepaintImmediately();
            }

            // now only tutorial window should be unmasked
            foreach (var view in views)
            {
                if (view == m_Window.m_Parent || view is TooltipView)
                {
                    Assert.IsFalse(MaskingManager.IsMasked(new GUIViewProxy(view), rects));
                }
                else
                {
                    Assert.IsTrue(MaskingManager.IsMasked(new GUIViewProxy(view), rects));
                }
            }
        }
Esempio n. 11
0
        public void Refresh()
        {
            m_Panels.Clear();

            var            it       = UIElementsUtility.GetPanelsIterator();
            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            bool setMax = false;
            Rect screen = new Rect(float.MaxValue, float.MaxValue, 0, 0);

            while (it.MoveNext())
            {
                GUIView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key);
                if (view == null)
                {
                    continue;
                }

                m_Panels.Add(new UIElementsDebugger.ViewPanel
                {
                    Panel = it.Current.Value,
                    View  = view
                });

                if (screen.xMin > view.screenPosition.xMin)
                {
                    screen.xMin = view.screenPosition.xMin;
                }
                if (screen.yMin > view.screenPosition.yMin)
                {
                    screen.yMin = view.screenPosition.yMin;
                }

                if (screen.xMax < view.screenPosition.xMax || !setMax)
                {
                    screen.xMax = view.screenPosition.xMax;
                }
                if (screen.yMax < view.screenPosition.yMax || !setMax)
                {
                    screen.yMax = view.screenPosition.yMax;
                }
                setMax = true;
            }

            m_Labels    = new GUIContent[m_Panels.Count + 1];
            m_Labels[0] = EditorGUIUtility.TrTextContent("Select a panel");
            for (int i = 0; i < m_Panels.Count; i++)
            {
                m_Labels[i + 1] = new GUIContent(GetName(m_Panels[i]));
            }

            screenRect = screen;
        }
Esempio n. 12
0
        public void Refresh()
        {
            this.m_Panels.Clear();
            Dictionary <int, Panel> .Enumerator it = UIElementsUtility.GetPanelsIterator();
            List <GUIView> list = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(list);
            bool flag = false;
            Rect rect = new Rect(3.40282347E+38f, 3.40282347E+38f, 0f, 0f);

            while (it.MoveNext())
            {
                GUIView gUIView = list.FirstOrDefault(delegate(GUIView v)
                {
                    int arg_19_0 = v.GetInstanceID();
                    KeyValuePair <int, Panel> current2 = it.Current;
                    return(arg_19_0 == current2.Key);
                });
                if (!(gUIView == null))
                {
                    List <UIElementsDebugger.ViewPanel> arg_A6_0 = this.m_Panels;
                    UIElementsDebugger.ViewPanel        item     = default(UIElementsDebugger.ViewPanel);
                    KeyValuePair <int, Panel>           current  = it.Current;
                    item.Panel = current.Value;
                    item.View  = gUIView;
                    arg_A6_0.Add(item);
                    if (rect.xMin > gUIView.screenPosition.xMin)
                    {
                        rect.xMin = gUIView.screenPosition.xMin;
                    }
                    if (rect.yMin > gUIView.screenPosition.yMin)
                    {
                        rect.yMin = gUIView.screenPosition.yMin;
                    }
                    if (rect.xMax < gUIView.screenPosition.xMax || !flag)
                    {
                        rect.xMax = gUIView.screenPosition.xMax;
                    }
                    if (rect.yMax < gUIView.screenPosition.yMax || !flag)
                    {
                        rect.yMax = gUIView.screenPosition.yMax;
                    }
                    flag = true;
                }
            }
            this.m_Labels    = new GUIContent[this.m_Panels.Count + 1];
            this.m_Labels[0] = EditorGUIUtility.TrTextContent("Select a panel", null, null);
            for (int i = 0; i < this.m_Panels.Count; i++)
            {
                this.m_Labels[i + 1] = new GUIContent(PickingData.GetName(this.m_Panels[i]));
            }
            this.screenRect = rect;
        }
        void RefreshPanelChoices()
        {
            m_GraphViewChoices.Clear();

            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                GUIView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key);
                if (view == null)
                {
                    continue;
                }

                DockArea dockArea = view as DockArea;
                if (dockArea == null)
                {
                    continue;
                }

                foreach (var graphViewEditor in dockArea.m_Panes.OfType <GraphViewEditorWindow>())
                {
                    int idx = 0;
                    foreach (var graphView in graphViewEditor.graphViews.Where(IsGraphViewSupported))
                    {
                        m_GraphViewChoices.Add(new GraphViewChoice {
                            window = graphViewEditor, idx = idx++, graphView = graphView
                        });
                    }
                }
            }

            var menu           = m_SelectorMenu.menu;
            var menuItemsCount = menu.MenuItems().Count;

            // Clear previous items (but not the "none" one at the top of the list)
            for (int i = menuItemsCount - 1; i > 0; i--)
            {
                menu.RemoveItemAt(i);
            }

            foreach (var graphView in m_GraphViewChoices)
            {
                menu.AppendAction(graphView.graphView.name, OnSelectGraphView,
                                  a => ((GraphViewChoice)a.userData).graphView == m_SelectedGraphView ?
                                  DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal,
                                  graphView);
            }
        }
Esempio n. 14
0
        private void DoViewsPanel()
        {
            GUILayout.Label("Views Panel", EditorStyles.boldLabel);
            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                HostView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as HostView;
                if (view == null)
                {
                    continue;
                }

                // Skip this window
                if (view.actualView == this)
                {
                    continue;
                }

                var    panel     = it.Current.Value;
                var    panelMode = UIRDebugUtility.GetPanelRepaintMode(panel);
                string name      = panel.name;
                var    mode      = (RepaintMode)EditorGUILayout.EnumPopup(name, panelMode);
                if (panelMode != mode)
                {
                    if (Panel.BeforeUpdaterChange != null)
                    {
                        Panel.BeforeUpdaterChange();
                    }
                    UIRDebugUtility.SwitchPanelRepaintMode(panel, mode);
                    if (mode == RepaintMode.UIR)
                    {
                        view.actualView.depthBufferBits = 24;
                    }
                    else
                    {
                        view.actualView.depthBufferBits = 0;
                    }
                    view.actualView.MakeParentsSettingsMatchMe();
                    if (Panel.AfterUpdaterChange != null)
                    {
                        Panel.AfterUpdaterChange();
                    }
                }
            }
        }
Esempio n. 15
0
        private void RefreshPanelChoices()
        {
            m_PanelChoices.Clear();
            m_PanelToEditorWindow.Clear();
            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                GUIView view = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key);
                if (view == null)
                {
                    continue;
                }

                // Skip this window
                HostView hostView = view as HostView;
                if (hostView != null && hostView.actualView == this)
                {
                    continue;
                }

                var p = it.Current.Value;
                m_PanelChoices.Add(new PanelChoice {
                    panel = p, name = p.name
                });
                if (hostView != null && hostView.actualView != null)
                {
                    m_PanelToEditorWindow.Add(p, hostView.actualView);
                }
            }

            var menu           = m_PanelSelect.menu;
            var menuItemsCount = menu.MenuItems().Count;

            // Clear previous items
            for (int i = 0; i < menuItemsCount; i++)
            {
                menu.RemoveItemAt(0);
            }

            foreach (var panelChoice in m_PanelChoices)
            {
                menu.AppendAction(panelChoice.ToString(), OnSelectPanel, DropdownMenuAction.AlwaysEnabled, panelChoice);
            }
        }
        public void ApplyHighlighting_ToOnlySpecifiedControls_WhenMaskingSettingsSpecifyControlsAndEntireWindowsAndViews()
        {
            var playButtonContrlSelector = new GuiControlSelector
            {
                SelectorMode = GuiControlSelector.Mode.NamedControl,
                ControlName  = "ToolbarPlayModePlayButton"
            };

            firstPage.m_Paragraphs[0].MaskingSettings.SetUnmaskedViews(
                new[]
            {
                UnmaskedView.CreateInstanceForGUIView <Toolbar>(new[] { playButtonContrlSelector }),
                UnmaskedView.CreateInstanceForGUIView <AppStatusBar>()
            }
                );
            firstPage.m_Paragraphs[0].MaskingSettings.Enabled = true;
            firstPage.RaiseTutorialPageMaskingSettingsChangedEvent();

            m_Window.RepaintImmediately();

            List <GUIView> views = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(views);

            // only the play button should be highlighted
            var rects = new List <Rect>();

            foreach (var view in views)
            {
                if (view == Toolbar.get)
                {
                    Assert.IsTrue(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                    Assert.AreEqual(1, rects.Count);
                    var viewPosition = view.position;
                    var controlRect  = rects[0];
                    Assert.Greater(controlRect.xMin, viewPosition.xMin);
                    Assert.Greater(controlRect.yMin, viewPosition.yMin);
                    Assert.Less(controlRect.xMax, viewPosition.xMax);
                    Assert.Less(controlRect.yMax, viewPosition.yMax);
                }
                else
                {
                    Assert.IsFalse(MaskingManager.IsHighlighted(new GUIViewProxy(view), rects));
                }
            }
        }
Esempio n. 17
0
        protected virtual void PopulatePanelChoices(List <IPanelChoice> panelChoices)
        {
            List <GUIView> guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);
            var it = UIElementsUtility.GetPanelsIterator();

            while (it.MoveNext())
            {
                // Skip this debugger window
                GUIView  view     = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key);
                HostView hostView = view as HostView;
                if (!m_DebuggerWindow.CanDebugView(hostView))
                {
                    continue;
                }

                var p = it.Current.Value;
                panelChoices.Add(new PanelChoice(p));
            }
        }
        void RefreshPanelChoices()
        {
            m_GraphViewChoices.Clear();

            var guiViews = new List <GUIView>();

            GUIViewDebuggerHelper.GetViews(guiViews);

            var usedGraphViews = new HashSet <GraphView>();

            // Get all GraphViews used by existing tool windows of our type
            using (var it = UIElementsUtility.GetPanelsIterator())
            {
                var currentWindowType = GetType();
                while (it.MoveNext())
                {
                    var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea;
                    if (dockArea == null)
                    {
                        continue;
                    }

                    foreach (var graphViewTool in dockArea.m_Panes.Where(p => p.GetType() == currentWindowType).Cast <GraphViewToolWindow>())
                    {
                        if (graphViewTool.m_SelectedGraphView != null)
                        {
                            usedGraphViews.Add(graphViewTool.m_SelectedGraphView);
                        }
                    }
                }
            }


            // Get all the existing GraphViewWindows we could use...
            using (var it = UIElementsUtility.GetPanelsIterator())
            {
                while (it.MoveNext())
                {
                    var dockArea = guiViews.FirstOrDefault(v => v.GetInstanceID() == it.Current.Key) as DockArea;
                    if (dockArea == null)
                    {
                        continue;
                    }

                    foreach (var graphViewWindow in dockArea.m_Panes.OfType <GraphViewEditorWindow>())
                    {
                        int idx = 0;
                        foreach (var graphView in graphViewWindow.graphViews.Where(IsGraphViewSupported))
                        {
                            m_GraphViewChoices.Add(new GraphViewChoice {
                                window = graphViewWindow, idx = idx++, graphView = graphView, canUse = !usedGraphViews.Contains(graphView)
                            });
                        }
                    }
                }
            }

            var menu           = m_SelectorMenu.menu;
            var menuItemsCount = menu.MenuItems().Count;

            // Clear previous items (but not the "none" one at the top of the list)
            for (int i = menuItemsCount - 1; i > 0; i--)
            {
                menu.RemoveItemAt(i);
            }

            foreach (var graphView in m_GraphViewChoices)
            {
                menu.AppendAction(graphView.graphView.name, OnSelectGraphView,
                                  a =>
                {
                    var gvc = (GraphViewChoice)a.userData;
                    return(gvc.graphView == m_SelectedGraphView
                            ? DropdownMenuAction.Status.Checked
                            : (gvc.canUse
                                ? DropdownMenuAction.Status.Normal
                                : DropdownMenuAction.Status.Disabled));
                },
                                  graphView);
            }
        }