Beispiel #1
0
        protected override VisualGroup CreateVisual(IRenderContext context, ILabel label)
        {
            var labelLayout = label.GetLayout();
            // create container
            var container = new VisualGroup();
            // create wrapped visual
            var wrappedVisual = wrapped.Renderer.GetVisualCreator(label, wrapped).CreateVisual(context);
            // create visual decorators
            VisualGroup innerContainer = new VisualGroup();
            var         decorator1     = new LineVisual(0, 0, labelLayout.Width, 0)
            {
                Pen = new Pen(new SolidBrush(Color.FromArgb(0xFF, 0x24, 0x9A, 0xE7)), 2)
            };
            var decorator2 = new LineVisual(0, labelLayout.Height, labelLayout.Width, labelLayout.Height)
            {
                Pen = new Pen(new SolidBrush(Color.FromArgb(0xFF, 0x24, 0x9A, 0xE7)), 2)
            };

            innerContainer.Add(decorator1);
            innerContainer.Add(decorator2);
            // arrange inner container - this is a ready-to-use utility method to apply the correct tranformation
            innerContainer.Transform = GetTransform(context, labelLayout, false);
            // add visuals to container
            container.Add(wrappedVisual);
            container.Add(innerContainer);

            return(container);
        }
Beispiel #2
0
        public override void OnSceneViewGUI(SceneView sceneView)
        {
            var lineVisualRadius   = 0.005f;
            var sphereVisualRadius = 1.5f * lineVisualRadius;
            var renderOnSceneView  = !ConfigurationToolActive() &&
                                     Line.Valid && (
                !EditorApplication.isPlaying ||
                EditorApplication.isPaused);
            var startEnabled = renderOnSceneView && GetFrameToggleEnable(StartFrameNameId);
            var endEnabled   = renderOnSceneView && GetFrameToggleEnable(EndFrameNameId);

            LineVisual.Visible = renderOnSceneView && Mode == ToolMode.Line;
            if (LineVisual.Visible)
            {
                LineVisual.SetTransformEx(Line.Start.Position,
                                          Line.End.Position,
                                          lineVisualRadius,
                                          RenderAsArrow);
            }

            ArrowVisual.Visible = renderOnSceneView && Mode == ToolMode.Direction;
            if (ArrowVisual.Visible)
            {
                ArrowVisual.SetTransform(Line.Start.Position,
                                         Line.End.Position - Mathf.Min(Line.Length, DirectionArrowLength) * Line.Direction,
                                         lineVisualRadius);
            }

            StartVisual.Visible = startEnabled;
            if (StartVisual.Visible)
            {
                StartVisual.SetTransform(Line.Start.Position,
                                         Quaternion.identity,
                                         sphereVisualRadius,
                                         false);
            }

            EndVisual.Visible = endEnabled;
            if (EndVisual.Visible)
            {
                EndVisual.SetTransform(Line.End.Position,
                                       Quaternion.identity,
                                       sphereVisualRadius,
                                       false);
            }

            if (StartFrameTool != null)
            {
                StartFrameTool.TransformHandleActive = startEnabled;
            }
            if (EndFrameTool != null)
            {
                EndFrameTool.TransformHandleActive = endEnabled;
            }

            Synchronize();
        }
Beispiel #3
0
    // Start is called before the first frame update
    void Start()
    {
        lv  = GetComponentInChildren <LineVisual>();
        avc = GetComponentInChildren <AtomVisualController>();
        lrs = GetComponentsInChildren <LineRenderer>().ToList();
        gm  = GameManager.GetGM();
        mc  = MenuController.GetMC();

        player       = gm.player.gameObject;
        playerScript = gm.player;
    }
Beispiel #4
0
        protected override VisualGroup UpdateVisual(IRenderContext context, VisualGroup group, INode node1)
        {
            if (group == null || group.Children.Count != 6 + buttons.Count)
            {
                return(CreateVisual(context, node1));
            }
            group.Transform = new Matrix(1, 0, 0, 1, (float)node1.Layout.X, (float)node1.Layout.Y);
            var data = (LayerConstraintsInfo)node1.Tag;

            node.Tag = data;

            var x     = (float)insets.Left;
            var y     = (float)insets.Top;
            var width = (float)(node.Layout.Width - insets.HorizontalInsets - ButtonSize);
            //var height = (float)(font.GetHeight(graphics) + insets.VerticalInsets);
            var height = ButtonSize * 2;

            // update background
            group.Children[0] = DecoratedStyle.Renderer.GetVisualCreator(node, DecoratedStyle).UpdateVisual(context, group.Children[0]);

            // update labels
            if (data.Constraints)
            {
                if (group.Children[1] == null)
                {
                    var rectangle = new RectangleVisual(x, y, width, height)
                    {
                        Brush = GetBackgroundBrush(data)
                    };
                    group.Children[1] = rectangle;
                    string s        = data.ToString();
                    Brush  brush    = GetForegroundBrush(data);
                    IPoint location = new PointD(x + insets.Left, y + insets.Top);
                    group.Children[2] = new TextVisual {
                        Text = s, Font = font, Brush = brush, Location = location
                    };
                }
                else
                {
                    ((ShapeVisual)group.Children[1]).Brush = GetBackgroundBrush(data);
                    var textPaintable = (TextVisual)group.Children[2];
                    textPaintable.Brush = GetForegroundBrush(data);
                    textPaintable.Text  = data.ToString();
                }
            }
            else
            {
                if (group.Children[1] != null)
                {
                    group.Children[1] = VoidVisualCreator.Instance.CreateVisual(context);
                    group.Children[2] = VoidVisualCreator.Instance.CreateVisual(context);
                }
            }

            // paint buttons
            toggleStateStyle.Icon            = data.Constraints ? ButtonLabelStyle.ButtonIcon.Toggle : ButtonLabelStyle.ButtonIcon.None;
            toggleStateStyle.BackgroundColor = data.Constraints ? Color.Green : Color.Gray;
            int childIndex = 3;

            foreach (var button in buttons)
            {
                ILabel oldLabel = button.Visualization;
                var    icon     = ((ButtonLabelStyle)button.Visualization.Style).Icon;
                if (data.Constraints || icon == ButtonLabelStyle.ButtonIcon.Toggle || icon == ButtonLabelStyle.ButtonIcon.None)
                {
                    SimpleLabel label = new SimpleLabel(node, oldLabel.Text, oldLabel.LayoutParameter)
                    {
                        Style         = oldLabel.Style,
                        PreferredSize = oldLabel.PreferredSize
                    };
                    group.Children[childIndex] = label.Style.Renderer.GetVisualCreator(label, label.Style).UpdateVisual(context, group.Children[childIndex]);
                }
                else
                {
                    group.Children[childIndex] = VoidVisualCreator.Instance.CreateVisual(context);
                }
                childIndex++;
            }

            if (data.Constraints)
            {
                if (group.Children[childIndex] == null)
                {
                    double w         = width + ButtonSize;
                    var    rectangle = new RectangleVisual(x, y, w, height)
                    {
                        Pen = Pens.Black
                    };
                    group.Children[childIndex] = rectangle;
                    var line = new LineVisual(x + width, y, x + width, y + height)
                    {
                        Pen = Pens.Black
                    };
                    group.Children[childIndex + 1] = line;
                }
            }
            else
            {
                if (group.Children[childIndex] != null)
                {
                    group.Children[childIndex]     = VoidVisualCreator.Instance.CreateVisual(context);
                    group.Children[childIndex + 1] = VoidVisualCreator.Instance.CreateVisual(context);
                }
            }
            childIndex += 2;

            ((TextVisual)group.Children[childIndex]).Text = data.Constraints ? "Enabled" : "Disabled";
            return(group);
        }
Beispiel #5
0
        protected override VisualGroup CreateVisual(IRenderContext context, INode node1)
        {
            var group = new VisualGroup();

            group.Transform = new Matrix(1, 0, 0, 1, (float)node1.Layout.X, (float)node1.Layout.Y);
            var data = (LayerConstraintsInfo)node1.Tag;

            node.Layout = new RectD(PointD.Origin, node1.Layout.GetSize());
            node.Tag    = data;

            var x     = (float)insets.Left;
            var y     = (float)insets.Top;
            var width = (float)(node.Layout.Width - insets.HorizontalInsets - ButtonSize);
            //var height = (float)(font.GetHeight(graphics) + insets.VerticalInsets);
            var height = ButtonSize * 2;

            // add background
            group.Add(DecoratedStyle.Renderer.GetVisualCreator(node, DecoratedStyle).CreateVisual(context));

            // paint label
            if (data.Constraints)
            {
                var rectangle = new RectangleVisual(x, y, width, height)
                {
                    Brush = GetBackgroundBrush(data)
                };
                group.Add(rectangle);
                group.Add(new TextVisual {
                    Text     = data.ToString(),
                    Font     = font,
                    Brush    = GetForegroundBrush(data),
                    Location = new PointD(x + insets.Left, y + insets.Top)
                });
            }
            else
            {
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
            }

            // paint buttons
            toggleStateStyle.Icon            = data.Constraints ? ButtonLabelStyle.ButtonIcon.Toggle : ButtonLabelStyle.ButtonIcon.None;
            toggleStateStyle.BackgroundColor = data.Constraints ? Color.Green : Color.Gray;
            foreach (var button in buttons)
            {
                ILabel buttonLabel = button.Visualization;
                var    icon        = ((ButtonLabelStyle)buttonLabel.Style).Icon;
                if (data.Constraints || icon == ButtonLabelStyle.ButtonIcon.Toggle || icon == ButtonLabelStyle.ButtonIcon.None)
                {
                    SimpleLabel label = new SimpleLabel(node, buttonLabel.Text, buttonLabel.LayoutParameter)
                    {
                        Style         = buttonLabel.Style,
                        PreferredSize = buttonLabel.PreferredSize
                    };
                    group.Add(label.Style.Renderer.GetVisualCreator(label, label.Style).CreateVisual(context));
                }
                else
                {
                    group.Add(VoidVisualCreator.Instance.CreateVisual(context));
                }
            }

            if (data.Constraints)
            {
                double w         = width + ButtonSize;
                var    rectangle = new RectangleVisual(x, y, w, height)
                {
                    Pen = Pens.Black
                };
                group.Add(rectangle);
                var line = new LineVisual(x + width, y, x + width, y + height)
                {
                    Pen = Pens.Black
                };
                group.Add(line);
            }
            else
            {
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
                group.Add(VoidVisualCreator.Instance.CreateVisual(context));
            }

            group.Add(new TextVisual {
                Text     = data.Constraints ? "Enabled" : "Disabled",
                Font     = labelFont,
                Brush    = Brushes.Black,
                Location = new PointD(x + ButtonSize + 1, y + (float)node.Layout.Height + 1 - (float)insets.Bottom - font.Height - ButtonSize * 0.2f)
            });
            return(group);
        }