using Chernobyl.Collections.Generic.Event; using Chernobyl.Graphics.Drawing; using Chernobyl.Graphics.Texture; using Chernobyl.Mathematics.Geometry; using Chernobyl.Mathematics.Movement; namespace Chernobyl.Interface.Utility { /// /// A simple 2D menu interface that is used to give /// derived instances a background. Typically this is used to hold other menu /// items like buttons, labels, input boxes, etc. The background will expand /// to fit the shape you give it and will continue to expand and contract /// to ensure the shape fit inside it's borders (even if that shape /// expands, contracts, or moves). /// public class Background : Sprite { /// /// Initializes a new instance of the class. /// /// The service holder instance that takes /// services and gives them out. /// The texture to use as the background. /// The shape that will be on this /// . This class will create a /// to store the /// instances in (using a /// and of 25) . If the passed in /// is a then that /// collection will be used instead. public Background(IEventCollection services, ITexture texture, IShape shape) : base(services, texture) { Shapes = shape as ShapeCollection ?? new ShapeCollection(new[] { shape }) { WidthModifier = 25, HeightModifier = 25 }; Transform.MakeParentChild(Shapes, this.Render); } /// /// The start of the transform chain of this entity. If there is only /// one transform in the chain, then the TransformStart will equal the /// TransformEnd. /// protected override ITransform TransformStart { get { return Shapes; } } /// /// The that ensures this /// is properly adjusting to the size of the contained s. /// ShapeCollection Shapes { get; set; } } }