public void ClearData()
 {
     if (m_HasData)
     {
         m_HasData = false;
         m_HeatMap.Dispose();
         m_Trace = default;
         m_ExportCsvButton.SetEnabled(false);
         m_ThreadSelection.SetEnabled(false);
         m_HeatMapTreeView.Reload();
     }
 }
Пример #2
0
        public void Update()
        {
            bool enabled = m_Store.GetState().CurrentGraphModel != null;

            int errorCount = 0;

            IGraphModel graphModel = m_Store.GetState().CurrentGraphModel;

            if (graphModel != null)
            {
                if (m_Store.GetState().CompilationResultModel != null)
                {
                    errorCount = (m_Store.GetState().CompilationResultModel?.GetLastResult()?.errors?.Count).GetValueOrDefault(0);
                }
            }

            enabled &= errorCount > 0;

            m_ErrorIconLabel.SetEnabled(enabled);
            m_PreviousErrorButton.SetEnabled(enabled);
            m_NextErrorButton.SetEnabled(enabled);

            m_ErrorCounterLabel.SetEnabled(enabled);
            m_ErrorCounterLabel.text = errorCount + (errorCount == 1 ? " error" : " errors");
        }
Пример #3
0
        private void InitTabVisuals(int tabIndex, GitSettingsTab tabData, VisualElement tabVisualElement, ToolbarButton toolbarButton)
        {
            tabVisualElement.style.display  = tabIndex == 0 ? DisplayStyle.Flex : DisplayStyle.None;
            tabVisualElement.style.position = Position.Absolute;
            tabVisualElement.style.top      = 0;
            tabVisualElement.style.right    = 0;
            tabVisualElement.style.left     = 0;
            tabVisualElement.style.bottom   = 0;
            settingsTabsElement.Add(tabVisualElement);

            toolbarButton.text     = tabData.Name.text;
            toolbarButton.userData = tabIndex;
            toolbarButton.SetEnabled(tabIndex != 0);

            toolbarButton.clickable.clicked += () =>
            {
                if (this.tab != tabIndex)
                {
                    lastTabIndex = this.tab;
                    toolbarButtons[this.tab].SetEnabled(true);
                    this.tab = tabIndex;
                    toolbarButtons[tabIndex].SetEnabled(false);
                    animationTween = gitAnimation.StartAnimation(AnimationDuration, this,
                                                                 GitSettingsJson.AnimationTypeEnum.Settings);
                }
            };
        }
Пример #4
0
        protected virtual void UpdateCommonMenu(VSPreferences prefs, bool enabled)
        {
            m_NewGraphButton.SetEnabled(enabled);
            m_SaveAllButton.SetEnabled(enabled);
            m_BuildAllButton.SetEnabled(enabled);

            var stencil         = m_Store.GetState()?.CurrentGraphModel?.Stencil;
            var toolbarProvider = stencil?.GetToolbarProvider();

            if (!(toolbarProvider?.ShowButton(NewGraphButton) ?? true))
            {
                m_NewGraphButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_NewGraphButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(SaveAllButton) ?? true))
            {
                m_SaveAllButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_SaveAllButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(BuildAllButton) ?? true))
            {
                m_BuildAllButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_BuildAllButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(ShowBlackboardButton) ?? true))
            {
                m_ShowBlackboardButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_ShowBlackboardButton.style.display = StyleKeyword.Null;
            }

            if (!(stencil?.GeneratesCode ?? false) || !(toolbarProvider?.ShowButton(ViewInCodeViewerButton) ?? true))
            {
                m_ViewInCodeViewerButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_ViewInCodeViewerButton.style.display = StyleKeyword.Null;
            }
        }
        public void UpdateUI()
        {
            IGraphModel graphModel = m_CommandDispatcher.State.WindowState.GraphModel;
            int         errorCount = m_CommandDispatcher.State.GraphProcessingState.RawResults?.Errors?.Count ?? 0;
            bool        enabled    = (graphModel != null) && (errorCount > 0);

            m_ErrorIconLabel.SetEnabled(enabled);
            m_PreviousErrorButton.SetEnabled(enabled);
            m_NextErrorButton.SetEnabled(enabled);

            m_ErrorCounterLabel.SetEnabled(enabled);
            m_ErrorCounterLabel.text = errorCount + (errorCount == 1 ? " error" : " errors");
        }
Пример #6
0
 private void UpdateUndoEnable()
 {
     if (undo == null || redo == null)
     {
         return;
     }
     if (treeView != null)
     {
         undo.SetEnabled(treeView.CanUndo);
         undo.tooltip = treeView.UndoName;
         redo.SetEnabled(treeView.CanRedo);
         redo.tooltip = treeView.RedoName;
     }
 }
        public ScrewItHeatMapView()
        {
            Root = new VisualElement {
                style = { flexGrow = 1 }
            };

            m_ThreadSelection      = new ToolbarMenu();
            m_ThreadSelection.text = "Select Thread";
            m_ToolbarItems.Add(m_ThreadSelection);

            m_FilterKernelCode = new ToolbarToggle
            {
                text    = "Reattribute Kernel Samples",
                tooltip = "When active, all samples that are not from unity.exe or from a managed module will be attributed to the first function up the callstack that is from unity.exe or managed."
            };
            m_FilterKernelCode.RegisterValueChangedCallback(_ => RefreshHeatMap());
            m_ToolbarItems.Add(m_FilterKernelCode);

            m_ExportCsvButton = new ToolbarButton
            {
                text  = "Export CSV",
                style = { unityTextAlign = TextAnchor.MiddleLeft },
            };
            m_ExportCsvButton.SetEnabled(false);
            m_ExportCsvButton.clicked += ExportCsvButton;
            m_ToolbarItems.Add(m_ExportCsvButton);

            m_ColumnHeader = new MultiColumnHeader(CreateHeaderState())
            {
                canSort = false
            };
            m_HeatMapTreeView = new HeatMapTreeView(new TreeViewState(), m_ColumnHeader);
            var treeContainer = new IMGUIContainer {
                style = { flexGrow = 1 }
            };

            treeContainer.onGUIHandler = () => m_HeatMapTreeView.OnGUI(treeContainer.contentRect);
            m_ColumnHeader.ResizeToFit();
            Root.Add(treeContainer);
        }
Пример #8
0
 protected virtual void UpdateCommonMenu(VSPreferences prefs, bool enabled)
 {
     m_SaveAllButton.SetEnabled(enabled);
     m_BuildAllButton.SetEnabled(enabled);
     m_ViewInCodeViewerButton.SetEnabled(enabled);
 }
Пример #9
0
        private void OnEnable()
        {
            var root = this.rootVisualElement;

            root.style.backgroundColor = EditorGUIUtility.isProSkin ? BackgroundColorInProSkin : Color.white;

            var toolbar = new Toolbar {
                style = { alignItems = Align.FlexEnd }
            };

            root.Add(toolbar);

            toolbar.Add(new ToolbarSpacer {
                flex = true
            });

            var buttonContainer = new VisualElement
            {
                tooltip = "Save current webrtc stats information to a json file",
            };

            toolbar.Add(buttonContainer);

            var dumpButton = new ToolbarButton(() =>
            {
                if (!m_peerConnenctionDataStore.Any())
                {
                    return;
                }

                var filePath = EditorUtility.SaveFilePanel("Save", "Assets", "dump", "json");

                if (string.IsNullOrEmpty(filePath))
                {
                    return;
                }

                var peerRecord = string.Join(",",
                                             m_peerConnenctionDataStore.Select(record => $"\"{record.Key}\":{{{record.Value.ToJson()}}}"));
                var json =
                    $"{{\"getUserMedia\":[], \"PeerConnections\":{{{peerRecord}}}, \"UserAgent\":\"UnityEditor\"}}";
                File.WriteAllText(filePath, json);
            })
            {
                text = "Save"
            };

            buttonContainer.Add(dumpButton);

            root.Add(CreateStatsView());

            EditorApplication.update += () =>
            {
                dumpButton.SetEnabled(m_peerConnenctionDataStore.Any());
            };

            EditorApplication.playModeStateChanged += change =>
            {
                switch (change)
                {
                case PlayModeStateChange.EnteredPlayMode:
                    m_peerConnenctionDataStore.Clear();
                    m_editorCoroutine = EditorCoroutineUtility.StartCoroutineOwnerless(GetStatsPolling());
                    break;

                case PlayModeStateChange.ExitingPlayMode:
                    EditorCoroutineUtility.StopCoroutine(m_editorCoroutine);
                    break;
                }
            };
        }
Пример #10
0
 void ModifiedHistory()
 {
     backButton?.SetEnabled(history.Count > 0);
     forwardButton?.SetEnabled(forwardHistory.Count > 0);
     homeButton?.SetEnabled(currentPageStateName != null && !currentPageStateName.Equals(pageRoot.GetType().FullName));
 }
Пример #11
0
        /// <summary>
        /// UI Element Browser Bar
        /// </summary>
        void BrowserBar(VisualElement root)
        {
            #region Browser Bar

            //Browser Bar
            Toolbar toolbar = new Toolbar();
            toolbar.style.justifyContent = Justify.SpaceBetween;
            root.Add(toolbar);
            // Back Button
            backButton         = AddToolbarButton(EditorGUIUtility.isProSkin ? GetTexture("Back") : GetTexture("Back_Alt"), Back, 5);
            backButton.tooltip = "Back";
            backButton.SetEnabled(false);
            toolbar.Add(backButton);
            // Forward Button
            forwardButton         = AddToolbarButton(EditorGUIUtility.isProSkin ? GetTexture("Forward") : GetTexture("Forward_Alt"), Forward, 0);
            forwardButton.tooltip = "Forward";
            forwardButton.SetEnabled(false);
            toolbar.Add(forwardButton);
            homeButton         = AddToolbarButton(EditorGUIUtility.isProSkin ? GetTexture("Home") : GetTexture("Home_Alt"), Home, 2);
            homeButton.tooltip = "Home";
            toolbar.Add(homeButton);

            ToolbarButton AddToolbarButton(Texture texture, Action action, float marginLeft)
            {
                ToolbarButton toolbarButton = new ToolbarButton(action)
                {
                    style =
                    {
                        marginLeft          = marginLeft,
                        width               =                      20,
                        borderLeftWidth     = marginLeft == 0 ? 0 : 1,
                        borderColor         = new Color(0.57f, 0.57f, 0.57f),
                        borderTopLeftRadius =                       2,
                        alignItems          = Align.Center,
                        paddingBottom       =                       0,
                        paddingLeft         =                       0,
                        paddingRight        =                       0,
                    }
                };

                toolbarButton.Add(new Image
                {
                    image = texture,
                    style =
                    {
                        marginTop =  4,
                        height    = 10,
                        width     = 10
                    }
                });
                return(toolbarButton);
            }

            // Search Bar
            ToolbarSearchField toolbarSearchField = new ToolbarSearchField();
            toolbarSearchField.SetValueWithoutNotify(searchString);

            //ToolbarSearchField's buttons have broken hover and action pseudo-states so we have to fix that
            StyleSheet fixSheet = LoadAssetOfType <StyleSheet>("InbuiltFixStyles", SearchFilter.Packages);
            toolbarSearchField.styleSheets.Add(fixSheet);

            toolbarSearchField.style.flexGrow = 1;
            toolbarSearchField.RegisterCallback <ChangeEvent <string> >(evt =>
            {
                searchString = evt.newValue;
                DoSearch();
            });
            TextField textField = toolbarSearchField.Q <TextField>();
            textField.RegisterCallback <FocusEvent>(evt =>
            {
                if (searchRoot.visible || string.IsNullOrEmpty(searchString))
                {
                    return;
                }
                //If there's a search string and we're in the search box we should enable the search container.
                searchRoot.visible = true;
                //If there isn't any search (ie. the previously cached search was never built, perform the search)
                if (searchStringsCache.Count == 0)
                {
                    DoSearch();
                }
            });
            //The internal text field has a fixed width so we have to remove that
            StyleLength width = textField.style.width;
            width.keyword         = StyleKeyword.Auto;
            textField.style.width = width;

            //The cancel button is improperly aligned so we have to fix that
            Button cancelButton = toolbarSearchField.Q <Button>("unity-cancel");
            cancelButton.style.width = 15;
            //The search button doesn't expand automatically, so we have to fix that
            Button searchButton = toolbarSearchField.Q <Button>("unity-search");
            searchButton.style.flexGrow = 1;
            //Set the Search Field to be 1/2 width
            toolbar.RegisterCallback <GeometryChangedEvent>(evt => toolbarSearchField.style.marginLeft = evt.newRect.width / 2f - 70);

            toolbar.Add(toolbarSearchField);

            #endregion
        }
Пример #12
0
        public BuilderStyleSheets(
            BuilderViewport viewport,
            BuilderSelection selection,
            BuilderClassDragger classDragger,
            BuilderHierarchyDragger hierarchyDragger,
            BuilderExplorerContextMenu contextMenuManipulator,
            HighlightOverlayPainter highlightOverlayPainter,
            BuilderTooltipPreview tooltipPreview)
            : base(
                viewport,
                selection,
                classDragger,
                hierarchyDragger,
                contextMenuManipulator,
                viewport.styleSelectorElementContainer,
                highlightOverlayPainter,
                kToolbarPath)
        {
            m_TooltipPreview = tooltipPreview;
            if (m_TooltipPreview != null)
            {
                var helpTooltipTemplate  = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>(kHelpTooltipPath);
                var helpTooltipContainer = helpTooltipTemplate.CloneTree();
                m_TooltipPreview.Add(helpTooltipContainer); // We are the only ones using it so just add the contents and be done.
            }

            viewDataKey = "builder-style-sheets";
            AddToClassList(BuilderConstants.ExplorerStyleSheetsPaneClassName);

            var parent = this.Q("new-selector-item");

            // Init text field.
            m_NewSelectorTextField = parent.Q <TextField>("new-selector-field");
            m_NewSelectorTextField.SetValueWithoutNotify(BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage);
            m_NewSelectorTextInputField = m_NewSelectorTextField.Q("unity-text-input");
            m_NewSelectorTextInputField.RegisterCallback <KeyDownEvent>(OnEnter, TrickleDown.TrickleDown);

            m_NewSelectorTextInputField.RegisterCallback <FocusEvent>((evt) =>
            {
                var input = evt.target as VisualElement;
                var field = input.parent as TextField;
                m_FieldFocusedFromStandby = true;
                if (field.text == BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage || m_NewSelectorJustCreated)
                {
                    m_NewSelectorJustCreated = false;
                    field.value = BuilderConstants.UssSelectorClassNameSymbol;
                }

                ShowTooltip();
            });

            m_NewSelectorTextField.RegisterCallback <ChangeEvent <string> >((evt) =>
            {
                var field = evt.target as TextField;

                if (!string.IsNullOrEmpty(evt.newValue) && evt.newValue != BuilderConstants.UssSelectorClassNameSymbol)
                {
                    m_NewSelectorAddButton.SetEnabled(true);
                    m_PseudoStatesMenu.SetEnabled(true);
                }
                else
                {
                    m_NewSelectorAddButton.SetEnabled(false);
                    m_PseudoStatesMenu.SetEnabled(false);
                }

                if (!m_FieldFocusedFromStandby)
                {
                    return;
                }

                m_FieldFocusedFromStandby = false;

                // We don't want the '.' we just inserted in the FocusEvent to be highlighted,
                // which is the default behavior.
                field.SelectRange(1, 1);
            });

            m_NewSelectorTextInputField.RegisterCallback <BlurEvent>((evt) =>
            {
                var input = evt.target as VisualElement;
                var field = input.parent as TextField;
                if (m_NewSelectorJustCreated)
                {
                    field.schedule.Execute(PostEnterRefocus);
                    evt.PreventDefault();
                    evt.StopImmediatePropagation();
                    return;
                }

                if (string.IsNullOrEmpty(field.text) || field.text == BuilderConstants.UssSelectorClassNameSymbol)
                {
                    field.SetValueWithoutNotify(BuilderConstants.ExplorerInExplorerNewClassSelectorInfoMessage);
                    m_NewSelectorAddButton.SetEnabled(false);
                    m_PseudoStatesMenu.SetEnabled(false);
                }

                HideTooltip();
            });

            // Setup new selector button.
            m_NewSelectorAddButton = parent.Q <ToolbarButton>("add-new-selector-button");
            m_NewSelectorAddButton.clickable.clicked += OnAddPress;
            m_NewSelectorAddButton.SetEnabled(false);

            // Setup pseudo states menu.
            m_PseudoStatesMenu = parent.Q <ToolbarMenu>("add-pseudo-state-menu");
            m_PseudoStatesMenu.SetEnabled(false);
            SetUpPseudoStatesMenu();
        }
Пример #13
0
        /// <summary>
        /// Updates the state of the toolbar common buttons.
        /// </summary>
        protected virtual void UpdateCommonMenu()
        {
            bool enabled = m_CommandDispatcher.State.WindowState.GraphModel != null;

            m_NewGraphButton.SetEnabled(enabled);
            m_SaveAllButton.SetEnabled(enabled);

            var stencil         = (Stencil)m_CommandDispatcher.State?.WindowState.GraphModel?.Stencil;
            var toolbarProvider = stencil?.GetToolbarProvider();

            if (!(toolbarProvider?.ShowButton(NewGraphButton) ?? true))
            {
                m_NewGraphButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_NewGraphButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(SaveAllButton) ?? true))
            {
                m_SaveAllButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_SaveAllButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(BuildAllButton) ?? false))
            {
                m_BuildAllButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_BuildAllButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(ShowMiniMapButton) ?? false))
            {
                m_ShowMiniMapButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_ShowMiniMapButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(ShowBlackboardButton) ?? false))
            {
                m_ShowBlackboardButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_ShowBlackboardButton.style.display = StyleKeyword.Null;
            }

            if (!(toolbarProvider?.ShowButton(EnableTracingButton) ?? false))
            {
                m_EnableTracingButton.style.display = DisplayStyle.None;
            }
            else
            {
                m_EnableTracingButton.style.display = StyleKeyword.Null;
            }
        }