diff --git a/Blish HUD/Controls/Panel.cs b/Blish HUD/Controls/Panel.cs index cdb3d4eef..2468ee583 100644 --- a/Blish HUD/Controls/Panel.cs +++ b/Blish HUD/Controls/Panel.cs @@ -1,10 +1,10 @@ -using System; -using System.ComponentModel; -using Blish_HUD.Content; +using Blish_HUD.Content; using Blish_HUD.Input; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; +using System; +using System.ComponentModel; namespace Blish_HUD.Controls { @@ -57,6 +57,12 @@ public string Title { set => SetProperty(ref _title, value, true); } + protected AsyncTexture2D _icon; + public AsyncTexture2D Icon { + get => _icon; + set => SetProperty(ref _icon, value); + } + protected AsyncTexture2D _backgroundTexture; /// @@ -202,6 +208,7 @@ private void UpdateContentRegionBounds(object sender, EventArgs e) { } private Rectangle _layoutHeaderBounds; + private Rectangle _layoutHeaderIconBounds; private Rectangle _layoutHeaderTextBounds; private Vector2 _layoutAccordionArrowOrigin; @@ -248,7 +255,18 @@ public override void RecalculateLayout() { _size.Y - topOffset - bottomOffset); _layoutHeaderBounds = new Rectangle(this.ContentRegion.Left, 0, this.ContentRegion.Width, HEADER_HEIGHT); - _layoutHeaderTextBounds = new Rectangle(_layoutHeaderBounds.Left + 10, 0, _layoutHeaderBounds.Width - 10, HEADER_HEIGHT); + + if (_icon?.HasTexture != null) { + + _layoutHeaderIconBounds = new Rectangle(_layoutHeaderBounds.Left + 3, 3, HEADER_HEIGHT - 6, HEADER_HEIGHT - 6); + _layoutHeaderTextBounds = new Rectangle(_layoutHeaderIconBounds.Right + 5, 0, _layoutHeaderBounds.Width - _layoutHeaderIconBounds.Width, HEADER_HEIGHT); + + } else { + + _layoutHeaderIconBounds = Rectangle.Empty; + _layoutHeaderTextBounds = new Rectangle(_layoutHeaderBounds.Left + 10, 0, _layoutHeaderBounds.Width - 10, HEADER_HEIGHT); + + } _layoutAccordionArrowOrigin = new Vector2((float)ARROW_SIZE / 2, (float)ARROW_SIZE / 2); _layoutAccordionArrowBounds = new Rectangle(_layoutHeaderBounds.Right - ARROW_SIZE, @@ -333,6 +351,11 @@ public override void PaintBeforeChildren(SpriteBatch spriteBatch, Rectangle boun _layoutHeaderBounds); } + // Panel header icon + if (_icon?.HasTexture != null) { + spriteBatch.DrawOnCtrl(this, _icon, _layoutHeaderIconBounds, Color.White); + } + // Panel header text spriteBatch.DrawStringOnCtrl(this, _title,