public DebuggerSearchBar(DebuggerTreeView parent) { m_ParentTreeView = parent; m_FoundItems = new List <SearchResultItem>(); this.AddToClassList("unity-treeview-searchbar"); m_FieldHelpLabel = new Label("Search by type, name, or class"); m_FieldHelpLabel.pickingMode = PickingMode.Ignore; m_FieldHelpLabel.AddToClassList("unity-treeview-searchbar-label"); m_FieldHelpLabel.AddToClassList("unity-treeview-searchbar-label-help"); Add(m_FieldHelpLabel); var field = new TextField(); field.AddToClassList("unity-treeview-searchbar-field"); field.RegisterValueChangedCallback(PerformSearch); field.RegisterCallback <KeyDownEvent>((e) => { var targetField = field; if (e.keyCode == KeyCode.F3 || e.keyCode == KeyCode.Return || e.keyCode == KeyCode.KeypadEnter) { if (e.modifiers == EventModifiers.Shift) { SelectPrev(); } else { SelectNext(); } } else if (e.keyCode == KeyCode.Escape) { targetField.value = string.Empty; targetField.visualInput.Blur(); m_ParentTreeView.ClearSearchResults(); m_ParentTreeView.Focus(); } }, TrickleDown.TrickleDown); Add(field); m_CountLabel = new Label(); m_CountLabel.AddToClassList("unity-treeview-searchbar-label"); m_CountLabel.AddToClassList("unity-treeview-searchbar-hidden"); Add(m_CountLabel); var prevButton = new Button(SelectPrev) { text = "<" }; prevButton.AddToClassList("unity-treeview-searchbar-button"); prevButton.AddToClassList("unity-treeview-searchbar-button-prev"); Add(prevButton); var nextButton = new Button(SelectNext) { text = ">" }; nextButton.AddToClassList("unity-treeview-searchbar-button"); nextButton.AddToClassList("unity-treeview-searchbar-button-next"); Add(nextButton); }
public new void OnEnable() { base.OnEnable(); DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this; m_DebuggerSelection = new DebuggerSelection(); m_RepaintOverlay = new RepaintOverlayPainter(); m_PickOverlay = new HighlightOverlayPainter(); m_LayoutOverlay = new LayoutOverlayPainter(); var root = this.rootVisualElement; var sheet = EditorGUIUtility.Load(k_DefaultStyleSheetPath) as StyleSheet; root.styleSheets.Add(sheet); StyleSheet colorSheet; if (EditorGUIUtility.isProSkin) { colorSheet = EditorGUIUtility.Load(k_DefaultDarkStyleSheetPath) as StyleSheet; } else { colorSheet = EditorGUIUtility.Load(k_DefaultLightStyleSheetPath) as StyleSheet; } root.styleSheets.Add(colorSheet); root.Add(m_Toolbar); m_PickToggle = new ToolbarToggle() { name = "pickToggle" }; m_PickToggle.text = "Pick Element"; m_PickToggle.RegisterValueChangedCallback((e) => { m_PickElement = e.newValue; // On OSX, as focus-follow-mouse is not supported, // we explicitly focus the EditorWindow when enabling picking if (Application.platform == RuntimePlatform.OSXEditor) { Panel p = m_DebuggerSelection.panel as Panel; if (p != null) { TryFocusCorrespondingWindow(p); } } }); m_Toolbar.Add(m_PickToggle); m_ShowLayoutToggle = new ToolbarToggle() { name = "layoutToggle" }; m_ShowLayoutToggle.SetValueWithoutNotify(m_ShowLayoutBound); m_ShowLayoutToggle.text = "Show Layout"; m_ShowLayoutToggle.RegisterValueChangedCallback((e) => { m_ShowLayoutBound = e.newValue; panelDebug?.MarkDirtyRepaint(); panelDebug?.MarkDebugContainerDirtyRepaint(); }); m_Toolbar.Add(m_ShowLayoutToggle); if (Unsupported.IsDeveloperBuild()) { m_RepaintOverlayToggle = new ToolbarToggle() { name = "repaintOverlayToggle" }; m_RepaintOverlayToggle.text = "Repaint Overlay"; m_RepaintOverlayToggle.RegisterValueChangedCallback((e) => m_ShowRepaintOverlay = e.newValue); m_Toolbar.Add(m_RepaintOverlayToggle); m_UXMLLiveReloadToggle = new ToolbarToggle() { name = "UXMLReloadToggle" }; m_UXMLLiveReloadToggle.SetValueWithoutNotify(RetainedMode.UxmlLiveReloadIsEnabled); m_UXMLLiveReloadToggle.text = "UXML Live Reload"; m_UXMLLiveReloadToggle.RegisterValueChangedCallback((e) => RetainedMode.UxmlLiveReloadIsEnabled = e.newValue); m_Toolbar.Add(m_UXMLLiveReloadToggle); m_ShowDrawStatsToggle = new ToolbarToggle() { name = "drawStatsToggle" }; m_ShowDrawStatsToggle.text = "Draw Stats"; m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) => { var updater = (panel as BaseVisualElementPanel)?.GetUpdater(VisualTreeUpdatePhase.Repaint) as UIRRepaintUpdater; if (updater != null) { updater.DebugGetRenderChain().drawStats = e.newValue; } panelDebug?.MarkDirtyRepaint(); }); m_Toolbar.Add(m_ShowDrawStatsToggle); } var splitter = new DebuggerSplitter(); root.Add(splitter); m_TreeViewContainer = new DebuggerTreeView(m_DebuggerSelection, SelectElement); m_TreeViewContainer.style.flexGrow = 1f; splitter.leftPane.Add(m_TreeViewContainer); m_StylesDebuggerContainer = new StylesDebugger(m_DebuggerSelection); splitter.rightPane.Add(m_StylesDebuggerContainer); }
public void Initialize(EditorWindow debuggerWindow, VisualElement root, DebuggerContext context) { base.Initialize(debuggerWindow); m_Root = root; m_Context = context; m_Context.onStateChange += OnContextChange; var sheet = EditorGUIUtility.Load(k_DefaultStyleSheetPath) as StyleSheet; m_Root.styleSheets.Add(sheet); StyleSheet colorSheet; if (EditorGUIUtility.isProSkin) { colorSheet = EditorGUIUtility.Load(k_DefaultDarkStyleSheetPath) as StyleSheet; } else { colorSheet = EditorGUIUtility.Load(k_DefaultLightStyleSheetPath) as StyleSheet; } m_Root.styleSheets.Add(colorSheet); m_Root.Add(m_Toolbar); m_PickToggle = new ToolbarToggle() { name = "pickToggle" }; m_PickToggle.text = "Pick Element"; m_PickToggle.RegisterValueChangedCallback((e) => { m_Context.pickElement = e.newValue; // On OSX, as focus-follow-mouse is not supported, // we explicitly focus the EditorWindow when enabling picking if (Application.platform == RuntimePlatform.OSXEditor) { Panel p = m_Context.selection.panel as Panel; if (p != null) { TryFocusCorrespondingWindow(p.ownerObject); } } }); m_Toolbar.Add(m_PickToggle); m_ShowLayoutToggle = new ToolbarToggle() { name = "layoutToggle" }; m_ShowLayoutToggle.text = "Show Layout"; m_ShowLayoutToggle.RegisterValueChangedCallback((e) => { m_Context.showLayoutBound = e.newValue; }); m_Toolbar.Add(m_ShowLayoutToggle); if (Unsupported.IsDeveloperBuild()) { m_RepaintOverlayToggle = new ToolbarToggle() { name = "repaintOverlayToggle" }; m_RepaintOverlayToggle.text = "Repaint Overlay"; m_RepaintOverlayToggle.RegisterValueChangedCallback((e) => m_Context.showRepaintOverlay = e.newValue); m_Toolbar.Add(m_RepaintOverlayToggle); m_ShowDrawStatsToggle = new ToolbarToggle() { name = "drawStatsToggle" }; m_ShowDrawStatsToggle.text = "Draw Stats"; m_ShowDrawStatsToggle.RegisterValueChangedCallback((e) => { m_Context.showDrawStats = e.newValue; }); m_Toolbar.Add(m_ShowDrawStatsToggle); } var splitter = new DebuggerSplitter(); m_Root.Add(splitter); m_TreeViewContainer = new DebuggerTreeView(m_Context.selection, SelectElement); m_TreeViewContainer.style.flexGrow = 1f; splitter.leftPane.Add(m_TreeViewContainer); m_StylesDebuggerContainer = new StylesDebugger(m_Context.selection); splitter.rightPane.Add(m_StylesDebuggerContainer); DebuggerEventDispatchingStrategy.s_GlobalPanelDebug = this; m_RepaintOverlay = new RepaintOverlayPainter(); m_PickOverlay = new HighlightOverlayPainter(); m_LayoutOverlay = new LayoutOverlayPainter(); OnContextChange(); }