/// <summary> /// Creates a new ControlButton. /// </summary> /// <param name="id">The id of the ControlButton./param> /// <param name="owner">The owner of the ControlButton.</param> /// <param name="position">The position of the ControlButton.</param> /// <param name="padding">The amount of padding around the button.</param> public ControlButton(string id, MenuScreen owner, Vector2 position, Vector2 padding, bool flushRight) : base(id, owner, new Rectangle(), "Eon\\Textures\\Pixel") { textItem = new TextItem(id + "txt", 1, id, "GUI\\Verdana12pt", position + padding, Color.Black, true); Vector2 size = textItem.GetTextSize(); size += padding * 2; if (flushRight) { position.X -= size.X; position.Y += padding.Y; textItem.Position = position; Bounds = new Rectangle((int)(position.X - padding.X), (int)(position.Y - padding.Y), (int)size.X, (int)size.Y); } else { Bounds = new Rectangle( (int)position.X, (int)position.Y, (int)size.X, (int)size.Y); } }
protected override void Initialize() { textItem = new TextItem(ID + text, 1, text, fontFilepath, pos, notSelected, true); AttachComponent(textItem); Vector2 measure = textItem.GetTextSize(); Bounds = new Rectangle((int)pos.X, (int)pos.Y, (int)measure.X, (int)measure.Y); base.Initialize(); }