コード例 #1
0
        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);
                });
        }
コード例 #2
0
ファイル: Drawer.cs プロジェクト: InvertGames/uFrame.Editor
 public virtual void Draw(IPlatformDrawer platform, float scale)
 {
     //if (ViewModelObject != null && ViewModelObject.IsDirty)
     //{
     //    Refresh(platform);
     //    ViewModelObject.IsDirty = false;
     //}
        
 }
コード例 #3
0
        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);

        }
コード例 #4
0
ファイル: Drawer.cs プロジェクト: InvertGames/uFrame.Editor
        public virtual void Refresh(IPlatformDrawer platform)
        {
            if (ViewModelObject == null)
            {
                Refresh(platform, Vector2.zero);
            }
            else
            {
                Refresh(platform, Bounds.position);
            }

        }
コード例 #5
0
        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);
            });
        }
コード例 #6
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);
        }
コード例 #7
0
    public override void Draw(IPlatformDrawer platform, float scale)
    {
        base.Draw(platform, scale);
        if (ViewModel == null) return;
        if (ViewModel.GraphItems == null) return;
        if (SelectionRect.width > 20 && SelectionRect.height > 20)
        {
            foreach (var item in ViewModel.GraphItems.OfType<DiagramNodeViewModel>())
            {
                item.IsSelected = SelectionRect.Scale(scale).Overlaps(item.Bounds.Scale(scale));
            }
#if UNITY_EDITOR
            platform.DrawStretchBox(SelectionRect.Scale(scale), CachedStyles.BoxHighlighter4, 12);
#else
            platform.DrawStretchBox(SelectionRect.Scale(scale), CachedStyles.BoxHighlighter4, 0);
#endif
        }
    }
コード例 #8
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);
            var _startRight = StartConnector.Direction == ConnectorDirection.Output;
            var _endRight = false;

            var startTan = _startPos + (_endRight ? -Vector2.right * 3 : Vector2.right * 3) * 30;

            var endTan = _endPos + (_startRight ? -Vector2.right * 3 : Vector2.right * 3) * 30;

            var shadowCol = new Color(0, 0, 0, 0.1f);

            for (int i = 0; i < 3; i++) // Draw a shadow
                platform.DrawBezier(_startPos * scale,
                    _endPos * scale, startTan * scale,
                    endTan * scale, shadowCol, (i + 1) * 5);

            InvertGraphEditor.PlatformDrawer.DrawBezier(_startPos * scale, _endPos * scale,
                startTan * scale, endTan * scale, color, 3);
        }
コード例 #9
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;
        }
コード例 #10
0
        public override void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {
            base.Refresh(platform, position, hardRefresh);
            var x      = position.x;
            var starty = position.y;

            this.Children.Clear();
            Children.AddRange(CreateDrawers());

            var y        = position.y;
            var height   = 0f;
            var maxWidth = 0f;

            foreach (var child in Children)
            {
                child.Refresh(platform, new Vector2(x + 10, y), hardRefresh);
                var rect = new Rect(child.Bounds);
                rect.y       = y;
                child.Bounds = rect;
                y           += child.Bounds.height;
                height      += child.Bounds.height;
                if (child.Bounds.width > maxWidth)
                {
                    maxWidth = child.Bounds.width;
                }
            }

            this.Bounds = new Rect(x, starty, maxWidth + 24, height);
            foreach (var child in Children)
            {
                var newRect = new Rect(child.Bounds)
                {
                    width = maxWidth
                };
                child.Bounds = newRect;
                child.OnLayout();
            }


            //Debug.Log("Bounds at " + position);
        }
コード例 #11
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);

            if (ViewModel.ShowHelp)
            {
                for (int index = 1; index <= NodeViewModel.ContentItems.Count; index++)
                {
                    var item = NodeViewModel.ContentItems[index - 1];
                    if (!string.IsNullOrEmpty(item.Comments))
                    {
                        var bounds = new Rect(item.Bounds);
                        bounds.width  = item.Bounds.height;
                        bounds.height = item.Bounds.height;
                        bounds.y     += (item.Bounds.height / 2) - 12;
                        bounds.x      = this.Bounds.x - (bounds.width + 4);
                        platform.DrawLabel(bounds, index.ToString(), CachedStyles.NodeHeader13, DrawingAlignment.MiddleCenter);
                    }
                }
            }
        }
コード例 #12
0
 public override void Draw(IPlatformDrawer platform, float scale)
 {
     base.Draw(platform, scale);
     GUI.Box(Bounds.Scale(scale), string.Empty, EditorStyles.textArea);
     foreach (var line in ViewModel.Lines)
     {
         foreach (var token in line.Tokens)
         {
             guiStyle.normal.textColor = token.Color;
             if (token.Bold)
             {
                 guiStyle.fontStyle = FontStyle.Bold;
             }
             else
             {
                 guiStyle.fontStyle = FontStyle.Normal;
             }
             GUI.Label(token.Bounds, token.Text, guiStyle);
         }
     }
 }
コード例 #13
0
ファイル: ConsoleDrawer.cs プロジェクト: yaoya/uFrame
        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);
                });
            }
        }
コード例 #14
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);
            if (EditorApplication.isPaused)
            {
                if (NodeViewModel.GraphItem.Identifier != DebugSystem.CurrentBreakId)
                {
                    var adjustedBounds = new Rect(Bounds.x - 9, Bounds.y + 1, Bounds.width + 19, Bounds.height + 9);
                    platform.DrawStretchBox(adjustedBounds, CachedStyles.BoxHighlighter5, 20);
                }
                else
                {
                    var adjustedBounds = new Rect(Bounds.x - 9, Bounds.y + 1, Bounds.width + 19, Bounds.height + 9);
                    platform.DrawStretchBox(adjustedBounds, CachedStyles.BoxHighlighter3, 20);
                }
            }

            var breakpointItemRect = new Rect().WithSize(24, 24).InnerAlignWithUpperRight(Bounds).Translate(16, -16);
            var deltaTime          = (DateTime.Now - _lastUpdate).TotalMilliseconds;

            _lastUpdate = DateTime.Now;


            if (EditorApplication.isPaused && NodeViewModel.GraphItem.Identifier == DebugSystem.CurrentBreakId)
            {
                _animationTime += (float)deltaTime;
                var offset = 8 * Mathf.Cos((_animationTime * 5f) / 1000);
                breakpointItemRect = breakpointItemRect.Translate(offset, -offset);
                //Apply animation to breakpoing item Rect
                platform.DrawImage(breakpointItemRect, "CurrentBreakpointIcon", true);
            }
            else
            {
                if (NodeViewModel.IsBreakpoint)
                {
                    platform.DrawImage(breakpointItemRect, "BreakpointIcon", true);
                }
                _animationTime = 0;
            }
        }
コード例 #15
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);
        }
コード例 #16
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);
            var _startRight = StartConnector.Direction == ConnectorDirection.Output;
            var _endRight   = false;

            var startTan = _startPos + (_endRight ? -Vector2.right * 3 : Vector2.right * 3) * 30;

            var endTan = _endPos + (_startRight ? -Vector2.right * 3 : Vector2.right * 3) * 30;

            var shadowCol = new Color(0, 0, 0, 0.1f);

            for (int i = 0; i < 3; i++) // Draw a shadow
            {
                platform.DrawBezier(_startPos * scale,
                                    _endPos * scale, startTan * scale,
                                    endTan * scale, shadowCol, (i + 1) * 5);
            }

            InvertGraphEditor.PlatformDrawer.DrawBezier(_startPos * scale, _endPos * scale,
                                                        startTan * scale, endTan * scale, color, 3);
        }
コード例 #17
0
        private void DrawStateLink(IPlatformDrawer platform, float scale)
        {
            var _startPos = ViewModel.ConnectorB.Bounds.center;
            var _endPos   = ViewModel.ConnectorA.Bounds.center;

            //var _startRight = ViewModel.ConnectorA.Direction == ConnectorDirection.Output;
            //var _endRight = ViewModel.ConnectorB.Direction == ConnectorDirection.Output;
            //Handles.color = ViewModel.CurrentColor;
            List <Vector2> points = new List <Vector2>();
            Vector2        curr;

            points.Add(curr = _startPos);

            if (_endPos.x < _startPos.x)
            {
                int offset = 0;
                if (_endPos.y < _startPos.y)
                {
                    offset = 10;
                }
                points.Add(curr = curr + new Vector2(20f + offset, 0f));
                points.Add(curr = curr + new Vector2(0f, (_endPos.y - _startPos.y) / 2f + offset));
                points.Add(_endPos - new Vector2(20f + offset, (_endPos.y - _startPos.y) / 2f - offset));
                points.Add(_endPos - new Vector2(20f + offset, 0f));
            }
            else
            {
                points.Add(curr = _startPos + new Vector2((_endPos.x - _startPos.x) / 2f, 0f));
                points.Add(new Vector2(curr.x, _endPos.y));
            }



            points.Add(_endPos);
            var scaled = points.Select(p => new Vector2(p.x * scale, p.y * scale)).ToArray();

            platform.DrawPolyLine(scaled, ViewModel.CurrentColor);
            platform.DrawPolyLine(scaled.Select(p => p + new Vector2(1f, 1f)).ToArray(), ViewModel.CurrentColor);
        }
コード例 #18
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {
            //base.Draw(platform, scale);
            platform.DrawStretchBox(this.Bounds, CachedStyles.BoxHighlighter1, 50f);

            if (ViewModel.SaveImage)
            {
                // Texture2D texture2D = new Texture2D(NodeViewModel.GraphItem.Width,NodeViewModel.GraphItem.Height, (TextureFormat)3, false);
                // var bounds = new Rect(this.Bounds);
                // bounds.y += editorWindow.position.height;
                //// bounds.y = lastRect.height - bounds.y - bounds.height;
                // texture2D.ReadPixels(bounds, 0, 0);
                // texture2D.Apply();
                // //string fullPath = Path.GetFullPath(Application.get_dataPath() + "/../" + Path.Combine(this.screenshotsSavePath, actionName) + ".png");
                // //if (!FsmEditorUtility.CreateFilePath(fullPath))
                // //    return;
                // byte[] bytes = texture2D.EncodeToPNG();
                // Object.DestroyImmediate((Object)texture2D, true);
                // File.WriteAllBytes("image.png", bytes);
                // ViewModel.SaveImage = false;
                // Debug.Log(this.Bounds.x.ToString() + " : " + this.Bounds.y);
            }
        }
コード例 #19
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);
            }
        }
コード例 #20
0
        private void DrawBeizureLink(IPlatformDrawer platform, float scale)
        {
            var _startPos = ViewModel.ConnectorA.Bounds.center;
            var _endPos   = ViewModel.ConnectorB.Bounds.center;

            var _startRight = ViewModel.ConnectorA.Direction == ConnectorDirection.Output;
            var _endRight   = ViewModel.ConnectorB.Direction == ConnectorDirection.Output;


            var multiplier = Mathf.Min(30f, (_endPos.x - _startPos.x) * 0.3f);


            var m2 = 3;

            if (multiplier < 0)
            {
                _startRight = !_startRight;
                _endRight   = !_endRight;
            }


            var startTan = _startPos + (_endRight ? -Vector2.right * m2 : Vector2.right * m2) * multiplier;

            var endTan = _endPos + (_startRight ? -Vector2.right * m2 : Vector2.right * m2) * multiplier;

            var shadowCol = new Color(0, 0, 0, 0.1f);

            //if (ViewModel.IsFullColor)
            for (int i = 0; i < 3; i++)     // Draw a shadow
            {
                platform.DrawBezier(_startPos * scale, _endPos * scale, startTan * scale,
                                    endTan * scale, shadowCol, (i + 1) * 5);
            }

            platform.DrawBezier(_startPos * scale, _endPos * scale, startTan * scale,
                                endTan * scale, ViewModel.CurrentColor, 3);
        }
コード例 #21
0
 public override void Draw(IPlatformDrawer platform, float scale)
 {
     if (CustomDrawer != null)
     {
         CustomDrawer.Draw(platform, scale, this);
     }
     else
     {
         Rect inspBounds;
         if (ViewModel.InspectorType == InspectorType.GraphItems)
         {
             inspBounds = Bounds.WithHeight(30).CenterInsideOf(Bounds);
         }
         else if (ViewModel.InspectorType == InspectorType.TextArea)
         {
             inspBounds = Bounds.WithHeight(60).CenterInsideOf(Bounds);
         }
         else
         {
             inspBounds = Bounds.WithHeight(17).CenterInsideOf(Bounds);
         }
         platform.DrawPropertyField(inspBounds.Pad(7, 0, 14, 0), this.ViewModel, scale);
     }
 }
コード例 #22
0
        /// <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);
                    }
                });
            }
        }
コード例 #23
0
    public override void Draw(IPlatformDrawer platform, float scale)
    {
        base.Draw(platform, scale);
        if (ViewModel == null)
        {
            return;
        }
        if (ViewModel.GraphItems == null)
        {
            return;
        }
        if (SelectionRect.width > 20 && SelectionRect.height > 20)
        {
            foreach (var item in ViewModel.GraphItems.OfType <DiagramNodeViewModel>())
            {
                item.IsSelected = SelectionRect.Scale(scale).Overlaps(item.Bounds.Scale(scale));
            }
#if UNITY_EDITOR
            platform.DrawStretchBox(SelectionRect.Scale(scale), CachedStyles.BoxHighlighter4, 12);
#else
            platform.DrawStretchBox(SelectionRect.Scale(scale), CachedStyles.BoxHighlighter4, 0);
#endif
        }
    }
コード例 #24
0
        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);
        }
コード例 #25
0
ファイル: Drawer.cs プロジェクト: DiazGames/oneGame
 public virtual void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
 {
 }
コード例 #26
0
 public void Refresh(IPlatformDrawer platform)
 {
 }
コード例 #27
0
 public override void Refresh(IPlatformDrawer platform)
 {
     base.Refresh(platform);
 }
コード例 #28
0
 public virtual void Draw(IPlatformDrawer platform, float scale)
 {
     
 }
コード例 #29
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;

            }



        }
コード例 #30
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();
        }
コード例 #31
0
 public override void Refresh(IPlatformDrawer platform)
 {
     //base.Refresh(platform);
     this.Bounds = new Rect(ViewModel.Position.x, ViewModel.Position.y, NodeViewModel.Width, NodeViewModel.Height);
 }
コード例 #32
0
        //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);
                }

            }
        }
コード例 #33
0
 public override void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
 {
     base.Refresh(platform, position, hardRefresh);
 }
コード例 #34
0
 public void Draw(IPlatformDrawer platform, float scale)
 {
     Refresh(PlatformDrawer, new Vector2(0, 0));
     DrawChildren();
 }
コード例 #35
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);
                //}
            }
        }
コード例 #36
0
        //uncomment to debug connector bounds
        //Color bc = new Color(UnityEngine.Random.value, UnityEngine.Random.value, UnityEngine.Random.value,0.3f);

        public override void Draw(IPlatformDrawer platform, float scale)
        {
            base.Draw(platform, scale);

            //uncomment to debug connector bounds
            //platform.DrawRect(Bounds,bc);

            //InvertGraphEditor.PlatformDrawer.DrawConnector(scale, ViewModel);
            var connectorFor    = ViewModel.ConnectorFor;
            var connectorBounds = ViewModel.ConnectorFor.ConnectorBounds;
            var forItem         = connectorFor as ItemViewModel;

            if (forItem != null)
            {
                if (forItem.NodeViewModel.IsCollapsed)
                {
                    connectorBounds = forItem.NodeViewModel.ConnectorBounds;
                }
            }
            var nodePosition = connectorBounds;
            //var texture = Texture;
            var pos = new Vector2(0f, 0f);

            if (ViewModel.Side == ConnectorSide.Left)
            {
                pos.x  = nodePosition.x;
                pos.y  = nodePosition.y + (nodePosition.height * ViewModel.SidePercentage);
                pos.y -= (TextureHeight / 2f);
                pos.x -= (TextureWidth) + 2;
            }
            else if (ViewModel.Side == ConnectorSide.Right)
            {
                pos.x  = nodePosition.x + nodePosition.width;
                pos.y  = nodePosition.y + (nodePosition.height * ViewModel.SidePercentage);
                pos.y -= (TextureHeight / 2f);
                pos.x += 2;
            }
            else if (ViewModel.Side == ConnectorSide.Bottom)
            {
                pos.x  = nodePosition.x + (nodePosition.width * ViewModel.SidePercentage);
                pos.y  = nodePosition.y + nodePosition.height;
                pos.x -= (TextureWidth / 2f);
                //pos.y += TextureHeight;
            }
            else if (ViewModel.Side == ConnectorSide.Top)
            {
                pos.x  = nodePosition.x + (nodePosition.width * ViewModel.SidePercentage);
                pos.y  = nodePosition.y;
                pos.x -= (TextureWidth / 2f);
                pos.y -= TextureHeight;
            }


            //if (ViewModel.IsMouseOver)
            //{
            //    var mouseOverBounds = new Rect(bounds);
            //    ////mouseOverBounds.x -= mouseOverBounds.width*0.2f;
            //    //mouseOverBounds.y += mouseOverBounds.height * 0.125f;
            //    //mouseOverBounds.x += mouseOverBounds.width * 0.125f;
            //    mouseOverBounds.width = 20;
            //    mouseOverBounds.height = 20;
            //    bounds = mouseOverBounds;
            //}

            //if (ViewModelObject.IsMouseOver)
            //{
            //    EditorGUI.DrawRect(Bounds.Scale(scale), Color.black);
            //}
            //if (!ViewModel.HasConnections)
            //if (!ViewModel.ConnectorFor.IsMouseOver && !ViewModel.ConnectorFor.IsSelected && !ViewModel.IsMouseOver) return;
            if (!ViewModel.AlwaysVisible)
            {
                if (!ViewModel.ConnectorFor.IsMouseOver && !ViewModel.ConnectorFor.IsSelected && !ViewModel.IsMouseOver && !ViewModel.HasConnections)
                {
                    return;
                }
            }

            //if (ViewModel.HasConnections)
            //{
            //    platform.DrawImage(bounds, Texture, true);



            //}
            if (ViewModel.Direction == ConnectorDirection.Output && ViewModel.Side == ConnectorSide.Right)
            {
                Bounds = new Rect(pos.x, pos.y, TextureWidth, TextureHeight);

                //return;
            }
            else
            {
                Bounds = new Rect(pos.x, pos.y, TextureWidth, TextureHeight);
            }

            var padding = ViewModel.StyleSchema.Padding;

            Bounds = Bounds.Pad(padding.x, padding.y, padding.width, padding.height);

            var bounds = Bounds.Scale(scale);

            // if (ViewModel.IsMouseOver)
            //   {
            platform.DrawImage(bounds, Texture, true);
            //  platform.DrawImage(bounds, Texture, true);
            //  }

            //platform.DrawImage(bounds, Texture, true);


            if (ViewModel.Direction == ConnectorDirection.Output && !string.IsNullOrEmpty(ViewModel.OutputDesctiption))
            {
                platform.SetTooltipForRect(bounds, ViewModel.OutputDesctiption);
            }
            else if (!string.IsNullOrEmpty(ViewModel.InputDesctiption))
            {
                platform.SetTooltipForRect(bounds, ViewModel.InputDesctiption);
            }
            //if (InvertGraphEditor.Settings.ShowGraphDebug && ViewModel.IsMouseOver)
            //{
            //    GUI.Label(new Rect(Bounds.x + 20, Bounds.y - 10, 500, 50),

            //        this.ViewModel.DataObject.GetType().Name,
            //        EditorStyles.miniBoldLabel);
            //}
        }
コード例 #37
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();
            }
        }
コード例 #38
0
ファイル: HeaderDrawer.cs プロジェクト: NotYours180/ALLINONE
        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);
                //}
            }
        }
コード例 #39
0
        public override void Draw(IPlatformDrawer platform, float scale)
        {

            


        
            //var x = rect.x + 10;

            //foreach (var item in DiagramDrawer.DiagramViewModel.GraphData.GetFilterPath())
            //{
            //    var item1 = item;
            //    var size = drawer.CalculateSize(item.Name, CachedStyles.GraphTitleLabel);
            //    x += size.x + 10;
            //}
            // Make sure they've upgraded to the latest json format
#if UNITY_EDITOR
            if (UpgradeOldProject()) return;
#endif
            //// Draw the title box
            //GUI.Box(new Rect(0, 0f, DiagramSize.width, 30f), DiagramViewModel.Title , ElementDesignerStyles.DiagramTitle);

            if (DiagramViewModel.LastMouseEvent != null)
            {
                var handler = DiagramViewModel.LastMouseEvent.CurrentHandler;
                if (!(handler is DiagramDrawer))
                    handler.Draw(platform, scale);
            }
            // Draw all of our drawers

           
            foreach (var drawer in CachedChildren)
            {
                if (drawer.Dirty)
                {
                    drawer.Refresh((IPlatformDrawer)platform,drawer.Bounds.position,false);
                    drawer.Dirty = false;
                }
                drawer.Draw(platform, Scale);

            }
          //  platform.DrawLabel(new Rect(5f, 5f, 200f, 100f), DiagramViewModel.Title, CachedStyles.GraphTitleLabel);


            DrawErrors();
            DrawHelp();
        }
コード例 #40
0
ファイル: DiagramDrawer.cs プロジェクト: NotYours180/ALLINONE
        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;
            }
        }
コード例 #41
0
 public virtual void Draw(IPlatformDrawer platform, float scale)
 {
 }
コード例 #42
0
ファイル: DiagramDrawer.cs プロジェクト: NotYours180/ALLINONE
        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();
            }
        }
コード例 #43
0
ファイル: DesignerWindow.cs プロジェクト: DiazGames/oneGame
        private bool DrawDiagram(IPlatformDrawer drawer, Vector2 scrollPosition, float scale, Rect diagramRect)
        {
            var screen = new Vector2(Screen.width, Screen.height);


            if (DiagramDrawer == null)
            {
                if (Workspace != null)
                {
                    if (Workspace.CurrentGraph != null)
                    {
                        LoadDiagram(Workspace.CurrentGraph);
                    }
                }
            }

            if (DiagramDrawer != null && DiagramViewModel != null && InvertGraphEditor.Settings.UseGrid)
            {
                if (_cachedLines == null || _cachedScroll != scrollPosition || _cachedScreen != screen)
                {
                    var lines = new List <CachedLineItem>();

                    var softColor = InvertGraphEditor.Settings.GridLinesColor;
                    var hardColor = InvertGraphEditor.Settings.GridLinesColorSecondary;
                    var x         = -scrollPosition.x;

                    var every10 = 0;

                    while (x < DiagramRect.x + DiagramRect.width + scrollPosition.x)
                    {
                        var color = softColor;
                        if (every10 == 10)
                        {
                            color   = hardColor;
                            every10 = 0;
                        }
                        if (x > diagramRect.x)
                        {
                            lines.Add(new CachedLineItem()
                            {
                                Lines = new[] { new Vector3(x, diagramRect.y), new Vector3(x, diagramRect.x + diagramRect.height + scrollPosition.y + 85) },
                                Color = color
                            });
                        }

                        x += DiagramViewModel.Settings.SnapSize * scale;
                        every10++;
                    }
                    var y = -scrollPosition.y + 80;
                    every10 = 10;
                    while (y < DiagramRect.y + DiagramRect.height + scrollPosition.y)
                    {
                        var color = softColor;
                        if (every10 == 10)
                        {
                            color   = hardColor;
                            every10 = 0;
                        }
                        if (y > diagramRect.y)
                        {
                            lines.Add(new CachedLineItem()
                            {
                                Lines = new[] { new Vector3(diagramRect.x, y), new Vector3(diagramRect.x + diagramRect.width + scrollPosition.x, y) },
                                Color = color
                            });
                        }

                        y += DiagramViewModel.Settings.SnapSize * scale;
                        every10++;
                    }
                    _cachedLines  = lines.ToArray();
                    _cachedScreen = screen;
                    _cachedScroll = scrollPosition;
                }

                for (int i = 0; i < _cachedLines.Length; i++)
                {
                    Drawer.DrawLine(_cachedLines[i].Lines, _cachedLines[i].Color);
                }
            }
            if (DiagramDrawer != null)
            {
                InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.BeforeDrawGraph(diagramRect));
                DiagramDrawer.Bounds = new Rect(0f, 0f, diagramRect.width, diagramRect.height);

                DiagramDrawer.Draw(drawer, 1f);

                if (_shouldProcessInputFromDiagram)
                {
                    InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.ProcessInput());
                }
                InvertApplication.SignalEvent <IDesignerWindowEvents>(_ => _.AfterDrawGraph(DiagramDrawer.Bounds));
            }
            return(false);
        }
コード例 #44
0
    public void DrawInspector(IPlatformDrawer platformDrawer)
    {
#if UNITY_EDITOR
#endif
    }
コード例 #45
0
 public void Draw(IPlatformDrawer platform, float scale)
 {
     Refresh(PlatformDrawer,new Vector2(0,0));
     DrawChildren();
 }
コード例 #46
0
        //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);
                }
            }
        }
コード例 #47
0
        public void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {
            foreach (var child in Children)
            {
                child.Refresh(platform, new Vector2(10, 0), hardRefresh);
            }

            foreach (var child in Children)
            {
                child.OnLayout();
            }
        }
コード例 #48
0
 public override void Draw(IPlatformDrawer platform, float scale)
 {
     base.Draw(platform, scale);
     platform.DrawLabel(new Rect(0, 0, 100, 100), ViewModel.Message, CachedStyles.GraphTitleLabel, DrawingAlignment.MiddleCenter);
 }
コード例 #49
0
 public void Refresh(IPlatformDrawer platform)
 {
 }
コード例 #50
0
ファイル: Drawer.cs プロジェクト: InvertGames/uFrame.Editor
        public virtual void Refresh(IPlatformDrawer platform, Vector2 position, bool hardRefresh = true)
        {

        }
コード例 #51
0
        private bool DrawDiagram(IPlatformDrawer drawer, Vector2 scrollPosition, float scale, Rect diagramRect)
        {

            var screen = new Vector2(Screen.width, Screen.height);


            if (DiagramDrawer == null)
            {
                if (Workspace != null)
                {
                    if (Workspace.CurrentGraph != null)
                    {
                        LoadDiagram(Workspace.CurrentGraph);
                    }
                }
            }

            if (DiagramDrawer != null && DiagramViewModel != null && InvertGraphEditor.Settings.UseGrid)
            {
                if (_cachedLines == null || _cachedScroll != scrollPosition || _cachedScreen != screen)
                {

                    var lines = new List<CachedLineItem>();

                    var softColor = InvertGraphEditor.Settings.GridLinesColor;
                    var hardColor = InvertGraphEditor.Settings.GridLinesColorSecondary;
                    var x = -scrollPosition.x;

                    var every10 = 0;

                    while (x < DiagramRect.x + DiagramRect.width + scrollPosition.x)
                    {
                        var color = softColor;
                        if (every10 == 10)
                        {
                            color = hardColor;
                            every10 = 0;
                        }
                        if (x > diagramRect.x)
                        {
                            lines.Add(new CachedLineItem()
                            {
                                Lines = new[] { new Vector3(x, diagramRect.y), new Vector3(x, diagramRect.x + diagramRect.height + scrollPosition.y + 85) },
                                Color = color
                            });
                        }

                        x += DiagramViewModel.Settings.SnapSize * scale;
                        every10++;
                    }
                    var y = -scrollPosition.y + 80;
                    every10 = 10;
                    while (y < DiagramRect.y + DiagramRect.height + scrollPosition.y)
                    {
                        var color = softColor;
                        if (every10 == 10)
                        {
                            color = hardColor;
                            every10 = 0;
                        }
                        if (y > diagramRect.y)
                        {

                            lines.Add(new CachedLineItem()
                            {
                                Lines = new[] { new Vector3(diagramRect.x, y), new Vector3(diagramRect.x + diagramRect.width + scrollPosition.x, y) },
                                Color = color
                            });
                        }

                        y += DiagramViewModel.Settings.SnapSize * scale;
                        every10++;
                    }
                    _cachedLines = lines.ToArray();
                    _cachedScreen = screen;
                    _cachedScroll = scrollPosition;
                }

                for (int i = 0; i < _cachedLines.Length; i++)
                {
                    Drawer.DrawLine(_cachedLines[i].Lines, _cachedLines[i].Color);
                }

            }
            if (DiagramDrawer != null)
            {
                InvertApplication.SignalEvent<IDesignerWindowEvents>(_ => _.BeforeDrawGraph(diagramRect));
                DiagramDrawer.Bounds = new Rect(0f, 0f, diagramRect.width, diagramRect.height);

                DiagramDrawer.Draw(drawer, 1f);

                if (_shouldProcessInputFromDiagram) InvertApplication.SignalEvent<IDesignerWindowEvents>(_ => _.ProcessInput());
                InvertApplication.SignalEvent<IDesignerWindowEvents>(_ => _.AfterDrawGraph(DiagramDrawer.Bounds));
            }
            return false;
        }
コード例 #52
0
        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);
        }