2019-08-10 13:44:48 +02:00
using Microsoft.Xna.Framework ;
2019-12-29 15:25:33 +01:00
using Microsoft.Xna.Framework.Graphics ;
2022-04-25 15:25:58 +02:00
using MLEM.Graphics ;
2019-08-10 13:44:48 +02:00
namespace MLEM.Ui.Elements {
2020-05-22 17:02:24 +02:00
/// <summary>
/// A group element to be used inside of a <see cref="UiSystem"/>.
/// A group is an element that has no rendering or interaction on its own, but that can aid with automatic placement of child elements.
/// </summary>
2019-08-10 13:44:48 +02:00
public class Group : Element {
2020-05-22 17:02:24 +02:00
/// <summary>
/// Creates a new group with the given settings
/// </summary>
/// <param name="anchor">The group's anchor</param>
/// <param name="size">The group's size</param>
2023-12-28 17:16:31 +01:00
/// <param name="setHeightBasedOnChildren">Whether the group's height should be based on its children's height, see <see cref="Element.SetHeightBasedOnChildren"/>.</param>
public Group ( Anchor anchor , Vector2 size , bool setHeightBasedOnChildren = true ) : this ( anchor , size , false , setHeightBasedOnChildren ) { }
/// <summary>
/// Creates a new group with the given settings
/// </summary>
/// <param name="anchor">The group's anchor</param>
/// <param name="size">The group's size</param>
/// <param name="setWidthBasedOnChildren">Whether the group's width should be based on its children's width, see <see cref="Element.SetWidthBasedOnChildren"/>.</param>
/// <param name="setHeightBasedOnChildren">Whether the group's height should be based on its children's height, see <see cref="Element.SetHeightBasedOnChildren"/>.</param>
public Group ( Anchor anchor , Vector2 size , bool setWidthBasedOnChildren , bool setHeightBasedOnChildren ) : base ( anchor , size ) {
this . SetWidthBasedOnChildren = setWidthBasedOnChildren ;
2019-08-13 16:05:18 +02:00
this . SetHeightBasedOnChildren = setHeightBasedOnChildren ;
2019-08-28 18:27:17 +02:00
this . CanBeSelected = false ;
2019-08-10 13:44:48 +02:00
}
2020-05-22 17:02:24 +02:00
/// <inheritdoc />
2022-04-25 15:25:58 +02:00
public override void Draw ( GameTime time , SpriteBatch batch , float alpha , SpriteBatchContext context ) {
2020-05-17 00:59:15 +02:00
// since the group never accesses its own area when drawing, we have to update it manually
2019-12-29 15:25:33 +01:00
this . UpdateAreaIfDirty ( ) ;
2022-04-25 15:25:58 +02:00
base . Draw ( time , batch , alpha , context ) ;
2019-12-29 15:25:33 +01:00
}
2019-08-10 13:44:48 +02:00
}
2022-06-17 18:23:47 +02:00
}