public void QueryToolbarCommands(ToolbarUI ui) { if (CurrentBreakpoint != null) { ui.AddCommand(new ToolbarItem() { Command = new ContinueCommand(), Title = "Continue" }); ui.AddCommand(new ToolbarItem() { Command = new StepCommand(), Title = "Step" }); } ui.AddCommand(new ToolbarItem() { Title = "Debug Mode", Checked = IsDebugMode, Description = "Enabling debug mode will turn on breakpoints, which you can setup on Action nodes and other Sequence nodes.", Command = new LambdaCommand("Debug Mode", () => { IsDebugMode = !IsDebugMode; InvertApplication.Execute(new SaveAndCompileCommand() { ForceCompileAll = true }); }), Position = ToolbarPosition.Right }); }
public void Execute(CreateNodeCommand command) { var node = Activator.CreateInstance(command.NodeType) as IDiagramNode; var repository = Container.Resolve <IRepository>(); node.GraphId = command.GraphData.Identifier; repository.Add(node); if (string.IsNullOrEmpty(node.Name)) { node.Name = repository.GetUniqueName("New" + node.GetType().Name.Replace("Data", "")); } var filterItem = node as IFilterItem; if (filterItem != null) { filterItem.FilterId = command.GraphData.CurrentFilter.Identifier; filterItem.Position = command.Position; } else { command.GraphData.CurrentFilter.ShowInFilter(node, command.Position); } // Start name editing DiagramNodeViewModel diagramNodeViewModel = InvertGraphEditor.CurrentDiagramViewModel.GraphItems .OfType <DiagramNodeViewModel>() .First(nodeViewModel => nodeViewModel.DataObject == node); InvertApplication.Execute(new RenameCommand { ViewModel = diagramNodeViewModel }); }
public void DoCommand(ToolbarItem command) { var style = EditorStyles.toolbarButton; if (command.IsDropdown) { style = EditorStyles.toolbarDropDown; } if (command.Checked) { style = new GUIStyle(EditorStyles.toolbarButton); style.normal.background = style.active.background; } var guiContent = new GUIContent(command.Title); if (GUILayout.Button(guiContent, style)) { if (command.IsDelayCall) // Fix the invalide status, stack error { EditorApplication.delayCall += () => { InvertApplication.Execute(command.Command); }; } else { InvertApplication.Execute(command.Command); } } InvertGraphEditor.PlatformDrawer.SetTooltipForRect(GUILayoutUtility.GetLastRect(), command.Description); GUI.enabled = true; }
private void CreateNewSectionItem(NodeConfigSectionBase section1, DiagramNodeViewModel vm) { var item = Activator.CreateInstance(section1.SourceType) as GenericNodeChildItem; item.Node = vm.GraphItemObject as GraphNode; DiagramViewModel.CurrentRepository.Add(item); item.Name = item.Repository.GetUniqueName(section1.Name); OnAdd(section1, item); if (typeof(ITypedItem).IsAssignableFrom(section1.SourceType)) { InvertApplication.Execute(new SelectTypeCommand() { PrimitiveOnly = false, AllowNone = false, IncludePrimitives = true, Item = item as ITypedItem, OnSelectionFinished = () => { item.IsSelected = true; item.IsEditing = true; } }); } else { item.IsEditing = true; } }
public void Navigate() { InvertApplication.Execute(new FilterBySelectionCommand()); // // if (SelectedNode == null) return; // if (SelectedNode.IsFilter) // { // // if (SelectedNode.GraphItemObject == GraphData.CurrentFilter) // { // GraphData.PopFilter(); // GraphData.UpdateLinks(); // // } // else // { // var graphFilter = SelectedNode.GraphItemObject as IGraphFilter; // GraphData.PushFilter(graphFilter); // GraphData.UpdateLinks(); // } // // if (command.SaveInHistory) SaveNewStep(null); // // } // InvertApplication.Execute(new FilterBySelectionCommand() // { // // }); }
public void NavigateTo(string identifier) { InvertApplication.Execute(new NavigateByIdCommand() { Identifier = identifier }); }
public void NavigateByName(string name) { InvertApplication.Execute(new NavigateByNameCommand() { ItemName = name }); }
public void Execute() { InvertApplication.Execute(new LambdaCommand("Select Item", () => { QuickLaunchItems[SelectedIndex].Action(QuickLaunchItems[SelectedIndex].Item); })); InvertApplication.SignalEvent <IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this)); }
public void Refresh() { Tabs.Clear(); foreach (var tab in DesignerWindow.Designer.Tabs) { var tab1 = tab; var navigationItem = new NavigationItem() { Icon = "CommandIcon", SpecializedIcon = null, //State = DesignerWindow.Designer.CurrentTab.Graph == tab ? NavigationItemState.Current : NavigationItemState.Regular, Title = tab.Title + (tab.IsDirty ? "*" : string.Empty), NavigationAction = x => { InvertApplication.Execute(new LambdaCommand("Change Current Graph", () => { WorkspaceService.CurrentWorkspace.CurrentGraphId = tab1.Identifier; //DesignerWindow.SwitchDiagram(WorkspaceService.CurrentWorkspace.Graphs.FirstOrDefault(p => p.Identifier == tab.Identifier)); })); }, CloseAction = x => { InvertApplication.Execute(new LambdaCommand("Close Graph", () => { this.DiagramViewModel.CurrentRepository.RemoveAll <WorkspaceGraph>(p => p.GraphId == tab1.Identifier); })); } }; if (DesignerWindow.Workspace != null && DesignerWindow.Workspace.CurrentGraph != null && tab.Identifier == DesignerWindow.Workspace.CurrentGraph.Identifier) { navigationItem.State = NavigationItemState.Current; } else { navigationItem.State = NavigationItemState.Regular; } Tabs.Add(navigationItem); } Breadcrubs.Clear(); foreach (var filter in new[] { DiagramViewModel.GraphData.RootFilter }.Concat(this.DiagramViewModel.GraphData.GetFilterPath())) { var navigationItem = CreateNavigationItem(filter); if (filter == DiagramViewModel.GraphData.RootFilter) { navigationItem.SpecializedIcon = "RootFilterIcon"; } Breadcrubs.Add(navigationItem); } }
public void InitTypeListWindow(GraphTypeInfo[] typesInfoList, Action <GraphTypeInfo> action) { ElementItemTypesWindow.InitTypeListWindow("Choose Type", typesInfoList, (selected) => { EditorWindow.GetWindow <ElementItemTypesWindow>().Close(); InvertApplication.Execute(() => { action(selected); }); }); }
public void InitItemWindow <TItem>(IEnumerable <TItem> items, Action <TItem> action, bool allowNone = false) where TItem : IItem { ItemSelectionWindow.Init("Select Item", items.Cast <IItem>(), (item) => { InvertApplication.Execute(() => { action((TItem)item); }); }, allowNone); }
public void DrawActionDialog(IPlatformDrawer platform, Rect bounds, ActionItem item, System.Action cancel = null) { if (item == null) { return; } platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13); bounds = bounds.PadSides(15); var descriptionHeight = string.IsNullOrEmpty(item.Description) ? 50 : platform.CalculateTextHeight(item.Description, CachedStyles.BreadcrumbTitleStyle, bounds.width) + 60; var headerRect = bounds.WithHeight(40); var iconRect = bounds.WithSize(41, 41); var descriptionRect = headerRect.Below(headerRect).Translate(0, -22).WithHeight(descriptionHeight); var inspectorRect = bounds.Below(descriptionRect).Clip(bounds); var executeButtonRect = new Rect() .WithSize(100, 30) .InnerAlignWithBottomRight(bounds); if (!_inspectors.ContainsKey(item)) { var uFrameMiniInspector = new uFrameMiniInspector(item.Command); _inspectors.Add(item, uFrameMiniInspector); } var inspector = _inspectors[item]; var inspectorHeight = inspector.Height; _scrollPosition = GUI.BeginScrollView(bounds.AddHeight(-30).AddWidth(15), _scrollPosition, bounds.WithHeight(headerRect.height + iconRect.height + descriptionRect.height + inspectorHeight)); platform.DrawLabel(headerRect, item.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter); platform.DrawImage(iconRect, string.IsNullOrEmpty(item.Icon) ? "CreateEmptyDatabaseIcon" : item.Icon, true); platform.DrawLabel(descriptionRect, item.Description, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleLeft); inspector.Draw(descriptionRect.WithHeight(inspectorHeight).Pad(0, 0, 10, 0).Below(descriptionRect)); //Draw generic inspector GUI.EndScrollView(); if (cancel != null) { platform.DoButton(executeButtonRect.InnerAlignWithBottomLeft(bounds), "Cancel", ElementDesignerStyles.DarkButtonStyle, cancel); } platform.DoButton(executeButtonRect, string.IsNullOrEmpty(item.Verb) ? "Create" : item.Verb, ElementDesignerStyles.DarkButtonStyle, () => { InvertApplication.Execute(item.Command); }); }
public void Execute(QuickAccessItem item) { var x = item.Item; var z = item; InvertApplication.Execute(new LambdaCommand("Select Item", () => { z.Action(x); })); InvertApplication.SignalEvent <IWindowsEvents>(i => i.WindowRequestCloseWithViewModel(this)); }
public bool KeyEvent(KeyCode keyCode, ModifierKeyState state) { if (state.Ctrl && keyCode == KeyCode.Z) { InvertApplication.Execute(new UndoCommand()); return(true); } if (state.Ctrl && keyCode == KeyCode.Y) { InvertApplication.Execute(new RedoCommand()); return(true); } return(false); }
public void Execute(AddGraphToWorkspace command) { var workspaceService = Container.Resolve <WorkspaceService>(); var repo = Container.Resolve <IRepository>(); var workspaceGraphs = workspaceService.CurrentWorkspace.Graphs.Select(p => p.Identifier).ToArray(); var importableGraphs = repo.AllOf <IGraphData>().Where(p => !workspaceGraphs.Contains(p.Identifier)); InvertGraphEditor.WindowManager.InitItemWindow(importableGraphs, _ => { InvertApplication.Execute(new LambdaCommand("Add Graph", () => { workspaceService.CurrentWorkspace.AddGraph(_); })); }); }
public NavigationItem CreateNavigationItem(IGraphFilter filter) { var navigationItem = new NavigationItem() { Icon = "CommandIcon", Title = filter.Name, State = DiagramViewModel.GraphData != null && DiagramViewModel.GraphData.CurrentFilter == filter ? NavigationItemState.Current : NavigationItemState.Regular, NavigationAction = x => { InvertApplication.Execute(new LambdaCommand("Back", () => { DiagramViewModel.GraphData.PopToFilter(filter); })); } }; return(navigationItem); }
private void ShowAddPointerMenu <TItem>(string name, Action addItem, Action <TItem> addPointer) where TItem : IDiagramNodeItem { var ctxMenu = new UnityEditor.GenericMenu(); ctxMenu.AddItem(new GUIContent("New " + name), false, () => { InvertApplication.Execute(() => { addItem(); }); }); ctxMenu.AddSeparator(""); var nodeConfigSection = NodeViewModel.DiagramViewModel.CurrentRepository.AllOf <TItem>(); foreach (var item in nodeConfigSection) { var item1 = item; ctxMenu.AddItem(new GUIContent(item.Name), false, () => { InvertApplication.Execute(() => { addPointer(item1); }); }); } ctxMenu.ShowAsContext(); }
private void TryNavigateToItem(IItem item) { if (InvertGraphEditor.CurrentDiagramViewModel != null) { InvertGraphEditor.CurrentDiagramViewModel.NothingSelected(); } var itemAsNode = item as IDiagramNodeItem; if (itemAsNode != null) { InvertApplication.Execute(new NavigateToNodeCommand() { Node = itemAsNode.Node }); return; } }
//public void UpgradeProject() //{ // uFrameEditor.ExecuteCommand(new ConvertToJSON()); //} public void NothingSelected() { var items = SelectedNodeItems.OfType <ItemViewModel>().Where(p => p.IsEditing).ToArray(); if (items.Length > 0) { InvertApplication.Execute(() => { foreach (var item in items) { item.EndEditing(); } }); } DeselectAll(); //InvertGraphEditor.ExecuteCommand(_ => { }); }
protected override void ApplyConnection(IGraphData graph, IContextVariable output, IActionIn input) { base.ApplyConnection(graph, output, input); var converter = uFrameECS.Converters.FirstOrDefault(p => output.VariableType.IsAssignableTo(p.ConvertFrom.MemberType) && p.ConvertTo.MemberType.FullName == input.VariableType.FullName ); if (converter != null) { InvertApplication.Execute(new CreateConverterConnectionCommand() { ConverterAction = converter, Input = input, Output = output }); } }
public void ShowSelectionListWindow() { EndEditing(); InvertApplication.Execute(new SelectTypeCommand() { PrimitiveOnly = false, AllowNone = false, IncludePrimitives = true, Item = this.DataObject as ITypedItem, }); // TODO 2.0 Typed Item Selection Window // This was in the drawer re-implement //if (!this.ItemViewModel.Enabled) return; //if (TypedItemViewModel.Data.Precompiled) return; //var commandName = ViewModelObject.DataObject.GetType().Name.Replace("Data", "") + "TypeSelection"; //var command = InvertGraphEditor.Container.Resolve<IEditorCommand>(commandName); }
private void CreateNewSectionItem(NodeConfigSectionBase section, DiagramNodeViewModel vm) { var item = Activator.CreateInstance(section.SourceType) as GenericNodeChildItem; item.Node = vm.GraphItemObject as GraphNode; DiagramViewModel.CurrentRepository.Add(item); item.Name = item.Repository.GetUniqueName(section.Name); OnAdd(section, item); if (typeof(ITypedItem).IsAssignableFrom(section.SourceType)) { InvertApplication.Execute(new SelectTypeCommand() { PrimitiveOnly = false, AllowNoneType = section.AllowNoneType, IncludePrimitives = true, Item = item as ITypedItem, OnSelectionFinished = () => { // Set the initial item name to the name o the type GenericTypedChildItem typedChildItem = item as GenericTypedChildItem; if (typedChildItem != null) { typedChildItem.Name = typedChildItem.RelatedTypeNode != null ? typedChildItem.RelatedTypeNode.Name : typedChildItem.RelatedTypeName; InvertGraphEditor.DesignerWindow.RefreshContent(); //InvertGraphEditor.DesignerWindow.DiagramDrawer.CachedChildren.First(drawer => drawer.ViewModelObject.DataObject == item).Refresh(InvertApplication.Container.Resolve<IPlatformDrawer>()); } item.IsSelected = true; item.IsEditing = true; } }); } else { item.IsEditing = true; } }
public bool KeyDown(bool control, bool alt, bool shift, KeyCode character) { if (character == KeyCode.F2) { GraphItemViewModel selectNodeItem = InvertGraphEditor.CurrentDiagramViewModel.SelectedNodeItem; if (selectNodeItem != null) { DiagramNodeItem nodeItem = selectNodeItem.DataObject as DiagramNodeItem; if (nodeItem != null) { nodeItem.IsEditing = true; return(false); } } DiagramNodeViewModel selectedNode = InvertGraphEditor.CurrentDiagramViewModel.SelectedNode; if (selectedNode != null) { InvertApplication.Execute(new RenameCommand() { ViewModel = selectedNode }); return(false); } } if (character == KeyCode.Delete) { DiagramNodeViewModel selectedNode = InvertGraphEditor.CurrentDiagramViewModel.SelectedNode; if (selectedNode != null) { InvertApplication.Execute(new DeleteCommand() { Item = new[] { selectedNode.DataObject as IDataRecord } }); return(false); } } return(false); }
public void CreateMenuItems(GenericMenu genericMenu) { var groups = Commands.GroupBy(p => p == null? "" : p.Group).OrderBy(p => p.Key).ToArray(); foreach (var group in groups) { //genericMenu.AddDisabledItem(new GUIContent(group.Key)); var groupCount = 0; foreach (var editorCommand in group.OrderBy(p => p.Order)) { ICommand command = editorCommand.Command; genericMenu.AddItem(new GUIContent(editorCommand.Title), editorCommand.Checked, () => { InvertApplication.Execute(command); }); groupCount++; } if (group != groups.Last() && groupCount > 0) { genericMenu.AddSeparator(null); } } }
public override void OnMouseUp(MouseEvent e) { base.OnMouseUp(e); if (CurrentConnection != null) { InvertApplication.Execute(new LambdaCommand("Create Connection", () => { CurrentConnection.Apply(CurrentConnection); })); } else { var mouseData = e; InvertApplication.SignalEvent <IShowConnectionMenu>(_ => _.Show(DiagramViewModel, StartConnector, mouseData.MouseUpPosition)); //var allowedFilterNodes = FilterExtensions.AllowedFilterNodes[this.DiagramViewModel.CurrentRepository.CurrentFilter.GetType()]; //var menu = InvertGraphEditor.CreateCommandUI<ContextMenuUI>(); //foreach (var item in allowedFilterNodes) //{ // if (item.IsInterface) continue; // if (item.IsAbstract) continue; // var node = Activator.CreateInstance(item) as IDiagramNode; // node.Graph = this.DiagramViewModel.GraphData; // var vm = InvertGraphEditor.Container.GetNodeViewModel(node, this.DiagramViewModel) as DiagramNodeViewModel; // if (vm == null) continue; // vm.IsCollapsed = false; // var connectors = new List<ConnectorViewModel>(); // vm.GetConnectors(connectors); // var config = InvertGraphEditor.Container.Resolve<NodeConfigBase>(item.Name); // var name = config == null ? item.Name : config.Name; // foreach (var connector in connectors) // { // foreach (var strategy in InvertGraphEditor.ConnectionStrategies) // { // var connection = strategy.Connect(this.DiagramViewModel, StartConnector, connector); // if (connection == null) continue; // var node1 = node; // var message = string.Format("Create {0}", name); // if (!string.IsNullOrEmpty(connector.Name)) // { // message += string.Format(" and connect to {0}", connector.Name); // } // var value = new KeyValuePair<IDiagramNode, ConnectionViewModel>(node1, connection); // menu.AddCommand( // new SimpleEditorCommand<DiagramViewModel>(delegate(DiagramViewModel n) // { // //UnityEditor.EditorWindow.FocusWindowIfItsOpen(typeof (ElementsDesigner)); // InvertGraphEditor.ExecuteCommand(_ => // { // this.DiagramViewModel.AddNode(value.Key,e.MouseUpPosition); // connection.Apply(value.Value as ConnectionViewModel); // value.Key.IsSelected = true; // value.Key.IsEditing = true; // value.Key.Name = ""; // }); // },message)); // } // } //} //menu.Go(); } foreach (var a in PossibleConnections) { a.IsMouseOver = false; a.IsSelected = false; } e.Cancel(); }
public void Add() { InvertApplication.Execute(AddCommand); }
public virtual void DrawInspector(Rect rect, PropertyFieldViewModel d, GUIStyle labelStyle) { var colorCache = GUI.color; GUI.color = Color.white; var labelArea = rect.LeftHalf(); var fieldArea = rect.RightHalf(); var labelWidtho = GUILayout.Width(140); if (d.InspectorType == InspectorType.GraphItems) { var item = d.CachedValue as IGraphItem; var text = "--Select--"; if (item != null) { text = item.Label; } if (GUI.Button(rect, d.Label + ": " + text, ElementDesignerStyles.ButtonStyle)) { var type = d.Type; var items = InvertGraphEditor.CurrentDiagramViewModel.CurrentRepository.AllOf <IGraphItem>().Where(p => type.IsAssignableFrom(p.GetType())); var menu = new SelectionMenu(); menu.AddItem(new SelectionMenuItem(string.Empty, "[None]", () => { InvertApplication.Execute(() => { d.Setter(d.DataObject, null); }); })); foreach (var graphItem in items) { var graphItem1 = graphItem; menu.AddItem(new SelectionMenuItem(graphItem1, () => { InvertApplication.Execute(() => { d.Setter(d.DataObject, graphItem1); }); })); } InvertApplication.SignalEvent <IShowSelectionMenu>(_ => _.ShowSelectionMenu(menu)); } SetTooltipForRect(rect, d.InspectorTip); GUI.color = colorCache; return; } if (d.Type == typeof(string)) { if (d.InspectorType == InspectorType.TextArea) { labelArea = rect.WithHeight(17).InnerAlignWithUpperRight(rect); fieldArea = rect.Below(labelArea).Clip(rect).PadSides(2); EditorGUI.LabelField(labelArea, d.Name, labelStyle); SetTooltipForRect(rect, d.InspectorTip); EditorGUI.BeginChangeCheck(); d.CachedValue = EditorGUI.TextArea(fieldArea, (string)d.CachedValue, TextWrappingTextArea); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { InvertApplication.Execute(() => { }); } } else if (d.InspectorType == InspectorType.TypeSelection) { if (GUI.Button(rect, (string)d.CachedValue)) { d.NodeViewModel.Select(); // TODO 2.0 Open Selection? } SetTooltipForRect(rect, d.InspectorTip); } else { EditorGUI.BeginChangeCheck(); EditorGUI.LabelField(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.TextField(fieldArea, (string)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } } else { if (d.Type == typeof(int)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.IntField(fieldArea, (int)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(float)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.FloatField(fieldArea, (float)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Vector2)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.Vector2Field(fieldArea, string.Empty, (Vector2)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Vector3)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.Vector3Field(fieldArea, string.Empty, (Vector3)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Color)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.ColorField(fieldArea, (Color)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Vector4)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.Vector4Field(fieldArea, string.Empty, (Vector4)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(bool)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.Toggle(fieldArea, (bool)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (typeof(Enum).IsAssignableFrom(d.Type)) { EditorGUI.BeginChangeCheck(); GUI.Label(labelArea, d.Name, labelStyle); d.CachedValue = EditorGUI.EnumPopup(fieldArea, (Enum)d.CachedValue); SetTooltipForRect(rect, d.InspectorTip); if (EditorGUI.EndChangeCheck()) { InvertApplication.Execute(() => { d.Setter(d.DataObject, d.CachedValue); }); } } else if (d.Type == typeof(Type)) { //InvertGraphEditor.WindowManager.InitTypeListWindow(); } } GUI.color = colorCache; }
public virtual void DrawInspector(PropertyFieldViewModel d, GUIStyle labelStyle) { var labelWidth = 140; var labelWidtho = GUILayout.ExpandWidth(true); var colorCache = GUI.color; GUI.color = Color.white; if (d.InspectorType == InspectorType.GraphItems) { var item = d.CachedValue as IGraphItem; var text = "--Select--"; if (item != null) { text = item.Label; } //GUILayout.BeginHorizontal(); if (GUILayout.Button(d.Label + ": " + text, ElementDesignerStyles.ButtonStyle)) { var type = d.Type; var items = InvertGraphEditor.CurrentDiagramViewModel.CurrentRepository.AllOf <IGraphItem>().Where(p => type.IsAssignableFrom(p.GetType())); var menu = new SelectionMenu(); foreach (var graphItem in items) { var graphItem1 = graphItem; menu.AddItem(new SelectionMenuItem(graphItem, () => { InvertApplication.Execute(() => { d.Setter(d.DataObject, graphItem1); }); })); } InvertApplication.SignalEvent <IShowSelectionMenu>(_ => _.ShowSelectionMenu(menu)); // // InvertGraphEditor.WindowManager.InitItemWindow(items, // // },true); } SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); GUI.color = colorCache; //GUILayout.EndHorizontal(); return; } if (d.Type == typeof(string)) { if (d.InspectorType == InspectorType.TextArea) { EditorGUILayout.LabelField(d.Name, labelWidtho); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); EditorGUI.BeginChangeCheck(); d.CachedValue = EditorGUILayout.TextArea((string)d.CachedValue, GUILayout.Height(50)); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } if (Event.current.isKey && Event.current.keyCode == KeyCode.Return) { InvertApplication.Execute(() => { }); } } else if (d.InspectorType == InspectorType.TypeSelection) { GUILayout.BeginHorizontal(); //GUILayout.Label(d.ViewModel.Name); if (GUILayout.Button((string)d.CachedValue)) { d.NodeViewModel.Select(); // TODO 2.0 Open Selection? } SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); GUILayout.EndHorizontal(); } else { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle); d.CachedValue = EditorGUILayout.TextField((string)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } } else { if (d.Type == typeof(int)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.IntField((int)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(float)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.FloatField((float)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Vector2)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.Vector2Field(string.Empty, (Vector3)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Vector3)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.Vector3Field(string.Empty, (Vector3)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Color)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.ColorField((Color)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(Vector4)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.Vector4Field(string.Empty, (Vector4)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (d.Type == typeof(bool)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.Toggle((bool)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { d.Setter(d.DataObject, d.CachedValue); } } else if (typeof(Enum).IsAssignableFrom(d.Type)) { EditorGUI.BeginChangeCheck(); GUILayout.BeginHorizontal(); GUILayout.Label(d.Name, labelStyle, labelWidtho); d.CachedValue = EditorGUILayout.EnumPopup((Enum)d.CachedValue); GUILayout.EndHorizontal(); SetTooltipForRect(GUILayoutUtility.GetLastRect(), d.InspectorTip); if (EditorGUI.EndChangeCheck()) { InvertApplication.Execute(() => { d.Setter(d.DataObject, d.CachedValue); }); } } else if (d.Type == typeof(Type)) { //InvertGraphEditor.WindowManager.InitTypeListWindow(); } } GUI.color = colorCache; }
public void DrawBreadcrumbs(IPlatformDrawer platform, float y) { var navPanelRect = new Rect(4, y, 60, 30f); var breadcrumbsRect = new Rect(64, y, Bounds.width - 44, 30f); platform.DrawRect(Bounds.WithOrigin(0, y).WithHeight(30), InvertGraphEditor.Settings.BackgroundColor); var back = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.LeftHalf()); platform.DoButton(back, "", ElementDesignerStyles.WizardActionButtonStyleSmall, () => { InvertApplication.Execute(new NavigateBackCommand()); }); platform.DrawImage(back.PadSides(4), "BackIcon", true); var forward = new Rect().WithSize(30, 30).PadSides(2).CenterInsideOf(navPanelRect.RightHalf()); platform.DoButton(forward, "", ElementDesignerStyles.WizardActionButtonStyleSmall, () => { InvertApplication.Execute(new NavigateForwardCommand()); }); platform.DrawImage(forward.PadSides(4), "ForwardIcon", true); //var color = new Color(InvertGraphEditor.Settings.BackgroundColor.r * 0.8f, InvertGraphEditor.Settings.BackgroundColor.g * 0.8f, InvertGraphEditor.Settings.BackgroundColor.b * 0.8f, 1f); //platform.DrawRect(rect, color); // var lineRect = new Rect(rect); // lineRect.height = 2; // lineRect.y = y + 38f; // platform.DrawRect(lineRect, new Color(InvertGraphEditor.Settings.BackgroundColor.r * 0.6f, InvertGraphEditor.Settings.BackgroundColor.g * 0.6f, InvertGraphEditor.Settings.BackgroundColor.b * 0.6f, 1f)); // // // var first = true; // if (_cachedPaths != null) // foreach (var item in _cachedPaths) // { // var item1 = item; // platform.DoButton(new Rect(x, rect.y + 20 - (item.Value.y / 2), item.Value.x, item.Value.y), first ? item.Key.Name : "< " + item.Key.Name, first ? CachedStyles.GraphTitleLabel : CachedStyles.ItemTextEditingStyle, // () => // { // InvertApplication.Execute(new LambdaCommand(() => // { // DiagramViewModel.GraphData.PopToFilter(item1.Key); // })); // }); // x += item.Value.x + 15; // first = false; // } var x = 1f; var styles = DiagramViewModel.NavigationViewModel.BreadcrumbsStyle; var iconsTine = new Color(1, 1, 1, 0.5f); foreach (var usitem in DiagramViewModel.NavigationViewModel.Breadcrubs.ToArray()) { var item = usitem; var textSize = platform.CalculateTextSize(usitem.Title, CachedStyles.BreadcrumbTitleStyle); float buttonContentPadding = 5; float buttonIconsPadding = 5; bool useSpecIcon = !string.IsNullOrEmpty(item.SpecializedIcon); var buttonWidth = textSize.x + buttonContentPadding * 2 + 8; if (!string.IsNullOrEmpty(item.Icon)) { buttonWidth += buttonIconsPadding + 16; } if (useSpecIcon) { buttonWidth += buttonIconsPadding + 16; } var buttonRect = new Rect() .AlignAndScale(breadcrumbsRect) .WithWidth(buttonWidth) .PadSides(3) .Translate(x, 0); var icon1Rect = new Rect() .WithSize(16, 16) .AlignTopRight(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(-buttonContentPadding, 0); var icon2Rect = new Rect() .WithSize(16, 16) .Align(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(buttonContentPadding, 0); var textRect = new Rect() .WithSize(textSize.x, textSize.y) .Align(useSpecIcon ? icon2Rect : buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(useSpecIcon ? buttonIconsPadding + 16 : buttonContentPadding, -1); var dotRect = new Rect() .WithSize(16, 16) .RightOf(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(-3, 0); platform.DoButton(buttonRect, "", item.State == NavigationItemState.Current ? CachedStyles.BreadcrumbBoxActiveStyle : CachedStyles.BreadcrumbBoxStyle, item.NavigationAction); platform.DrawLabel(textRect, item.Title, CachedStyles.BreadcrumbTitleStyle, DrawingAlignment.MiddleCenter); platform.DrawImage(icon1Rect, styles.GetIcon(item.Icon, iconsTine), true); if (useSpecIcon) { platform.DrawImage(icon2Rect, styles.GetIcon(item.SpecializedIcon, iconsTine), true); } if (item.State != NavigationItemState.Current) { platform.DrawImage(dotRect, styles.GetIcon("DotIcon", iconsTine), true); } x += buttonRect.width + 16 - 6; } }