internal override void Layout() { // Pixel size of panel to contain child widgets var outerArea = BuildContainerRenderArea(); RenderRule.BuildBars(outerArea); foreach (var widget in Children) { widget.AbsoluteArea = new Rectangle( widget.Area.X + AbsoluteInputArea.X - (int)(RenderRule.Horizontal.ChildOffset), widget.Area.Y + AbsoluteInputArea.Y - (int)(RenderRule.Vertical.ChildOffset), widget.Area.Width, widget.Area.Height); widget.SissorArea = AbsoluteInputArea; if (Parent != null) { widget.SissorArea = Rectangle.Intersect(widget.SissorArea, SissorArea); } } base.Layout(); }
public void Draw(GameTime time, Matrix parent, Rectangle scissor) { Matrix transform = this.Transform * parent; Rectangle newScissor = scissor; if (this.EnableScissor) newScissor = scissor.Intersect(RectangleExtensions.Create(Vector2.Transform(Vector2.Zero, transform), Vector2.Transform(this.Size, transform))); if (newScissor.Width > 0 && newScissor.Height > 0) { if (this.EnableScissor) { this.renderer.Batch.End(); this.renderer.Batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, this.renderer.RasterizerState, null, Matrix.Identity); this.main.GraphicsDevice.ScissorRectangle = newScissor; } this.draw(time, parent, transform); foreach (UIComponent child in this.Children) { if (child.Visible) { if (this.main.GraphicsDevice.ScissorRectangle != newScissor || child.requiresNewBatch) { this.renderer.Batch.End(); this.renderer.Batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, this.renderer.RasterizerState, null, Matrix.Identity); this.main.GraphicsDevice.ScissorRectangle = newScissor; } child.Draw(time, transform, newScissor); } } } if (this.EnableScissor) { // Restore original scissor this.renderer.Batch.End(); this.renderer.Batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, this.renderer.RasterizerState, null, Matrix.Identity); this.main.GraphicsDevice.ScissorRectangle = scissor; } }