DrawContext.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //-----------------------------------------------------------------------------
  2. // DrawContext.cs
  3. //
  4. // Microsoft XNA Community Game Platform
  5. // Copyright (C) Microsoft Corporation. All rights reserved.
  6. //-----------------------------------------------------------------------------
  7. using Microsoft.Xna.Framework;
  8. using Microsoft.Xna.Framework.Graphics;
  9. namespace UserInterfaceSample.Controls
  10. {
  11. /// <summary>
  12. /// DrawContext is a collection of rendering data to pass into Control.Draw().
  13. /// By passing this data into each Draw call, we controls can access necessary
  14. /// data when they need it, without introducing dependencies on top-level object
  15. /// like ScreenManager.
  16. /// </summary>
  17. public struct DrawContext
  18. {
  19. /// <summary>
  20. /// The XNA GraphicsDevice
  21. /// </summary>
  22. public GraphicsDevice Device;
  23. /// <summary>
  24. /// GameTime passed into Game.Draw()
  25. /// </summary>
  26. public GameTime GameTime;
  27. /// <summary>
  28. /// Shared SpriteBatch for use by any control that wants to draw with it.
  29. /// Begin() is called on this batch before drawing controls, and End() is
  30. /// called after drawing controls, so that multiple controls can have
  31. /// their rendering batched together.
  32. /// </summary>
  33. public SpriteBatch SpriteBatch;
  34. /// <summary>
  35. /// A single-pixel white texture, useful for drawing boxes and lines within a SpriteBatch.
  36. /// </summary>
  37. public Texture2D BlankTexture;
  38. /// <summary>
  39. /// Positional offset to draw at. Note that this is a simple positional offset rather
  40. /// than a full transform, so this API doesn't easily support full heirarchical transforms.
  41. ///
  42. /// A control's position will already be added to this vector when Control.Draw() is called.
  43. /// </summary>
  44. public Vector2 DrawOffset;
  45. }
  46. }