Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
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);
                }
            }
        }
Exemplo n.º 3
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);
                }
            }
        }
 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);
     }
 }
Exemplo n.º 5
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);
     }
 }
Exemplo n.º 6
0
 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);
     }
 }
Exemplo n.º 7
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);
     }
 }
Exemplo n.º 8
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);
         }
     }
 }
Exemplo n.º 9
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);
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 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);
 }
Exemplo n.º 12
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
 }
Exemplo n.º 13
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Child?.Render(context, skinLayout, skinDelegator, AbsoluteRectangle);
 }
Exemplo n.º 14
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
 }
Exemplo n.º 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));
 }
Exemplo n.º 16
0
 public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     _child?.Render(context, skinLayout, skinDelegator, layout);
 }
Exemplo n.º 17
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Child?.Render(context, skinLayout, skinDelegator, AbsoluteRectangle);
 }
Exemplo n.º 18
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));
 }
Exemplo n.º 19
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     foreach (var kv in GetChildrenWithLayouts(skinLayout, layout))
     {
         var old = kv.Item.Text;
         kv.Item.Text = kv.Name;
         if (kv.Layout != null)
         {
             kv.Item.Render(context, skinLayout, skinDelegator, kv.Layout.Value);
         }
         kv.Item.Text = old;
     }
 }
Exemplo n.º 20
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));
 }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
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);
        }