public void DrawBackground(IUserInterfaceRenderContext renderContext, RenderElementDisplay display, Rectangle clientDest) { if (display.Style.Background == null) { return; } // This draws the background behind the border - a problem for borders which have transparency on their outer edges // but important for borders which have transparency on their inner edges. Oh what to do... //Rectangle backgroundRect = new Rectangle( // new Point(dest.X - display.Region.BorderToContentOffset.Left, // dest.Y - display.Region.BorderToContentOffset.Top), // display.Region.BorderRect.Size); // Here we make a compromise and set the background rectangle to be slightly smaller than // the border rectangle var borderLayout = display.Style.Border.ToLayoutBox(); Rectangle backgroundRect = new Rectangle( clientDest.X - display.Region.BorderToContentOffset.Left + borderLayout.Left / 2, clientDest.Y - display.Region.BorderToContentOffset.Top + borderLayout.Top / 2, display.BorderRect.Width - borderLayout.Width / 2, display.BorderRect.Height - borderLayout.Height / 2); styleRenderer.DrawBackground( renderContext.SpriteBatch, display.Style.Background, backgroundRect); }
public void DrawBackground(IWidgetRenderContext renderContext, WidgetDisplay display, Point dest) { // This draws the background behind the border - a problem for borders which have transparency on their outer edges // but important for borders which have transparency on their inner edges. Oh what to do... //Rectangle backgroundRect = new Rectangle( // new Point(dest.X - display.Region.BorderToContentOffset.Left, // dest.Y - display.Region.BorderToContentOffset.Top), // display.Region.BorderRect.Size); // Here we make a compromise and set the background rectangle to be slightly smaller than // the border rectangle Rectangle backgroundRect = new Rectangle( dest.X - display.Region.BorderToContentOffset.Left + display.Region.Style.Border.Left.Width / 2, dest.Y - display.Region.BorderToContentOffset.Top + display.Region.Style.Border.Top.Width / 2, display.Region.BorderRect.Width - display.Region.Style.Border.Width / 2, display.Region.BorderRect.Height - display.Region.Style.Border.Height / 2); styleRenderer.DrawBackground( renderContext.SpriteBatch, display.Style.Background, backgroundRect); }