public void DrawDatabasesList(IPlatformDrawer Drawer, Rect bounds, List <DatabasesListItem> items) { Drawer.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13); var scrollBounds = bounds.Translate(15, 0).Pad(0, 0, 15, 0); bounds = bounds.PadSides(15); var headerRect = bounds.WithHeight(40); Drawer.DrawLabel(headerRect, "Databases", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); var unpaddedItemRect = bounds.Below(headerRect).WithHeight(150); var databasesListItems = items.ToArray(); var position = scrollBounds.Below(headerRect).Clip(scrollBounds).Pad(0, 0, 0, 55); var usedRect = position.Pad(0, 0, 15, 0).WithHeight((unpaddedItemRect.height + 1) * databasesListItems.Length); _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect); foreach (var db in databasesListItems) { Drawer.DrawStretchBox(unpaddedItemRect, CachedStyles.WizardListItemBoxStyle, 2); var itemRect = unpaddedItemRect.PadSides(15); var titleRect = itemRect.WithHeight(40); Drawer.DrawLabel(titleRect, db.GraphConfiguration.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopLeft); var infoRect = itemRect.Below(titleRect).WithHeight(50); (Drawer as UnityDrawer).DrawInfo(infoRect, string.Format("Namespace: {0}\nPath: {1}", db.GraphConfiguration.Namespace ?? "-", db.GraphConfiguration.FullPath)); var openButton = new Rect().WithSize(80, 25).InnerAlignWithBottomRight(itemRect); var configButton = openButton.LeftOf(openButton).Translate(-2, 0); var showButton = configButton.WithWidth(120).InnerAlignWithBottomLeft(itemRect); Drawer.DoButton(openButton, "Open", ElementDesignerStyles.DarkButtonStyle, () => { Signal <IChangeDatabase>(_ => _.ChangeDatabase(db.GraphConfiguration)); }); Drawer.SetTooltipForRect(openButton, "Open this database."); var db1 = db; Drawer.DoButton(configButton, "Config", ElementDesignerStyles.DarkButtonStyle, () => { SelectedItem = new ActionItem() { Command = new EditDatabaseCommand() { Namespace = db1.GraphConfiguration.Namespace, CodePath = db1.GraphConfiguration.CodeOutputPath, Configuration = db1.GraphConfiguration as uFrameDatabaseConfig }, Description = "Configuration", Title = string.Format("Configure {0}", db1.GraphConfiguration.Title), Verb = "Apply" }; }); Drawer.DoButton(showButton, "Show In Explorer", ElementDesignerStyles.DarkButtonStyle, () => { EditorUtility.RevealInFinder(db1.GraphConfiguration.FullPath); }); unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0, 1); } GUI.EndScrollView(true); }
//uncomment to debug connector bounds //Color bc = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value,0.3f); public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); //uncomment to debug connector bounds //platform.DrawRect(Bounds,bc); //InvertGraphEditor.PlatformDrawer.DrawConnector(scale, ViewModel); var connectorFor = ViewModel.ConnectorFor; var connectorBounds = ViewModel.ConnectorFor.ConnectorBounds; var forItem = connectorFor as ItemViewModel; if (forItem != null) { if (forItem.NodeViewModel.IsCollapsed) { connectorBounds = forItem.NodeViewModel.ConnectorBounds; } } var nodePosition = connectorBounds; //var texture = Texture; var pos = new Vector2(0f, 0f); if (ViewModel.Side == ConnectorSide.Left) { pos.x = nodePosition.x; pos.y = nodePosition.y + (nodePosition.height * ViewModel.SidePercentage); pos.y -= (TextureHeight / 2f); pos.x -= (TextureWidth) + 2; } else if (ViewModel.Side == ConnectorSide.Right) { pos.x = nodePosition.x + nodePosition.width; pos.y = nodePosition.y + (nodePosition.height * ViewModel.SidePercentage); pos.y -= (TextureHeight / 2f); pos.x += 2; } else if (ViewModel.Side == ConnectorSide.Bottom) { pos.x = nodePosition.x + (nodePosition.width * ViewModel.SidePercentage); pos.y = nodePosition.y + nodePosition.height; pos.x -= (TextureWidth / 2f); //pos.y += TextureHeight; } else if (ViewModel.Side == ConnectorSide.Top) { pos.x = nodePosition.x + (nodePosition.width * ViewModel.SidePercentage); pos.y = nodePosition.y; pos.x -= (TextureWidth / 2f); pos.y -= TextureHeight; } //if (ViewModel.IsMouseOver) //{ // var mouseOverBounds = new Rect(bounds); // ////mouseOverBounds.x -= mouseOverBounds.width*0.2f; // //mouseOverBounds.y += mouseOverBounds.height * 0.125f; // //mouseOverBounds.x += mouseOverBounds.width * 0.125f; // mouseOverBounds.width = 20; // mouseOverBounds.height = 20; // bounds = mouseOverBounds; //} //if (ViewModelObject.IsMouseOver) //{ // EditorGUI.DrawRect(Bounds.Scale(scale), Color.black); //} //if (!ViewModel.HasConnections) //if (!ViewModel.ConnectorFor.IsMouseOver && !ViewModel.ConnectorFor.IsSelected && !ViewModel.IsMouseOver) return; if (!ViewModel.AlwaysVisible) { if (!ViewModel.ConnectorFor.IsMouseOver && !ViewModel.ConnectorFor.IsSelected && !ViewModel.IsMouseOver && !ViewModel.HasConnections) { return; } } //if (ViewModel.HasConnections) //{ // platform.DrawImage(bounds, Texture, true); //} if (ViewModel.Direction == ConnectorDirection.Output && ViewModel.Side == ConnectorSide.Right) { Bounds = new Rect(pos.x, pos.y, TextureWidth, TextureHeight); //return; } else { Bounds = new Rect(pos.x, pos.y, TextureWidth, TextureHeight); } var padding = ViewModel.StyleSchema.Padding; Bounds = Bounds.Pad(padding.x, padding.y, padding.width, padding.height); var bounds = Bounds.Scale(scale); // if (ViewModel.IsMouseOver) // { platform.DrawImage(bounds, Texture, true); // platform.DrawImage(bounds, Texture, true); // } //platform.DrawImage(bounds, Texture, true); if (ViewModel.Direction == ConnectorDirection.Output && !string.IsNullOrEmpty(ViewModel.OutputDesctiption)) { platform.SetTooltipForRect(bounds, ViewModel.OutputDesctiption); } else if (!string.IsNullOrEmpty(ViewModel.InputDesctiption)) { platform.SetTooltipForRect(bounds, ViewModel.InputDesctiption); } //if (InvertGraphEditor.Settings.ShowGraphDebug && ViewModel.IsMouseOver) //{ // GUI.Label(new Rect(Bounds.x + 20, Bounds.y - 10, 500, 50), // this.ViewModel.DataObject.GetType().Name, // EditorStyles.miniBoldLabel); //} }
public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); var headerPadding = StyleSchema.HeaderPadding; // var headerBounds = new Rect( // Bounds.x - headerPadding.left, // Bounds.y, // Bounds.width + headerPadding.left * 2 + 1, // Bounds.height + (NodeViewModel.IsCollapsed ? 0 : -20) + headerPadding.bottom); var headerBounds = new Rect( //Bounds.x-headerPadding.left-1, Bounds.x - headerPadding.left + 1, Bounds.y + 1, Bounds.width + headerPadding.left + headerPadding.right + headerPadding.left - 6, Bounds.height + 0 + (NodeViewModel.IsCollapsed ? 9 : -2)); var image = HeaderImage; platform.DrawNodeHeader( headerBounds, NodeViewModel.IsCollapsed ? StyleSchema.CollapsedHeaderStyleObject : StyleSchema.ExpandedHeaderStyleObject, NodeViewModel.IsCollapsed, scale, image); // The bounds for the main text // var textBounds = new Rect(Bounds.x, Bounds.y + ((Bounds.height / 2f) - (TextSize.y / 2f)), Bounds.width, // Bounds.height); var padding = headerPadding; var titleBounds = new Rect( Bounds.x + padding.left, Bounds.y + padding.top + (StyleSchema.ShowSubtitle ? 1 : 0), Bounds.width - padding.right - padding.left - (StyleSchema.ShowIcon ? 16 : 0), //Subtract icon size if shown Bounds.height - padding.top - padding.bottom); var titleSize = platform.CalculateTextSize(NodeViewModel.Label, StyleSchema.TitleStyleObject); var subtitleBound = new Rect(Bounds.x + padding.left + 0, Bounds.y + padding.top + titleSize.y + 0, Bounds.width - padding.right, Bounds.height - padding.top); if (NodeViewModel.IsEditing && NodeViewModel.IsEditable) { //UnityEngine.GUI.SetNextControlName("EditingField"); //DiagramDrawer.IsEditingField = true; //UnityEditor.EditorGUI.BeginChangeCheck(); //var newText = GUI.TextField(textBounds.Scale(scale), NodeViewModel.Name, // ElementDesignerStyles.ViewModelHeaderEditingStyle); //if (UnityEditor.EditorGUI.EndChangeCheck()) //{ // NodeViewModel.Rename(newText); // Dirty = true; //} //textBounds.y += TextSize.y / 2f; platform.DrawTextbox(NodeViewModel.GraphItemObject.Identifier, titleBounds.Scale(scale), NodeViewModel.Name, CachedStyles.ViewModelHeaderStyle, (v, finished) => { NodeViewModel.Rename(v); ParentDrawer.Refresh(platform); if (finished) { NodeViewModel.EndEditing(); } }); } else { //var titleStyle = new GUIStyle(TextStyle); //titleStyle.normal.textColor = BackgroundStyle.normal.textColor; //titleStyle.alignment = TextAnchor.MiddleCenter; //titleStyle.fontSize = Mathf.RoundToInt(12*scale); platform.DrawLabel(titleBounds.Scale(scale), NodeViewModel.Label ?? string.Empty, StyleSchema.TitleStyleObject, StyleSchema.ShowSubtitle ? DrawingAlignment.TopLeft : DrawingAlignment.MiddleLeft); if (StyleSchema.ShowSubtitle && !string.IsNullOrEmpty(NodeViewModel.SubTitle)) { platform.DrawLabel(subtitleBound.Scale(scale), NodeViewModel.SubTitle ?? string.Empty, StyleSchema.SubTitleStyleObject, StyleSchema.ShowSubtitle ? DrawingAlignment.TopLeft : DrawingAlignment.MiddleLeft); } if (StyleSchema.ShowIcon && !string.IsNullOrEmpty(NodeViewModel.IconName)) { var iconsize = IconBounds ?? (IconBounds = new Vector2(16, 16)); var size = 16; var imageBounds = new Rect(Bounds.xMax - padding.right - size, Bounds.y + ((Bounds.height / 2f) - (size / 2f)), 16, 16); //var imageBounds = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(Bounds).AlignHorisonallyByCenter(headerBounds).Translate(-headerPadding.right,0); var cCache = GUI.color; GUI.color = new Color(cCache.r, cCache.g, cCache.b, 0.7f); platform.DrawImage(imageBounds.Scale(scale), IconImage, true); GUI.color = cCache; if (!string.IsNullOrEmpty(IconTooltip)) { platform.SetTooltipForRect(imageBounds.Scale(scale), IconTooltip); } } //GUI.Label(textBounds.Scale(scale), NodeViewModel.Label ?? string.Empty, titleStyle); //if (NodeViewModel.IsCollapsed) //{ // textBounds.y += TextSize.y/2f; // //titleStyle.fontSize = Mathf.RoundToInt(10*scale); // //titleStyle.fontStyle = FontStyle.Italic; // GUI.Label(textBounds.Scale(scale), NodeViewModel.SubTitle, titleStyle); //} } }
public void DrawTabs(IPlatformDrawer platform, Rect tabsRect) { var designerWindow = DiagramViewModel.NavigationViewModel.DesignerWindow; if (designerWindow != null && designerWindow.Designer != null) { var x = 1f; foreach (var tab in DiagramViewModel.NavigationViewModel.Tabs.ToArray()) { if (tab == null) { continue; } if (tab.Title == null) { continue; } var textSize = platform.CalculateTextSize(tab.Title, CachedStyles.TabTitleStyle); var buttonRect = new Rect() .AlignAndScale(tabsRect) .WithWidth(Math.Max(textSize.x + 21 + 16, 60)) .Translate(x, 0); var buttonBoxRect = new Rect().AlignAndScale(buttonRect) .WithWidth(textSize.x + 10); var textRect = new Rect() .AlignAndScale(buttonRect) .Pad(7, 0, 7, 0); var closeButton = new Rect() .WithSize(16, 16) .AlignTopRight(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(-7, 1); platform.DrawStretchBox(buttonRect, tab.State == NavigationItemState.Current ? CachedStyles.TabBoxActiveStyle : CachedStyles.TabBoxStyle, 10); platform.DrawLabel(textRect, tab.Title, CachedStyles.TabTitleStyle); var tab1 = tab; platform.DoButton(buttonBoxRect, "", CachedStyles.ClearItemStyle, m => { if (tab1.NavigationAction != null) { tab1.NavigationAction(m); } }, m => { if (tab1.NavigationActionSecondary != null) { tab1.NavigationActionSecondary(m); } }); platform.DoButton(closeButton, "", CachedStyles.TabCloseButton, m => { if (tab1.CloseAction != null) { tab1.CloseAction(m); } }); // if (GUILayout.Button(tab.Name, // isCurrent // ? ElementDesignerStyles.TabBoxStyle // : ElementDesignerStyles.TabBoxActiveStyle,GUILayout.MinWidth(150))) // { // var projectService = InvertGraphEditor.Container.Resolve<WorkspaceService>(); // // if (Event.current.button == 1) // { // // var isLastGraph = projectService.CurrentWorkspace.Graphs.Count() <= 1; // // if (!isLastGraph) // { // var tab1 = tab; // projectService.Repository.RemoveAll<WorkspaceGraph>(p=>p.WorkspaceId == projectService.CurrentWorkspace.Identifier && p.GraphId == tab1.Identifier); // var lastGraph = projectService.CurrentWorkspace.Graphs.LastOrDefault(); // if (isCurrent && lastGraph != null) // { // designerWindow.SwitchDiagram(lastGraph); // } // // } // } // else // { // designerWindow.SwitchDiagram(projectService.CurrentWorkspace.Graphs.FirstOrDefault(p => p.Identifier == tab.Identifier)); // } // // } // // var butRect = GUILayoutUtility.GetLastRect(); x += buttonRect.width + 2; } var newTabButtonRect = new Rect().WithSize(27, 27).Align(tabsRect).AlignHorisonallyByCenter(tabsRect).Translate(x + 2, 0); platform.SetTooltipForRect(newTabButtonRect, "Create or import new graphs"); platform.DoButton(newTabButtonRect, "", ElementDesignerStyles.WizardActionButtonStyleSmall, () => { InvertApplication.SignalEvent <INewTabRequested>(_ => _.NewTabRequested()); }); //platform.DrawImage(newTabButtonRect,"",true); platform.DrawImage(newTabButtonRect.PadSides(6), "PlusIcon_Micro", true); // GUILayout.FlexibleSpace(); // GUILayout.EndHorizontal(); // GUILayout.EndArea(); } }
public void DrawTabs(IPlatformDrawer platform, Rect tabsRect) { var designerWindow = DiagramViewModel.NavigationViewModel.DesignerWindow; if (designerWindow != null && designerWindow.Designer != null) { var x = 1f; foreach (var tab in DiagramViewModel.NavigationViewModel.Tabs.ToArray()) { if (tab == null) { continue; } if (tab.Title == null) { continue; } var textSize = platform.CalculateTextSize(tab.Title, CachedStyles.TabTitleStyle); var buttonRect = new Rect() .AlignAndScale(tabsRect) .WithWidth(Math.Max(textSize.x + 21 + 16, 60)) .Translate(x, 0); var buttonBoxRect = new Rect().AlignAndScale(buttonRect) .WithWidth(textSize.x + 10); var textRect = new Rect() .AlignAndScale(buttonRect) .Pad(7, 0, 7, 0); var closeButton = new Rect() .WithSize(16, 16) .AlignTopRight(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(-7, 1); platform.DrawStretchBox(buttonRect, tab.State == NavigationItemState.Current ? CachedStyles.TabBoxActiveStyle : CachedStyles.TabBoxStyle, 10); platform.DrawLabel(textRect, tab.Title, CachedStyles.TabTitleStyle); var tab1 = tab; platform.DoButton(buttonBoxRect, "", CachedStyles.ClearItemStyle, m => { if (tab1.NavigationAction != null) { tab1.NavigationAction(m); } }, m => { if (tab1.NavigationActionSecondary != null) { tab1.NavigationActionSecondary(m); } }); platform.DoButton(closeButton, "", CachedStyles.TabCloseButton, m => { if (tab1.CloseAction != null) { tab1.CloseAction(m); } }); x += buttonRect.width + 2; } var newTabButtonRect = new Rect().WithSize(27, 27).Align(tabsRect).AlignHorisonallyByCenter(tabsRect).Translate(x + 2, 0); platform.SetTooltipForRect(newTabButtonRect, "Create or import new graphs"); platform.DoButton(newTabButtonRect, "", ElementDesignerStyles.WizardActionButtonStyleSmall, () => { InvertApplication.SignalEvent <INewTabRequested>(_ => _.NewTabRequested()); }); platform.DrawImage(newTabButtonRect.PadSides(6), "PlusIcon_Micro", true); } }
public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); var headerPadding = StyleSchema.HeaderPadding; // var headerBounds = new Rect( // Bounds.x - headerPadding.left, // Bounds.y, // Bounds.width + headerPadding.left * 2 + 1, // Bounds.height + (NodeViewModel.IsCollapsed ? 0 : -20) + headerPadding.bottom); var headerBounds = new Rect( //Bounds.x-headerPadding.left-1, Bounds.x-headerPadding.left+1, Bounds.y+1, Bounds.width + headerPadding.left + headerPadding.right + headerPadding.left -6, Bounds.height+0 + (NodeViewModel.IsCollapsed ? 9 : -2)); var image = HeaderImage; platform.DrawNodeHeader( headerBounds, NodeViewModel.IsCollapsed ? StyleSchema.CollapsedHeaderStyleObject : StyleSchema.ExpandedHeaderStyleObject, NodeViewModel.IsCollapsed, scale,image); // The bounds for the main text // var textBounds = new Rect(Bounds.x, Bounds.y + ((Bounds.height / 2f) - (TextSize.y / 2f)), Bounds.width, // Bounds.height); var padding = headerPadding; var titleBounds = new Rect( Bounds.x + padding.left, Bounds.y + padding.top + (StyleSchema.ShowSubtitle ? 1 : 0 ) , Bounds.width-padding.right-padding.left-(StyleSchema.ShowIcon ? 16 : 0), //Subtract icon size if shown Bounds.height-padding.top-padding.bottom); var titleSize = platform.CalculateTextSize(NodeViewModel.Label, StyleSchema.TitleStyleObject); var subtitleBound = new Rect(Bounds.x + padding.left+0, Bounds.y + padding.top + titleSize.y + 0, Bounds.width-padding.right, Bounds.height-padding.top); if (NodeViewModel.IsEditing && NodeViewModel.IsEditable) { //UnityEngine.GUI.SetNextControlName("EditingField"); //DiagramDrawer.IsEditingField = true; //UnityEditor.EditorGUI.BeginChangeCheck(); //var newText = GUI.TextField(textBounds.Scale(scale), NodeViewModel.Name, // ElementDesignerStyles.ViewModelHeaderEditingStyle); //if (UnityEditor.EditorGUI.EndChangeCheck()) //{ // NodeViewModel.Rename(newText); // Dirty = true; //} //textBounds.y += TextSize.y / 2f; platform.DrawTextbox(NodeViewModel.GraphItemObject.Identifier, titleBounds.Scale(scale), NodeViewModel.Name, CachedStyles.ViewModelHeaderStyle, (v, finished) => { NodeViewModel.Rename(v); ParentDrawer.Refresh(platform); if (finished) { NodeViewModel.EndEditing(); } }); } else { //var titleStyle = new GUIStyle(TextStyle); //titleStyle.normal.textColor = BackgroundStyle.normal.textColor; //titleStyle.alignment = TextAnchor.MiddleCenter; //titleStyle.fontSize = Mathf.RoundToInt(12*scale); platform.DrawLabel(titleBounds.Scale(scale), NodeViewModel.Label ?? string.Empty, StyleSchema.TitleStyleObject, StyleSchema.ShowSubtitle ? DrawingAlignment.TopLeft : DrawingAlignment.MiddleLeft); if (StyleSchema.ShowSubtitle && !string.IsNullOrEmpty(NodeViewModel.SubTitle)) { platform.DrawLabel(subtitleBound.Scale(scale), NodeViewModel.SubTitle ?? string.Empty, StyleSchema.SubTitleStyleObject, StyleSchema.ShowSubtitle ? DrawingAlignment.TopLeft : DrawingAlignment.MiddleLeft); } if (StyleSchema.ShowIcon && !string.IsNullOrEmpty(NodeViewModel.IconName)) { var iconsize = IconBounds ?? (IconBounds = new Vector2(16,16)); var size = 16; var imageBounds = new Rect(Bounds.xMax - padding.right - size, Bounds.y + ((Bounds.height / 2f) - (size / 2f)), 16, 16); //var imageBounds = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(Bounds).AlignHorisonallyByCenter(headerBounds).Translate(-headerPadding.right,0); var cCache = GUI.color; GUI.color = new Color(cCache.r, cCache.g, cCache.b, 0.7f); platform.DrawImage(imageBounds.Scale(scale), IconImage, true); GUI.color = cCache; if (!string.IsNullOrEmpty(IconTooltip)) { platform.SetTooltipForRect(imageBounds.Scale(scale), IconTooltip); } } //GUI.Label(textBounds.Scale(scale), NodeViewModel.Label ?? string.Empty, titleStyle); //if (NodeViewModel.IsCollapsed) //{ // textBounds.y += TextSize.y/2f; // //titleStyle.fontSize = Mathf.RoundToInt(10*scale); // //titleStyle.fontStyle = FontStyle.Italic; // GUI.Label(textBounds.Scale(scale), NodeViewModel.SubTitle, titleStyle); //} } }
public void DrawTabs(IPlatformDrawer platform, Rect tabsRect) { var designerWindow = DiagramViewModel.NavigationViewModel.DesignerWindow; if (designerWindow != null && designerWindow.Designer != null) { var x = 1f; foreach (var tab in DiagramViewModel.NavigationViewModel.Tabs.ToArray()) { if (tab == null) continue; if (tab.Title == null) continue; var textSize = platform.CalculateTextSize(tab.Title, CachedStyles.TabTitleStyle); var buttonRect= new Rect() .AlignAndScale(tabsRect) .WithWidth(Math.Max(textSize.x + 21 + 16,60)) .Translate(x,0); var buttonBoxRect = new Rect().AlignAndScale(buttonRect) .WithWidth(textSize.x + 10); var textRect = new Rect() .AlignAndScale(buttonRect) .Pad(7, 0, 7, 0); var closeButton = new Rect() .WithSize(16, 16) .AlignTopRight(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(-7,1); platform.DrawStretchBox(buttonRect,tab.State == NavigationItemState.Current ? CachedStyles.TabBoxActiveStyle : CachedStyles.TabBoxStyle,10); platform.DrawLabel(textRect,tab.Title,CachedStyles.TabTitleStyle); var tab1 = tab; platform.DoButton(buttonBoxRect,"",CachedStyles.ClearItemStyle, m => { if (tab1.NavigationAction != null) tab1.NavigationAction(m); }, m => { if (tab1.NavigationActionSecondary != null) tab1.NavigationActionSecondary(m); }); platform.DoButton(closeButton,"",CachedStyles.TabCloseButton, m => { if (tab1.CloseAction != null) tab1.CloseAction(m); }); // if (GUILayout.Button(tab.Name, // isCurrent // ? ElementDesignerStyles.TabBoxStyle // : ElementDesignerStyles.TabBoxActiveStyle,GUILayout.MinWidth(150))) // { // var projectService = InvertGraphEditor.Container.Resolve<WorkspaceService>(); // // if (Event.current.button == 1) // { // // var isLastGraph = projectService.CurrentWorkspace.Graphs.Count() <= 1; // // if (!isLastGraph) // { // var tab1 = tab; // projectService.Repository.RemoveAll<WorkspaceGraph>(p=>p.WorkspaceId == projectService.CurrentWorkspace.Identifier && p.GraphId == tab1.Identifier); // var lastGraph = projectService.CurrentWorkspace.Graphs.LastOrDefault(); // if (isCurrent && lastGraph != null) // { // designerWindow.SwitchDiagram(lastGraph); // } // // } // } // else // { // designerWindow.SwitchDiagram(projectService.CurrentWorkspace.Graphs.FirstOrDefault(p => p.Identifier == tab.Identifier)); // } // // } // // var butRect = GUILayoutUtility.GetLastRect(); x += buttonRect.width+2; } var newTabButtonRect = new Rect().WithSize(27, 27).Align(tabsRect).AlignHorisonallyByCenter(tabsRect).Translate(x+2, 0); platform.SetTooltipForRect(newTabButtonRect,"Create or import new graphs"); platform.DoButton(newTabButtonRect,"",ElementDesignerStyles.WizardActionButtonStyleSmall,()=>{ InvertApplication.SignalEvent<INewTabRequested>(_=>_.NewTabRequested());}); //platform.DrawImage(newTabButtonRect,"",true); platform.DrawImage(newTabButtonRect.PadSides(6),"PlusIcon_Micro",true); // GUILayout.FlexibleSpace(); // GUILayout.EndHorizontal(); // GUILayout.EndArea(); } }
/// <summary> /// Draw Diagram Tabs and Add Graph Button /// </summary> /// <param name="platform"></param> /// <param name="tabsRect"></param> public void DrawTabs(IPlatformDrawer platform, Rect tabsRect) { var designerWindow = DiagramViewModel.NavigationViewModel.DesignerWindow; if (designerWindow != null && designerWindow.Designer != null) { var x = 1f; // Show Tab Buttons float maxButtonWidth = (tabsRect.width - 32) / DiagramViewModel.NavigationViewModel.Tabs.Count; foreach (var tab in DiagramViewModel.NavigationViewModel.Tabs.ToArray()) { if (tab == null) { continue; } if (tab.Title == null) { continue; } // Calculate Tab Button's rects (button, closebutton, text, buttonbox) var textSize = platform.CalculateTextSize(tab.Title, CachedStyles.TabTitleStyle); var buttonRect = new Rect().AlignAndScale(tabsRect) .WithWidth(Math.Min(textSize.x + 21 + 16, maxButtonWidth)) .Translate(x, 0); var closeButtonRect = new Rect() { width = 0 }; if (tab.State == NavigationItemState.Current) { closeButtonRect = new Rect().WithSize(16, 16) .AlignTopRight(buttonRect) .AlignHorisonallyByCenter(buttonRect) .Translate(-7, 1); } var textRect = new Rect().AlignAndScale(buttonRect) .Pad(7, 0, 14 + closeButtonRect.width, 0); var buttonBoxRect = new Rect().AlignAndScale(buttonRect) .WithWidth(textRect.width); // Draw Tab Button DrawTab(platform, buttonRect, textRect, buttonBoxRect, closeButtonRect, tab); x += buttonRect.width; } // Show New Graph Button var newTabButtonRect = new Rect().WithSize(27, 27).Align(tabsRect).AlignHorisonallyByCenter(tabsRect).Translate(x + 2, 0); platform.SetTooltipForRect(newTabButtonRect, "Create or import new graphs"); platform.DoButton(newTabButtonRect, "", ElementDesignerStyles.WizardActionButtonStyleSmall, () => { InvertApplication.SignalEvent <INewTabRequested>(_ => _.NewTabRequested()); }); platform.DrawImage(newTabButtonRect.PadSides(6), "PlusIcon_Micro", true); } }
public void DrawDatabasesList(IPlatformDrawer Drawer, Rect bounds, List<DatabasesListItem> items) { Drawer.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13); var scrollBounds = bounds.Translate(15,0).Pad(0,0,15,0); bounds = bounds.PadSides(15); var headerRect = bounds.WithHeight(40); Drawer.DrawLabel(headerRect, "Databases", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); var unpaddedItemRect = bounds.Below(headerRect).WithHeight(150); var databasesListItems = items.ToArray(); var position = scrollBounds.Below(headerRect).Clip(scrollBounds).Pad(0, 0, 0, 55); var usedRect = position.Pad(0, 0, 15, 0).WithHeight((unpaddedItemRect.height + 1)*databasesListItems.Length); _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect); foreach (var db in databasesListItems) { Drawer.DrawStretchBox(unpaddedItemRect,CachedStyles.WizardListItemBoxStyle,2); var itemRect = unpaddedItemRect.PadSides(15); var titleRect = itemRect.WithHeight(40); Drawer.DrawLabel(titleRect,db.GraphConfiguration.Title,CachedStyles.WizardSubBoxTitleStyle,DrawingAlignment.TopLeft); var infoRect = itemRect.Below(titleRect).WithHeight(50); (Drawer as UnityDrawer).DrawInfo(infoRect,string.Format("Namespace: {0}\nPath: {1}",db.GraphConfiguration.Namespace ?? "-",db.GraphConfiguration.FullPath)); var openButton = new Rect().WithSize(80,25).InnerAlignWithBottomRight(itemRect); var configButton = openButton.LeftOf(openButton).Translate(-2,0); var showButton = configButton.WithWidth(120).InnerAlignWithBottomLeft(itemRect); Drawer.DoButton(openButton, "Open", ElementDesignerStyles.DarkButtonStyle, () => { Signal<IChangeDatabase>(_=>_.ChangeDatabase(db.GraphConfiguration)); }); Drawer.SetTooltipForRect(openButton,"Open this database."); var db1 = db; Drawer.DoButton(configButton, "Config", ElementDesignerStyles.DarkButtonStyle, () => { SelectedItem = new ActionItem() { Command = new EditDatabaseCommand() { Namespace = db1.GraphConfiguration.Namespace, CodePath = db1.GraphConfiguration.CodeOutputPath, Configuration = db1.GraphConfiguration as uFrameDatabaseConfig }, Description = "Configuration", Title = string.Format("Configure {0}", db1.GraphConfiguration.Title), Verb = "Apply" }; }); Drawer.DoButton(showButton, "Show In Explorer", ElementDesignerStyles.DarkButtonStyle, () => { EditorUtility.RevealInFinder(db1.GraphConfiguration.FullPath); }); unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0,1); } GUI.EndScrollView(true); }