// Manually create header for the tree view. void CreateTreeViewHeader(VisualElement root) { var systemTreeViewHeader = new Toolbar(); systemTreeViewHeader.AddToClassList(UssClasses.SystemScheduleWindow.TreeView.Header); var systemHeaderLabel = new Label("Systems"); systemHeaderLabel.AddToClassList(UssClasses.SystemScheduleWindow.TreeView.System); var entityHeaderLabel = new Label("Matches") { tooltip = "The number of entities that match the queries at the end of the frame." }; entityHeaderLabel.AddToClassList(UssClasses.SystemScheduleWindow.TreeView.Matches); var timeHeaderLabel = new Label("Time (ms)") { tooltip = "Average running time." }; timeHeaderLabel.AddToClassList(UssClasses.SystemScheduleWindow.TreeView.Time); systemTreeViewHeader.Add(systemHeaderLabel); systemTreeViewHeader.Add(entityHeaderLabel); systemTreeViewHeader.Add(timeHeaderLabel); root.Add(systemTreeViewHeader); }
private VisualElement CreateFooter() { var expressionText = new TextField { tooltip = "Type an expression to execute" }; expressionText.AddToClassList(UssExpressionClassName); void execute() { if (string.IsNullOrWhiteSpace(expressionText.text)) { var valid = ExecuteExpression(expressionText.text); if (valid) { expressionText.SetValueWithoutNotify(string.Empty); } EnableInClassList(UssExpressionInvalidClassName, !valid); } }; expressionText.RegisterCallback <KeyDownEvent>(evt => { if (evt.keyCode == KeyCode.KeypadEnter || evt.keyCode == KeyCode.Return) { execute(); } }); var executeButton = new IconButton(execute) { image = _executeIcon.Texture, tooltip = "Execute this expression" }; executeButton.AddToClassList(UssExecuteButtonClassName); var placeholder = new Placeholder("Execute Expression"); placeholder.AddToField(expressionText); var footer = new Toolbar(); footer.AddToClassList(UssFooterClassName); footer.Add(expressionText); footer.Add(executeButton); return(footer); }
void CreateToolBar(VisualElement root) { var toolbar = new Toolbar(); toolbar.AddToClassList(UssClasses.SystemScheduleWindow.ToolbarContainer); root.Add(toolbar); m_WorldSelector = CreateWorldSelector(); toolbar.Add(m_WorldSelector); m_EmptySelectorWhenShowingFullPlayerLoop = new ToolbarMenu { text = k_ShowFullPlayerLoopString }; toolbar.Add(m_EmptySelectorWhenShowingFullPlayerLoop); var rightSideContainer = new VisualElement(); rightSideContainer.AddToClassList(UssClasses.SystemScheduleWindow.ToolbarRightSideContainer); AddSearchIcon(rightSideContainer, UssClasses.DotsEditorCommon.SearchIcon); AddSearchElement(root); var dropdownSettings = CreateDropdownSettings(UssClasses.DotsEditorCommon.SettingsIcon); dropdownSettings.menu.AppendAction(k_ShowFullPlayerLoopString, a => { m_State.ShowFullPlayerLoop = !m_State.ShowFullPlayerLoop; UpdateWorldSelectorDisplay(); if (World.All.Count > 0) { RebuildTreeView(); } }, a => m_State.ShowFullPlayerLoop ? DropdownMenuAction.Status.Checked : DropdownMenuAction.Status.Normal); UpdateWorldSelectorDisplay(); rightSideContainer.Add(dropdownSettings); toolbar.Add(rightSideContainer); }
/// <summary> /// Create the toolbar at the top of the edit view /// </summary> private Toolbar CreateToolbar() { Toolbar = new Toolbar { name = "Toolbar" }; Toolbar.pickingMode = PickingMode.Position; Toolbar.AddToClassList("toolbar"); var fileMenu = new ToolbarMenu(); fileMenu.text = "File"; fileMenu.menu.AppendAction("New...", (a) => { }, (a) => DropdownMenuAction.Status.Normal); fileMenu.menu.AppendAction( "Open...", (a) => { _openFileControlId = GUIUtility.GetControlID(FocusType.Passive); EditorGUIUtility.ShowObjectPicker <PixelArt>(Workspace?.Target, false, null, _openFileControlId); }, (a) => DropdownMenuAction.Status.Normal); fileMenu.menu.AppendSeparator(); fileMenu.menu.AppendAction("Save", (a) => Workspace?.SaveFile(), (a) => Workspace != null ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); fileMenu.menu.AppendAction("Save As...", (a) => { }, (a) => Workspace != null ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); fileMenu.menu.AppendAction("Close", (a) => CloseFile(), (a) => Workspace != null ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); Toolbar.Add(fileMenu); // Select menu var selectMenu = new ToolbarMenu(); selectMenu.text = "Select"; selectMenu.menu.AppendAction("All\tCtrl+A", (a) => Workspace?.Canvas.SelectAll(), (a) => Workspace?.Canvas != null ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); selectMenu.menu.AppendAction("Deselect\tCtrl+D", (a) => Workspace?.Canvas.ClearSelection(), (a) => (Workspace?.Canvas?.HasSelection ?? false) ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); selectMenu.menu.AppendAction("Inverse\tCtrl+Shift+I", (a) => Workspace?.Canvas?.SelectInverse(), (a) => Workspace?.Canvas != null ? DropdownMenuAction.Status.Normal : DropdownMenuAction.Status.Disabled); Toolbar.Add(selectMenu); return(Toolbar); }
void CreateToolBar(VisualElement root) { var toolbar = new Toolbar(); toolbar.AddToClassList(UssClasses.SystemScheduleWindow.ToolbarContainer); root.Add(toolbar); m_WorldMenu = CreateWorldSelector(); toolbar.Add(m_WorldMenu); var rightSideContainer = new VisualElement(); rightSideContainer.AddToClassList(UssClasses.SystemScheduleWindow.ToolbarRightSideContainer); AddSearchIcon(rightSideContainer, UssClasses.DotsEditorCommon.SearchIcon); AddSearchFieldContainer(root, UssClasses.DotsEditorCommon.SearchFieldContainer); var dropDownSettings = CreateDropDownSettings(UssClasses.DotsEditorCommon.SettingsIcon); UpdateDropDownSettings(dropDownSettings); rightSideContainer.Add(dropDownSettings); toolbar.Add(rightSideContainer); }
private VisualElement CreateToolbar() { var watchField = new TextField { tooltip = "Type a VariableReference to watch" }; watchField.AddToClassList(UssWatchClassName); void watch() { if (string.IsNullOrWhiteSpace(watchField.text)) { var valid = AddWatch(watchField.text); if (valid) { watchField.SetValueWithoutNotify(string.Empty); } EnableInClassList(UssWatchInvalidClassName, !valid); } }; watchField.RegisterCallback <KeyDownEvent>(evt => { if (evt.keyCode == KeyCode.KeypadEnter || evt.keyCode == KeyCode.Return) { watch(); } }); var placeholder = new Placeholder("Add watch"); placeholder.AddToField(watchField); var watchButton = new IconButton(watch) { image = Icon.View.Texture, tooltip = "Watch this variable" }; watchButton.AddToClassList(UssWatchButtonClassName); var loggingButton = new Image { image = _logIcon.Texture, tooltip = "Enable/Disable logging of graph statistics" }; loggingButton.AddToClassList(UssLoggingClassName); loggingButton.AddManipulator(new Clickable(() => { CompositionManager.LogTracking = !CompositionManager.LogTracking; _logGraphEnabled.Value = CompositionManager.LogTracking; EnableInClassList(UssLoggingActiveClassName, CompositionManager.LogTracking); })); var toolbar = new Toolbar(); toolbar.AddToClassList(UssToolbarClassName); toolbar.Add(watchField); toolbar.Add(watchButton); toolbar.Add(loggingButton); return(toolbar); }
private void CreateToolbar() { _graphButton = new TextElement { tooltip = "Select a graph to edit" }; _graphButton.AddToClassList(ToolbarButtonUssClassName); _graphButton.AddToClassList(ToolbarButtonLargeUssClassName); _graphButton.AddToClassList(ToolbarButtonFirstUssClassName); _graphButton.AddToClassList(ToolbarButtonGraphUssClassName); _graphButton.AddManipulator(new Clickable(() => ShowGraphPicker(GUIUtility.GUIToScreenPoint(_graphButton.worldBound.position)))); _editButton = CreateEditMenu(); _editButton.AddToClassList(ToolbarMenuUssClassName); _viewButton = CreateViewMenu(); _viewButton.AddToClassList(ToolbarMenuUssClassName); _playButton = new Image { image = _playIcon.Texture, tooltip = "Resume execution of the graph" }; _playButton.AddToClassList(ToolbarButtonUssClassName); _playButton.AddToClassList(ToolbarButtonSmallUssClassName); _playButton.AddManipulator(new Clickable(() => CurrentGraph.DebugPlay())); _pauseButton = new Image { image = _pauseIcon.Texture, tooltip = "Pause the execution of the graph" }; _pauseButton.AddToClassList(ToolbarButtonUssClassName); _pauseButton.AddToClassList(ToolbarButtonSmallUssClassName); _pauseButton.AddManipulator(new Clickable(() => CurrentGraph.DebugPause())); _stepButton = new Image { image = _stepIcon.Texture, tooltip = "Step forward one node in the graph" }; _stepButton.AddToClassList(ToolbarButtonUssClassName); _stepButton.AddToClassList(ToolbarButtonSmallUssClassName); _stepButton.AddManipulator(new Clickable(() => CurrentGraph.DebugStep())); _stopButton = new Image { image = _stopIcon.Texture, tooltip = "Stop executing the graph", tintColor = Color.gray }; _stopButton.AddToClassList(ToolbarButtonUssClassName); _stopButton.AddToClassList(ToolbarButtonSmallUssClassName); _stopButton.AddManipulator(new Clickable(() => CurrentGraph.DebugStop())); _breakButton = new VisualElement { tooltip = "Enable/Disable node breakpoints for all graphs" }; _breakButton.AddToClassList(ToolbarButtonUssClassName); _breakButton.AddToClassList(ToolbarButtonSmallUssClassName); _breakButton.AddToClassList(ToolbarButtonFirstUssClassName); _breakButton.AddManipulator(new Clickable(ToggleBreakpointsEnabled)); var breakButton = new VisualElement(); breakButton.AddToClassList(ToolbarButtonBreakpointUssClassName); _breakButton.Add(breakButton); _loggingButton = new Image { image = _logIcon.Texture, tooltip = "Enable/Disable logging of graph execution for all graphs" }; _loggingButton.AddToClassList(ToolbarButtonUssClassName); _loggingButton.AddToClassList(ToolbarButtonSmallUssClassName); _loggingButton.AddManipulator(new Clickable(ToggleLoggingEnabled)); _lockButton = new Image { tintColor = Color.black, tooltip = "Lock/Unlock this window so it won't be used when other graphs are opened" }; _lockButton.AddToClassList(ToolbarButtonUssClassName); _lockButton.AddToClassList(ToolbarButtonSmallUssClassName); _lockButton.AddToClassList(ToolbarButtonLockUssClassName); _lockButton.AddManipulator(new Clickable(ToggleLockingEnabled)); var watchButton = new Image { image = Icon.View.Texture, tooltip = "Open the Watch Window" }; watchButton.AddToClassList(ToolbarButtonUssClassName); watchButton.AddToClassList(ToolbarButtonSmallUssClassName); watchButton.AddManipulator(new Clickable(WatchWindow.ShowWindow)); RefreshToolbar(); var toolbar = new Toolbar(); toolbar.AddToClassList(ToolbarUssClassName); toolbar.Add(_graphButton); toolbar.Add(_editButton); toolbar.Add(_viewButton); toolbar.Add(_playButton); toolbar.Add(_pauseButton); toolbar.Add(_stepButton); toolbar.Add(_stopButton); toolbar.Add(new ToolbarSpacer { flex = true }); toolbar.Add(_breakButton); toolbar.Add(_loggingButton); toolbar.Add(watchButton); toolbar.Add(_lockButton); Add(toolbar); }