Пример #1
0
        public VisualisedDrawable(Drawable d, TreeContainer tree)
        {
            this.tree = tree;
            Target    = d;

            attachEvents();

            var sprite = Target as Sprite;

            AutoSizeAxes = Axes.Both;
            Add(new[]
            {
                activityInvalidate = new Box
                {
                    Colour   = Color4.Yellow,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(6, 0),
                    Alpha    = 0
                },
                activityLayout = new Box
                {
                    Colour   = Color4.Orange,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(3, 0),
                    Alpha    = 0
                },
                activityAutosize = new Box
                {
                    Colour   = Color4.Red,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(0, 0),
                    Alpha    = 0
                },
                previewBox = sprite?.Texture == null ? previewBox = new Box {
                    Colour = Color4.White
                } : new Sprite
                {
                    Texture = sprite.Texture,
                    Scale   = new Vector2(sprite.Texture.DisplayWidth / sprite.Texture.DisplayHeight, 1),
                },
                text = new SpriteText
                {
                    Position = new Vector2(24, -3),
                    Scale    = new Vector2(0.9f),
                },
                Flow = new FillFlowContainer
                {
                    Direction    = FillDirection.Down,
                    AutoSizeAxes = Axes.Both,
                    Position     = new Vector2(10, 14)
                },
            });

            previewBox.Position = new Vector2(9, 0);
            previewBox.Size     = new Vector2(line_height, line_height);

            updateSpecifics();
        }
Пример #2
0
 public DrawVisualiser()
 {
     RelativeSizeAxes = Axes.Both;
     Children         = new Drawable[]
     {
         treeContainer = new TreeContainer
         {
             Depth         = float.MaxValue,
             ChooseTarget  = chooseTarget,
             GoUpOneParent = delegate { Target = Target?.Parent ?? Target; }
         },
         new CursorContainer()
     };
 }
Пример #3
0
 public DrawVisualiser()
 {
     RelativeSizeAxes = Axes.Both;
     Children         = new Drawable[]
     {
         overlay       = new InfoOverlay(),
         treeContainer = new TreeContainer
         {
             Depth         = float.MinValue,
             ChooseTarget  = chooseTarget,
             GoUpOneParent = delegate
             {
                 var parent = Target?.Parent;
                 if (parent?.Parent != null)
                 {
                     Target = Target?.Parent;
                 }
             }
         },
         new CursorContainer()
     };
 }
Пример #4
0
        public DrawVisualiser()
        {
            RelativeSizeAxes = Axes.Both;
            Children         = new Drawable[]
            {
                overlay       = new InfoOverlay(),
                treeContainer = new TreeContainer
                {
                    ChooseTarget  = chooseTarget,
                    GoUpOneParent = delegate
                    {
                        Drawable lastHighlight = highlightedTarget?.Target;

                        var parent = Target?.Parent;
                        if (parent?.Parent != null)
                        {
                            Target = Target?.Parent;
                        }

                        // Rehighlight the last highlight
                        if (lastHighlight != null)
                        {
                            VisualisedDrawable visualised = findVisualised(lastHighlight, targetDrawable);
                            if (visualised != null)
                            {
                                propertyDisplay.State = Visibility.Visible;
                                setHighlight(visualised);
                            }
                        }
                    },
                    ToggleProperties = delegate
                    {
                        if (targetDrawable == null)
                        {
                            return;
                        }

                        propertyDisplay.ToggleVisibility();

                        if (propertyDisplay.State == Visibility.Visible)
                        {
                            setHighlight(targetDrawable);
                        }
                    },
                },
                new CursorContainer()
            };

            propertyDisplay = treeContainer.PropertyDisplay;

            propertyDisplay.StateChanged += (display, visibility) =>
            {
                switch (visibility)
                {
                case Visibility.Hidden:
                    // Dehighlight everything automatically if property display is closed
                    setHighlight(null);
                    break;
                }
            };
        }
Пример #5
0
        public VisualisedDrawable(Drawable d, TreeContainer tree)
        {
            this.tree = tree;

            Target = d;

            attachEvents();

            var sprite = Target as Sprite;

            RelativeSizeAxes = Axes.X;
            AutoSizeAxes     = Axes.Y;
            AddRange(new[]
            {
                activityInvalidate = new Box
                {
                    Colour   = Color4.Yellow,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(6, 0),
                    Alpha    = 0
                },
                activityLayout = new Box
                {
                    Colour   = Color4.Orange,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(3, 0),
                    Alpha    = 0
                },
                activityAutosize = new Box
                {
                    Colour   = Color4.Red,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(0, 0),
                    Alpha    = 0
                },
                previewBox       = sprite?.Texture == null
                    ? previewBox = new Box {
                    Colour = Color4.White
                }
                    : new Sprite
                {
                    Texture = sprite.Texture,
                    Scale   = new Vector2(sprite.Texture.DisplayWidth / sprite.Texture.DisplayHeight, 1),
                },
                new Container
                {
                    AutoSizeAxes = Axes.Both,
                    Position     = new Vector2(24, -3),
                    Children     = new Drawable[]
                    {
                        background = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(1, 0.8f),
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            Colour           = Color4.Transparent,
                        },
                        highlightBackground = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(1, 0.8f),
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            Colour           = Color4.Khaki.Opacity(0.4f),
                            Alpha            = 0
                        },
                        text = new SpriteText()
                    }
                },
                flow = new FillFlowContainer <VisualisedDrawable>
                {
                    Direction        = FillDirection.Vertical,
                    RelativeSizeAxes = Axes.X,
                    AutoSizeAxes     = Axes.Y,
                    Position         = new Vector2(10, 14)
                },
            });

            previewBox.Position = new Vector2(9, 0);
            previewBox.Size     = new Vector2(line_height, line_height);

            var compositeTarget = Target as CompositeDrawable;

            compositeTarget?.AliveInternalChildren.ForEach(addChild);

            updateSpecifics();
        }
Пример #6
0
        public VisualisedDrawable(VisualisedDrawable parent, Drawable d, TreeContainer tree)
        {
            this.tree = tree;

            nestingDepth = (parent?.nestingDepth ?? 0) + 1;
            Target       = d;

            attachEvents();

            var sprite = Target as Sprite;

            AutoSizeAxes = Axes.Both;
            Add(new[]
            {
                activityInvalidate = new Box
                {
                    Colour   = Color4.Yellow,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(6, 0),
                    Alpha    = 0
                },
                activityLayout = new Box
                {
                    Colour   = Color4.Orange,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(3, 0),
                    Alpha    = 0
                },
                activityAutosize = new Box
                {
                    Colour   = Color4.Red,
                    Size     = new Vector2(2, line_height),
                    Position = new Vector2(0, 0),
                    Alpha    = 0
                },
                previewBox       = sprite?.Texture == null
                    ? previewBox = new Box {
                    Colour = Color4.White
                }
                    : new Sprite
                {
                    Texture = sprite.Texture,
                    Scale   = new Vector2(sprite.Texture.DisplayWidth / sprite.Texture.DisplayHeight, 1),
                },
                new Container
                {
                    AutoSizeAxes = Axes.Both,
                    Position     = new Vector2(24, -3),
                    Children     = new Drawable[]
                    {
                        textBg = new Box
                        {
                            RelativeSizeAxes = Axes.Both,
                            Size             = new Vector2(1, 0.8f),
                            Anchor           = Anchor.CentreLeft,
                            Origin           = Anchor.CentreLeft,
                            Colour           = Color4.Transparent,
                        },
                        text = new SpriteText
                        {
                            Scale = new Vector2(0.9f),
                        },
                    }
                },
                Flow = new FillFlowContainer <VisualisedDrawable>
                {
                    Direction    = FillDirection.Vertical,
                    AutoSizeAxes = Axes.Both,
                    Position     = new Vector2(10, 14)
                },
            });

            previewBox.Position = new Vector2(9, 0);
            previewBox.Size     = new Vector2(line_height, line_height);

            updateSpecifics();
        }
Пример #7
0
        public DrawVisualiser()
        {
            RelativeSizeAxes = Axes.Both;
            Children         = new Drawable[]
            {
                overlay       = new InfoOverlay(),
                treeContainer = new TreeContainer
                {
                    State        = { BindTarget = State },
                    ChooseTarget = () =>
                    {
                        Searching = true;
                        Target    = null;
                    },
                    GoUpOneParent = delegate
                    {
                        Drawable lastHighlight = highlightedTarget?.Target;

                        var parent = Target?.Parent;

                        if (parent != null)
                        {
                            var lastVisualiser = targetVisualiser;

                            Target = parent;
                            lastVisualiser.SetContainer(targetVisualiser);

                            targetVisualiser.Expand();
                        }

                        // Rehighlight the last highlight
                        if (lastHighlight != null)
                        {
                            VisualisedDrawable visualised = targetVisualiser.FindVisualisedDrawable(lastHighlight);

                            if (visualised != null)
                            {
                                propertyDisplay.Show();
                                setHighlight(visualised);
                            }
                        }
                    },
                    ToggleProperties = delegate
                    {
                        if (targetVisualiser == null)
                        {
                            return;
                        }

                        propertyDisplay.ToggleVisibility();

                        if (propertyDisplay.State.Value == Visibility.Visible)
                        {
                            setHighlight(targetVisualiser);
                        }
                    },
                },
                new CursorContainer()
            };

            propertyDisplay = treeContainer.PropertyDisplay;

            propertyDisplay.State.ValueChanged += v =>
            {
                switch (v.NewValue)
                {
                case Visibility.Hidden:
                    // Dehighlight everything automatically if property display is closed
                    setHighlight(null);
                    break;
                }
            };
        }