Пример #1
0
 public CanvasEntity(ISkinLayout skinLayout, ISkinDelegator skinDelegator)
 {
     _skinLayout = skinLayout;
     _skinDelegator = skinDelegator;
     CanvasesEnabled = true;
     Windows = new List<Window>();
 }
        public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
        {
            var layoutWidth = layout.Width - skinLayout.HorizontalScrollBarHeight;
            var layoutHeight = layout.Height - skinLayout.VerticalScrollBarWidth;

            int childWidth, childHeight;
            if (!(_child is IHasDesiredSize))
            {
                childWidth = layoutWidth;
                childHeight = layoutHeight;
            }
            else
            {
                var hasDesiredSize = (IHasDesiredSize) _child;
                childWidth = hasDesiredSize.GetDesiredWidth(skinLayout) ?? layoutWidth;
                childHeight = hasDesiredSize.GetDesiredHeight(skinLayout) ?? layoutHeight;
                if (childWidth < layoutWidth)
                {
                    childWidth = layoutWidth;
                }
                if (childHeight < layoutHeight)
                {
                    childHeight = layoutHeight;
                }
            }

            if (_renderTarget == null || _renderTarget.Width != childWidth ||
                _renderTarget.Height != childHeight)
            {
                _renderTarget?.Dispose();

                _renderTarget = new RenderTarget2D(
                    context.GraphicsDevice,
                    Math.Max(1, childWidth),
                    Math.Max(1, childHeight));
            }
            
            context.SpriteBatch.End();
            context.PushRenderTarget(_renderTarget);
            context.GraphicsDevice.Clear(Color.Transparent);
            context.SpriteBatch.Begin();

            try
            {
                _child?.Render(
                    context,
                    skinLayout,
                    skinDelegator,
                    new Rectangle(0, 0, childWidth, childHeight));
            }
            finally
            {
                context.SpriteBatch.End();
                context.PopRenderTarget();
                context.SpriteBatch.Begin();
            }

            skinDelegator.Render(context, layout, this);
        }
Пример #3
0
 public override void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     foreach (var kv in GetChildLocations(skinLayout, layout))
     {
         kv.Key.Render(context, skinLayout, skinDelegator, kv.Value);
     }
 }
 public override void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     foreach (var kv in this.ChildrenWithLayouts(layout).OrderByDescending(x => x.Key.Order))
     {
         kv.Key.Render(context, skinLayout, skinDelegator, kv.Value);
     }
 }
Пример #5
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     foreach (var kv in GetChildrenWithLayouts(skinLayout, layout))
     {
         if (kv.Layout != null)
         {
             kv.Item.Render(context, skinLayout, skinDelegator, kv.Layout.Value);
         }
     }
 }
Пример #6
0
        public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
        {
            skinDelegator.Render(context, layout, this);
            foreach (var kv in LabelsWithLayouts(layout))
            {
                kv.Key.Render(context, skinLayout, skinDelegator, kv.Value);
            }

            foreach (var kv in ChildrenWithLayouts(layout))
            {
                kv.Key.Render(context, skinLayout, skinDelegator, kv.Value);
            }
        }
Пример #7
0
        public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
        {
            TextWidth = (int)Math.Ceiling(skinDelegator.MeasureText(context, Text, this).X);
            skinDelegator.Render(context, layout, this);

            var childrenLayout = GetMenuListLayout(skinLayout, layout);
            if (Active && childrenLayout != null)
            {
                IsRenderingMenuList = true;
                skinDelegator.Render(context, childrenLayout.Value, this);
                foreach (var kv in GetMenuChildren(skinLayout, layout))
                {
                    kv.Key.Render(context, skinLayout, skinDelegator, kv.Value);
                }
            }
        }
Пример #8
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Child?.Render(context, skinLayout, skinDelegator, AbsoluteRectangle);
 }
Пример #9
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
 }
Пример #10
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
 }
Пример #11
0
 public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     _child?.Render(context, skinLayout, skinDelegator, layout);
 }
Пример #12
0
 public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     _child?.Render(context, skinLayout, skinDelegator, layout);
 }
Пример #13
0
 public override void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Children[0]?.Render(context, skinLayout, skinDelegator, GetChildLayout(layout, skinLayout));
 }
Пример #14
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     _toggleButton.Render(context, skinLayout, skinDelegator, new Rectangle(layout.X, layout.Y, layout.Width, 24));
 }
Пример #15
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     _toggleButton.Render(context, skinLayout, skinDelegator, new Rectangle(layout.X, layout.Y, layout.Width, 24));
 }
Пример #16
0
 public abstract void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout);
Пример #17
0
 public abstract void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout);
Пример #18
0
        public override void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
        {
            if (_recentProjectsTask == null)
            {
                _recentProjectsTask = _coroutine.Run(() => _recentProjects.GetRecentProjects(context));
            }

            if (_recentProjectsTask.IsCompleted && !_hasAppliedRecentProjects)
            {
                foreach (var recentProject in _recentProjectsTask.Result)
                {
                    var horizontalContainer = new ClickableHorizontalContainer();
                    if (recentProject.Thumbnail != null)
                    {
                        var textureContainer = new RawTextureContainer(_renderUtilities);
                        textureContainer.Texture    = recentProject.Thumbnail;
                        textureContainer.TextureFit = "stretch";
                        horizontalContainer.AddChild(textureContainer, "60");
                    }
                    else
                    {
                        horizontalContainer.AddChild(new EmptyContainer(), "60");
                    }

                    var verticalContainer = new VerticalContainer();
                    verticalContainer.AddChild(new EmptyContainer(), "*");
                    verticalContainer.AddChild(new Label {
                        Text = recentProject.Name, HorizontalAlignment = HorizontalAlignment.Left
                    }, "16");
                    verticalContainer.AddChild(new EmptyContainer(), "*");
                    verticalContainer.AddChild(new Label {
                        Text = recentProject.Path, HorizontalAlignment = HorizontalAlignment.Left, TextColor = new Color(63, 63, 63, 255)
                    }, "16");
                    verticalContainer.AddChild(new EmptyContainer(), "*");

                    var button = new Button
                    {
                        Text = "Load",
                    };
                    button.Click += (sender, e) =>
                    {
                        _projectManager.LoadProject(recentProject.Path);
                    };
                    horizontalContainer.Click += (sender, e) =>
                    {
                        _projectManager.LoadProject(recentProject.Path);
                    };

                    horizontalContainer.AddChild(new EmptyContainer(), "16");
                    horizontalContainer.AddChild(verticalContainer, "*");
                    horizontalContainer.AddChild(new EmptyContainer(), "16");
                    horizontalContainer.AddChild(button, "60");

                    _recentProjectsContainer.AddChild(horizontalContainer, "60");
                    _recentProjectsContainer.AddChild(new EmptyContainer(), "10");
                }

                _hasAppliedRecentProjects = true;
            }

            base.Render(context, skinLayout, skinDelegator, layout);
        }
Пример #19
0
        public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
        {
            var constrainedLayoutWidth  = layout.Width - skinLayout.VerticalScrollBarWidth;
            var constrainedLayoutHeight = layout.Height - skinLayout.HorizontalScrollBarHeight;

            var realLayoutWidth  = layout.Width;
            var realLayoutHeight = layout.Height;

            NeedsVerticalScrollbar   = false;
            NeedsHorizontalScrollbar = false;

            int childWidth, childHeight;

            if (!(_child is IHasDesiredSize))
            {
                childWidth  = layout.Width;
                childHeight = layout.Height;
            }
            else
            {
                var hasDesiredSize = (IHasDesiredSize)_child;
                childWidth  = hasDesiredSize.GetDesiredWidth(skinLayout) ?? layout.Width;
                childHeight = hasDesiredSize.GetDesiredHeight(skinLayout) ?? layout.Height;
                if (childHeight > layout.Height)
                {
                    NeedsVerticalScrollbar = true;
                    realLayoutWidth        = constrainedLayoutWidth;

                    // Introducing a vertical scrollbar modifies the width, so update that.
                    childWidth = hasDesiredSize.GetDesiredWidth(skinLayout) ?? constrainedLayoutWidth;

                    if (childWidth > constrainedLayoutWidth)
                    {
                        NeedsHorizontalScrollbar = true;
                        realLayoutHeight         = constrainedLayoutHeight;
                    }
                }
                else if (childWidth > layout.Width)
                {
                    NeedsHorizontalScrollbar = true;
                    realLayoutHeight         = constrainedLayoutHeight;

                    // Introducing a horizontal scrollbar modifies the height, so update that.
                    childHeight = hasDesiredSize.GetDesiredHeight(skinLayout) ?? constrainedLayoutHeight;

                    if (childHeight > constrainedLayoutHeight)
                    {
                        NeedsVerticalScrollbar = true;
                        realLayoutWidth        = constrainedLayoutWidth;
                    }
                }

                if (childWidth < realLayoutWidth)
                {
                    childWidth = realLayoutWidth;
                }
                if (childHeight < realLayoutHeight)
                {
                    childHeight = realLayoutHeight;
                }
            }

            if (_renderTarget == null || _renderTarget.Width != realLayoutWidth ||
                _renderTarget.Height != realLayoutHeight)
            {
                _renderTarget?.Dispose();

                _renderTarget = new RenderTarget2D(
                    context.GraphicsDevice,
                    Math.Max(1, realLayoutWidth),
                    Math.Max(1, realLayoutHeight));
            }

            ChildWidth  = childWidth;
            ChildHeight = childHeight;

            context.SpriteBatch.End();
            context.PushRenderTarget(_renderTarget);
            context.GraphicsDevice.Clear(Color.Transparent);
            context.SpriteBatch.Begin();

            try
            {
                var scrollableChild = _child as IScrollableAwareChild;

                if (scrollableChild != null)
                {
                    scrollableChild.Render(
                        context,
                        skinLayout,
                        skinDelegator,
                        new Rectangle(
                            -(int)(ScrollX * (System.Math.Max(childWidth, realLayoutWidth) - realLayoutWidth)),
                            -(int)(ScrollY * (System.Math.Max(childHeight, realLayoutHeight) - realLayoutHeight)),
                            childWidth,
                            childHeight),
                        new Rectangle(
                            0,
                            0,
                            realLayoutWidth,
                            realLayoutHeight));
                }
                else
                {
                    _child?.Render(
                        context,
                        skinLayout,
                        skinDelegator,
                        new Rectangle(
                            -(int)(ScrollX * (System.Math.Max(childWidth, realLayoutWidth) - realLayoutWidth)),
                            -(int)(ScrollY * (System.Math.Max(childHeight, realLayoutHeight) - realLayoutHeight)),
                            childWidth,
                            childHeight));
                }
            }
            finally
            {
                context.SpriteBatch.End();
                context.PopRenderTarget();
                context.SpriteBatch.Begin();
            }

            skinDelegator.Render(context, layout, this);
        }
Пример #20
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Child?.Render(context, skinLayout, skinDelegator, AbsoluteRectangle);
 }