Ejemplo n.º 1
0
        public override void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {
            base.Refresh(platform, position, hardRefresh);

            if (hardRefresh || string.IsNullOrEmpty(_cachedItemName) || string.IsNullOrEmpty(_cachedTypeName))
            {
                _cachedItemName = TypedItemViewModel.Name;
                _cachedTypeName = TypedItemViewModel.RelatedType;
                _nameSize = platform.CalculateTextSize(_cachedItemName, CachedStyles.ClearItemStyle);
                _typeSize = platform.CalculateTextSize(_cachedTypeName, CachedStyles.ItemTextEditingStyle);
            }


            Bounds = new Rect(position.x, position.y, _nameSize.x + 5 + _typeSize.x + 40, 18);
        }
Ejemplo n.º 2
0
        public override void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {
            base.Refresh(platform, position, hardRefresh);

            TextSize = platform.CalculateTextSize(NodeViewModel.Label, StyleSchema.TitleStyleObject); //.CalcSize(new GUIContent(NodeViewModel.Label)));
            
            Vector2 subTitleSize = Vector2.zero; 
            
            if (StyleSchema.ShowSubtitle)
            {
                subTitleSize = platform.CalculateTextSize(NodeViewModel.SubTitle, StyleSchema.SubTitleStyleObject);
            }

            var padding = StyleSchema.HeaderPadding;

            var width = (TextSize.x > subTitleSize.x ? TextSize.x : subTitleSize.x)+(StyleSchema.ShowIcon ? 8 : 0); //Add icon padding

            var height = TextSize.y + subTitleSize.y + padding.top + padding.bottom;

            if (StyleSchema.ShowIcon && NodeViewModel.IconName != null)
            {
                var iconBounds = IconBounds ?? (IconBounds = new Vector2(16,16));
                width += iconBounds.Value.x;
//                if (height - Padding.y*2 < iconBounds.y)
//                {
//                    height = iconBounds.y + Padding.y*2;
//                }
            }

            if (NodeViewModel.IsCollapsed)
            {
                this.Bounds = new Rect(position.x, position.y, width + 12, height); //height > 35 ? height : 35);
            }
            else
            {
                this.Bounds = new Rect(position.x, position.y, width + 12, height); //height > 35 ? height : 35);
            }
            var cb = new Rect(this.Bounds);
            cb.width += 4;
            ViewModelObject.ConnectorBounds = cb;
        }
Ejemplo n.º 3
0
        public override void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {
            base.Refresh(platform, position, hardRefresh);
            if (hardRefresh)
            {
                ViewModel.CachedValue = ViewModel.Getter();
            }

            if (ViewModel.CustomDrawerType != null && hardRefresh)
            {
                CustomDrawer = (IInspectorPropertyDrawer)Activator.CreateInstance(ViewModel.CustomDrawerType);
            }


            if (CustomDrawer != null)
            {
                CustomDrawer.Refresh(platform, position, this);
            }
            else
            {
                var bounds = new Rect(Bounds)
                {
                    x = position.x, y = position.y
                };
                var labelSize = platform.CalculateTextSize(ViewModel.Name, CachedStyles.HeaderStyle);
                bounds.width = labelSize.x * 3;
                if (ViewModel.Type == typeof(Vector2) || ViewModel.Type == typeof(Vector3)
                    ) // || ViewModel.Type == typeof(Quaternion))
                {
                    bounds.height *= 2f;
                }

                bounds.x += 3;
                Bounds    = bounds;

                switch (ViewModel.InspectorType)
                {
                case InspectorType.GraphItems:
                    Bounds = Bounds.WithHeight(30);
                    break;

                case InspectorType.TextArea:
                    Bounds = Bounds.WithHeight(60);
                    break;
                }
            }
        }
Ejemplo n.º 4
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);

            var paddedBOunds = Bounds.PadSides(5);
            var headerBounds = paddedBOunds.WithHeight(20).Translate(0,10);
            Rect textBounds;
            var hasHeader = !string.IsNullOrEmpty(NodeViewModel.HeaderText);
            if (hasHeader)
            {
                textBounds = paddedBOunds.Below(headerBounds).Translate(0, 5).Clip(paddedBOunds);
            }
            else
            {
                textBounds = paddedBOunds;
            }

            if (NodeViewModel.ShowMark)
            {
                textBounds = textBounds.Pad(6, 0, 6, 0);
            }

            if (hasHeader)
            {
                var ts =platform.CalculateTextSize(NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle);
                platform.DrawLabel(headerBounds, NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle);

                var hmRect = new Rect().Align(headerBounds).WithSize(ts.x,2).Below(headerBounds).Translate(0,3);
                platform.DrawRect(hmRect, CachedStyles.GetColor(NodeColor.Gray));

            }

            if (NodeViewModel.ShowMark)
            {
                var markRect = textBounds.WithWidth(3).Pad(0,10,0,20).Translate(-6, 0);
                platform.DrawRect(markRect,CachedStyles.GetColor(NodeViewModel.MarkColor));
            }

            platform.DrawLabel(textBounds,ViewModel.Comments,CachedStyles.ListItemTitleStyle);
        }
Ejemplo n.º 5
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);

            var  paddedBOunds = Bounds.PadSides(5);
            var  headerBounds = paddedBOunds.WithHeight(20).Translate(0, 10);
            Rect imageBounds;
            var  hasHeader   = !string.IsNullOrEmpty(NodeViewModel.HeaderText);
            var  hasComments = !string.IsNullOrEmpty(NodeViewModel.Comments);

            if (hasHeader)
            {
                imageBounds = paddedBOunds.Below(headerBounds).Translate(0, 5).Clip(paddedBOunds);
            }
            else
            {
                imageBounds = paddedBOunds;
            }

            if (hasHeader)
            {
                var ts = platform.CalculateTextSize(NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle);
                platform.DrawLabel(headerBounds, NodeViewModel.HeaderText, CachedStyles.WizardSubBoxTitleStyle);

                var hmRect = new Rect().Align(headerBounds).WithSize(ts.x, 2).Below(headerBounds).Translate(0, 3);
                platform.DrawRect(hmRect, CachedStyles.GetColor(NodeColor.Gray));
            }

            if (!string.IsNullOrEmpty(NodeViewModel.ImageName) && Image != null)
            {
                platform.DrawImage(imageBounds, Image, true);
            }
            else
            {
                platform.DrawLabel(imageBounds, "Image Not Found", CachedStyles.WizardSubBoxTitleStyle);
            }
        }
Ejemplo n.º 6
0
        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();
            }
        }
Ejemplo n.º 7
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 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;
            }
        }
Ejemplo n.º 8
0
        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);
                //}
            }
        }
Ejemplo n.º 9
0
        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);
            }
        }
Ejemplo n.º 10
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;
            }
        }
Ejemplo n.º 11
0
        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);
                //}
            }
        }
Ejemplo n.º 12
0
        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();
            }
        }
Ejemplo n.º 13
0
        public override void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {
            base.Refresh(platform, position, hardRefresh);
            // Eventually it will all be viewmodels
            if (DiagramViewModel == null) return;
            Dictionary<IGraphFilter, Vector2> dictionary = new Dictionary<IGraphFilter, Vector2>();
            
            var first = true;
            foreach (var filter in new [] {DiagramViewModel.GraphData.RootFilter}.Concat(this.DiagramViewModel.GraphData.GetFilterPath()).Reverse())
            {


                var name = first ? filter.Name : "< " + filter.Name;
                dictionary.Add(filter, platform.CalculateTextSize(name, first ? CachedStyles.GraphTitleLabel : CachedStyles.ItemTextEditingStyle));
                first = false;
            }
                
            _cachedPaths = dictionary;

            Children.Clear();
            DiagramViewModel.Load(hardRefresh);
            Children.Add(SelectionRectHandler);
            Dirty = true;
            //_cachedChildren = Children.OrderBy(p => p.ZOrder).ToArray();
        }
Ejemplo n.º 14
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 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;

            }



        }
Ejemplo n.º 15
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);
            }
        }