2020-07-15 23:21:52 +02:00
|
|
|
using System;
|
2019-09-08 16:30:55 +02:00
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
|
|
|
|
namespace MLEM.Ui.Elements {
|
2020-05-22 17:02:24 +02:00
|
|
|
/// <summary>
|
|
|
|
/// A <see cref="Group"/> that can have custom drawing parameters.
|
2020-07-15 23:21:52 +02:00
|
|
|
/// Custom drawing parameters include a <see cref="Element.Transform"/> matrix, as well as a custom <see cref="SpriteBatch.Begin"/> call.
|
2020-05-22 17:02:24 +02:00
|
|
|
/// All <see cref="Element.Children"/> of the custom draw group will be drawn with the custom parameters.
|
|
|
|
/// </summary>
|
2020-07-15 23:21:52 +02:00
|
|
|
[Obsolete("CustomDrawGroup mechanics have been moved down to Element, which means custom draw groups are no longer necessary.")]
|
2019-09-08 16:30:55 +02:00
|
|
|
public class CustomDrawGroup : Group {
|
|
|
|
|
2020-05-22 17:02:24 +02:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new custom draw group with the given settings
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="anchor">The group's anchor</param>
|
|
|
|
/// <param name="size">The group's size</param>
|
2020-07-15 23:21:52 +02:00
|
|
|
/// <param name="transformGetter">The group's <see cref="Element.TransformGetter"/></param>
|
|
|
|
/// <param name="beginImpl">The group's <see cref="Element.BeginImpl"/></param>
|
2020-05-22 17:02:24 +02:00
|
|
|
/// <param name="setHeightBasedOnChildren">Whether this group should automatically calculate its height based on its children</param>
|
2019-12-29 19:28:56 +01:00
|
|
|
public CustomDrawGroup(Anchor anchor, Vector2 size, TransformCallback transformGetter = null, BeginDelegate beginImpl = null, bool setHeightBasedOnChildren = true) :
|
2019-09-08 16:30:55 +02:00
|
|
|
base(anchor, size, setHeightBasedOnChildren) {
|
2019-12-29 19:28:56 +01:00
|
|
|
this.TransformGetter = transformGetter ?? ((element, time, matrix) => Matrix.Identity);
|
2020-03-02 10:31:03 +01:00
|
|
|
this.BeginImpl = beginImpl;
|
2019-09-08 16:30:55 +02:00
|
|
|
}
|
|
|
|
|
2020-07-15 23:21:52 +02:00
|
|
|
///<inheritdoc cref="Element.ScaleTransform"/>
|
|
|
|
[Obsolete("Use ScaleTransform instead")]
|
2020-03-18 16:47:14 +01:00
|
|
|
public void ScaleOrigin(float scale, Vector2? origin = null) {
|
2020-07-15 23:21:52 +02:00
|
|
|
this.ScaleTransform(scale, origin);
|
2020-03-18 16:47:14 +01:00
|
|
|
}
|
|
|
|
|
2019-09-08 16:30:55 +02:00
|
|
|
}
|
|
|
|
}
|