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);
        }
Exemple #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);
                }
            }
        }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
     }
 }
Exemple #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);
         }
     }
 }
Exemple #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);
            }
        }
Exemple #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);
            }
        }
 public virtual void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     _child?.Render(context, skinLayout, skinDelegator, layout);
 }
Exemple #12
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
 }
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Child?.Render(context, skinLayout, skinDelegator, AbsoluteRectangle);
 }
Exemple #14
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
 }
 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));
 }
Exemple #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);
 }
Exemple #17
0
 public void Render(IRenderContext context, ISkinLayout skinLayout, ISkinDelegator skinDelegator, Rectangle layout)
 {
     skinDelegator.Render(context, layout, this);
     Child?.Render(context, skinLayout, skinDelegator, AbsoluteRectangle);
 }
 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));
 }
Exemple #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;
     }
 }
Exemple #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));
 }
        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);
        }
Exemple #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);
        }