public void DrawWorkspacesList(IPlatformDrawer platform, Rect bounds, List <WorkspacesListItem> items) { platform.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); platform.DrawLabel(headerRect, "Workspaces", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); var unpaddedItemRect = bounds.Below(headerRect).WithHeight(100); var workspaces = 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) * workspaces.Length); _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect); foreach (var db in workspaces) { var workspace = db; platform.DrawStretchBox(unpaddedItemRect, CachedStyles.WizardListItemBoxStyle, 2); var itemRect = unpaddedItemRect.PadSides(15); var titleRect = itemRect.WithHeight(40); platform.DrawLabel(titleRect, db.Workspace.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopLeft); var infoRect = itemRect.Below(titleRect).WithHeight(30); //(platform 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 deleteButton = configButton.LeftOf(configButton).Translate(-2, 0); platform.DoButton(openButton, "Open", ElementDesignerStyles.DarkButtonStyle, () => { Execute(new OpenWorkspaceCommand() { Workspace = workspace.Workspace }); EnableWizard = false; }); var db1 = db; platform.DoButton(configButton, "Config", ElementDesignerStyles.DarkButtonStyle, () => InvokeConfigFor(db1)); platform.DoButton(deleteButton, "Remove", ElementDesignerStyles.DarkButtonStyle, () => { Execute(new RemoveWorkspaceCommand() { Workspace = workspace.Workspace }); }); //platform.DoButton(showButton, "Show In Explorer", ElementDesignerStyles.ButtonStyle, () => { }); unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0, 1); } GUI.EndScrollView(true); }
public override void Draw(IPlatformDrawer platform, float scale) { DrawBackground(platform, scale); var b = new Rect(Bounds); b.x += 10; b.width -= 20; //base.Draw(platform, scale); platform.DrawColumns(b.Scale(scale), new float[] { _typeSize.x + 5, _nameSize.x }, _ => { platform.DoButton(_, _cachedTypeName, CachedStyles.ClearItemStyle, OptionClicked, OptionRightClicked); }, _ => { DrawName(_, platform, scale, DrawingAlignment.MiddleRight); platform.DoButton(_, "", CachedStyles.ClearItemStyle, () => { if (ItemViewModel.IsSelected) { //TODO: Eliminate hack: due to the inconsistent input mechanisms, I cannot fix: when clicking on type, type window appear, then click on the property, //editing will begin, but type window will stay there. So here is a hack of signaling HideSelection event. InvertApplication.SignalEvent <IHideSelectionMenu>(__ => __.HideSelection()); ItemViewModel.BeginEditing(); } else { ItemViewModel.Select(); } }, OptionRightClicked); }); }
public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); if (IsSelected) { var selectedChild = Children.Skip(1).FirstOrDefault(p => p.IsSelected); var width = 85f; var buttonHeight = 25; var toolbarRect = new Rect(this.Bounds.x - width - 4, this.Bounds.y + 8, width, selectedChild == null ? (buttonHeight * 3) + 20 : (buttonHeight * 4) + 20); platform.DrawStretchBox(toolbarRect, CachedStyles.WizardSubBoxStyle, 12f); toolbarRect.y += 10; var x = toolbarRect.x; var y = toolbarRect.y; if (selectedChild != null) { platform.DoButton(new Rect(x, y, toolbarRect.width, buttonHeight), "Remove", CachedStyles.WizardListItemBoxStyle, () => { NodeViewModel.RemoveSelected(); }); y += buttonHeight; } platform.DoButton(new Rect(x, y, toolbarRect.width, buttonHeight), "+ Add Section", CachedStyles.WizardListItemBoxStyle, () => { ShowAddPointerMenu <ShellNodeConfigSection>("Section", () => { NodeViewModel.AddSectionItem(); }, _ => { NodeViewModel.AddSectionPointer(_); }); }); y += buttonHeight; platform.DoButton(new Rect(x, y, toolbarRect.width, buttonHeight), "+ Input", CachedStyles.WizardListItemBoxStyle, () => { ShowAddPointerMenu <ShellNodeConfigInput>("Input", () => { NodeViewModel.AddInputItem(); }, _ => { NodeViewModel.AddInputPointer(_); }); }); y += buttonHeight; platform.DoButton(new Rect(x, y, toolbarRect.width, buttonHeight), "+ Output", CachedStyles.WizardListItemBoxStyle, () => { ShowAddPointerMenu <ShellNodeConfigOutput>("Output", () => { NodeViewModel.AddOutputItem(); }, _ => { NodeViewModel.AddOutputPointer(_); }); }); y += buttonHeight; } }
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 DrawActionDialog(IPlatformDrawer platform, Rect bounds, ActionItem item, 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 override void Draw(IPlatformDrawer platform, float scale) { DrawBackground(platform, scale); var b = new Rect(Bounds); b.x += 10; b.width -= 20; //base.Draw(platform, scale); platform.DrawColumns(b.Scale(scale), new float[] { _typeSize.x + 5, _nameSize.x }, _ => { platform.DoButton(_, _cachedTypeName, CachedStyles.ClearItemStyle, OptionClicked, OptionRightClicked); }, _ => { DrawName(_, platform, scale, DrawingAlignment.MiddleRight); platform.DoButton(_, "", CachedStyles.ClearItemStyle, () => { if (ItemViewModel.IsSelected) { //TODO: Eliminate hack: due to the inconsistent input mechanisms, I cannot fix: when clicking on type, type window appear, then click on the property, //editing will begin, but type window will stay there. So here is a hack of signaling HideSelection event. InvertApplication.SignalEvent<IHideSelectionMenu>(__ => __.HideSelection()); ItemViewModel.BeginEditing(); } else ItemViewModel.Select(); }, OptionRightClicked); }); }
public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); platform.DrawStretchBox(Bounds.Scale(scale), CachedStyles.Item6, 0f); //platform.DrawStretchBox(Bounds,CachedStyles.Item1, 0); _AddButtonRect = new Rect { y = Bounds.y + ((Bounds.height / 2) - 8), x = (Bounds.x + Bounds.width) - 22, width = 16, height = 16 }; var b = new Rect(Bounds); b.x += 8; b.width -= 27; platform.DrawLabel(b.Scale(scale), ViewModel.Name, ViewModel.IsBig ? CachedStyles.NodeStyleSchemaBold.SubTitleStyleObject : CachedStyles.HeaderStyle); if (ViewModel.AddCommand != null && ViewModel.Enabled) { platform.DoButton(_AddButtonRect.Scale(scale), string.Empty, CachedStyles.AddButtonStyle, () => { var vm = this.ViewModel.NodeViewModel as GraphItemViewModel; vm.Select(); ViewModel.Add(); //InvertGraphEditor.ExecuteCommand(ViewModel.AddCommand); }); } }
protected override void DrawChildren(IPlatformDrawer platform, float scale) { for (int index = 0; index < Children.Count; index++) { var item = Children[index]; if (index == 0) { item.Draw(platform, scale); continue; } var optionsBounds = new Rect(item.Bounds.x, item.Bounds.y + 4, item.Bounds.width, item.Bounds.height); if (item.IsSelected) { platform.DrawStretchBox(optionsBounds, CachedStyles.Item1, 0f); } optionsBounds.width -= 35; //optionsBounds.x += 15; item.Draw(platform, scale); platform.DoButton(optionsBounds, "", CachedStyles.ClearItemStyle, () => { ViewModel.DiagramViewModel.DeselectAll(); ViewModel.Select(); item.ViewModelObject.Select(); InvertApplication.SignalEvent <IGraphSelectionEvents>(_ => _.SelectionChanged(item.ViewModelObject)); }); } }
public void DrawWorkspacesWizard(Rect bounds) { var actions = new List <ActionItem>(); var items = new List <WorkspacesListItem>(); var databasesActionsBounds = bounds.LeftHalf().TopHalf().PadSides(2); var databasesListBounds = bounds.RightHalf().PadSides(2); var databasesActionInspectorBounds = bounds.LeftHalf().BottomHalf().PadSides(2); var closeButtonBounds = new Rect().WithSize(80, 30).InnerAlignWithBottomRight(databasesListBounds.PadSides(15)); Signal <IQueryWorkspacesActions>(_ => _.QueryWorkspacesActions(actions)); Signal <IQueryWorkspacesListItems>(_ => _.QueryWorkspacesListItems(items)); Signal <IDrawActionsPanel>(_ => _.DrawActionsPanel(Drawer, databasesActionsBounds, actions, (a, m) => SelectedAction = a)); Signal <IDrawActionDialog>(_ => _.DrawActionDialog(Drawer, databasesActionInspectorBounds, SelectedAction, () => SelectedAction = null)); Signal <IDrawWorkspacesList>(_ => _.DrawWorkspacesList(Drawer, databasesListBounds, items)); Drawer.DoButton(closeButtonBounds, "Close", ElementDesignerStyles.DarkButtonStyle, () => { if (WorkspaceService.CurrentWorkspace == null) { Signal <INotify>(_ => _.Notify("You need to select or create a Workspace!", NotificationIcon.Info)); } else { EnableWizard = false; } }); }
public void DrawNavigationHistory(Rect rect) { GUIHelpers.IsInspector = false; if (Drawer == null) { return; } if (_updateRequired) { UpdateItems(); _updateRequired = false; } Drawer.DrawStretchBox(rect, CachedStyles.WizardListItemBoxStyle, 10); if (!NavHistoryItems.Any()) { var textRect = rect; var cacheColor = GUI.color; GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.4f); Drawer.DrawLabel(textRect, "No History", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter); GUI.color = cacheColor; return; } var clearButton = new Rect().WithSize(80, 33).InnerAlignWithBottomRight(rect).PadSides(5); Drawer.DoButton(clearButton, "Clear", ElementDesignerStyles.ButtonStyle, m => { Execute(new LambdaCommand("Clear Navigation History", () => { Repository.RemoveAll <NavHistoryItem>(); })); }); if (NavHistoryTree == null) { return; } if (NavHistoryTree.IsDirty) { NavHistoryTree.Refresh(); } Signal <IDrawTreeView>(_ => _.DrawTreeView(rect.AddHeight(-28).PadSides(5), NavHistoryTree, (m, i) => { var bp = i as NavHistoryItem; if (bp != null) { Execute(new NavigateByHistoryItemCommand() { Item = bp, }); } })); }
public override void Draw(IPlatformDrawer platform, float scale) { base.Draw(platform, scale); var messageRect = new Rect(5, 5, 100, 15); foreach (var messages in ViewModel.Messages) { var message = string.Format("{0} : {1}", Enum.GetName(typeof(MessageType), messages.MessageType), messages.Message); platform.DrawLabel(messageRect, message, CachedStyles.HeaderTitleStyle); messageRect = new Rect(messageRect) { y = messageRect.y + messageRect.height }; } var typeRect = new Rect(250, 5, 150, 24); platform.DoButton(typeRect, "All", ElementDesignerStyles.ButtonStyle, () => { ViewModel.SelectFilterType(null); }); foreach (var type in ViewModel.AvailableTypes) { typeRect = new Rect(typeRect) { y = typeRect.y + typeRect.height }; var type1 = type; platform.DoButton(typeRect, type.Name, ElementDesignerStyles.ButtonStyle, () => { ViewModel.SelectFilterType(type1); }); } }
/// <summary> /// Draw Diagram tab /// </summary> /// <param name="platform"></param> /// <param name="buttonRect"></param> /// <param name="textRect"></param> /// <param name="buttonBoxRect"></param> /// <param name="closeButtonRect"></param> /// <param name="tab"></param> public void DrawTab(IPlatformDrawer platform, Rect buttonRect, Rect textRect, Rect buttonBoxRect, Rect closeButtonRect, NavigationItem tab) { platform.DrawStretchBox(buttonRect, tab.State == NavigationItemState.Current ? CachedStyles.TabBoxActiveStyle : CachedStyles.TabBoxStyle, 10); platform.DrawTabLabel(textRect, tab.Title, CachedStyles.TabTitleStyle); platform.DoButton(buttonBoxRect, "", CachedStyles.ClearItemStyle, m => { if (tab.NavigationAction != null) { tab.NavigationAction(m); } }, m => { if (tab.NavigationActionSecondary != null) { tab.NavigationActionSecondary(m); } }); if (tab.State == NavigationItemState.Current) { platform.DoButton(closeButtonRect, "", CachedStyles.TabCloseButton, m => { if (tab.CloseAction != null) { tab.CloseAction(m); } }); } }
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); }
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); }
//TODO WIZARDS: Add scrolling (drawer needs to be extended to support scrolling / or use native unity stuff) public void DrawActionsPanel(IPlatformDrawer platform, Rect bounds, List <ActionItem> actions, Action <ActionItem, Vector2> primaryAction, Action <ActionItem, Vector2> secondaryAction = null) { platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13); bounds = bounds.PadSides(15); var headerRect = new Rect(bounds.WithHeight(40)); platform.DrawLabel(headerRect, "Actions", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); bounds = bounds.Below(headerRect).Clip(bounds); var buttonSize = 100; var buttonsPerRow = (int)bounds.width / (int)buttonSize; var buttonIndex = 0; var padding = (bounds.width % buttonSize) / (buttonsPerRow - 1); var itemRect = new Rect().Align(bounds).WithSize(buttonSize, buttonSize); foreach (var action in actions) { platform.DrawStretchBox(itemRect, CachedStyles.WizardActionButtonStyle, 0); var action1 = action; platform.DoButton(itemRect, "", CachedStyles.ClearItemStyle, m => { primaryAction(action1, m); }, m => { if (secondaryAction != null) { secondaryAction(action1, m); } }); var imageRect = itemRect .WithSize(41, 41) .CenterInsideOf(itemRect) .AlignHorisontally(itemRect) .Translate(0, 10); var titleRect = itemRect .Below(imageRect) .Clip(itemRect) .Pad(5, 0, 10, 0) .Translate(0, -2); platform.DrawImage(imageRect, string.IsNullOrEmpty(action.Icon) ? "CreateEmptyDatabaseIcon" : action.Icon, true); platform.DrawLabel(titleRect, action.Title, CachedStyles.ListItemTitleStyle, DrawingAlignment.MiddleCenter); buttonIndex++; if (buttonIndex % buttonsPerRow == 0) { itemRect = itemRect.Below(itemRect).AlignVertically(bounds).Translate(0, 10); } else { itemRect = itemRect.RightOf(itemRect).Translate(padding, 0); } } }
/// <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 DrawWorkspacesList(IPlatformDrawer platform, Rect bounds, List<WorkspacesListItem> items) { platform.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); platform.DrawLabel(headerRect, "Workspaces", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); var unpaddedItemRect = bounds.Below(headerRect).WithHeight(100); var workspaces = 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) * workspaces.Length); _scrollPos = GUI.BeginScrollView(position, _scrollPos, usedRect); foreach (var db in workspaces) { var workspace = db; platform.DrawStretchBox(unpaddedItemRect, CachedStyles.WizardListItemBoxStyle, 2); var itemRect = unpaddedItemRect.PadSides(15); var titleRect = itemRect.WithHeight(40); platform.DrawLabel(titleRect, db.Workspace.Title, CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopLeft); var infoRect = itemRect.Below(titleRect).WithHeight(30); //(platform 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 deleteButton = configButton.LeftOf(configButton).Translate(-2, 0); platform.DoButton(openButton, "Open", ElementDesignerStyles.DarkButtonStyle, () => { Execute(new OpenWorkspaceCommand() { Workspace = workspace.Workspace }); EnableWizard = false; }); var db1 = db; platform.DoButton(configButton, "Config", ElementDesignerStyles.DarkButtonStyle, () => InvokeConfigFor(db1)); platform.DoButton(deleteButton, "Remove", ElementDesignerStyles.DarkButtonStyle, () => { Execute(new RemoveWorkspaceCommand() { Workspace = workspace.Workspace }); }); //platform.DoButton(showButton, "Show In Explorer", ElementDesignerStyles.ButtonStyle, () => { }); unpaddedItemRect = unpaddedItemRect.Below(unpaddedItemRect).Translate(0, 1); } GUI.EndScrollView(true); }
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; } }
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); } }); // 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 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; } }
//TODO WIZARDS: Add scrolling (drawer needs to be extended to support scrolling / or use native unity stuff) public void DrawActionsPanel(IPlatformDrawer platform, Rect bounds, List<ActionItem> actions, Action<ActionItem,Vector2> primaryAction, Action<ActionItem,Vector2> secondaryAction = null) { platform.DrawStretchBox(bounds, CachedStyles.WizardSubBoxStyle, 13); bounds = bounds.PadSides(15); var headerRect = new Rect(bounds.WithHeight(40)); platform.DrawLabel(headerRect, "Actions", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.TopCenter); bounds = bounds.Below(headerRect).Clip(bounds); var buttonSize = 100; var buttonsPerRow = (int)bounds.width / (int)buttonSize; var buttonIndex = 0; var padding = (bounds.width % buttonSize) / (buttonsPerRow - 1); var itemRect = new Rect().Align(bounds).WithSize(buttonSize, buttonSize); foreach (var action in actions) { platform.DrawStretchBox(itemRect, CachedStyles.WizardActionButtonStyle, 0); var action1 = action; platform.DoButton(itemRect,"",CachedStyles.ClearItemStyle, m => { primaryAction(action1, m); }, m => { if (secondaryAction != null) { secondaryAction(action1, m); } }); var imageRect = itemRect .WithSize(41, 41) .CenterInsideOf(itemRect) .AlignHorisontally(itemRect) .Translate(0, 10); var titleRect = itemRect .Below(imageRect) .Clip(itemRect) .Pad(5, 0, 10, 0) .Translate(0, -2); platform.DrawImage(imageRect, string.IsNullOrEmpty(action.Icon) ? "CreateEmptyDatabaseIcon" : action.Icon, true); platform.DrawLabel(titleRect, action.Title, CachedStyles.ListItemTitleStyle, DrawingAlignment.MiddleCenter); buttonIndex++; if (buttonIndex % buttonsPerRow == 0) { itemRect = itemRect.Below(itemRect).AlignVertically(bounds).Translate(0, 10); } else { itemRect = itemRect.RightOf(itemRect).Translate(padding, 0); } } }
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 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; } }
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); } }