mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
4ecb74f6b6
* FNA projects * update actions fixes MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file. * build tests * remove test for issue #633 * FNA/XNA compatible * GraphicsDevice Extensions * remove MockGameWindow --------- Co-authored-by: Christopher Whitley <103014489+AristurtleDev@users.noreply.github.com>
70 lines
1.8 KiB
C#
70 lines
1.8 KiB
C#
using System.Collections.Generic;
|
|
using Microsoft.Xna.Framework;
|
|
|
|
namespace MonoGame.Extended.Gui.Controls
|
|
{
|
|
public abstract class CompositeControl : Control
|
|
{
|
|
protected CompositeControl()
|
|
{
|
|
}
|
|
|
|
protected bool IsDirty { get; set; } = true;
|
|
|
|
public abstract object Content { get; set; }
|
|
|
|
protected abstract Control Template { get; }
|
|
|
|
public override IEnumerable<Control> Children
|
|
{
|
|
get
|
|
{
|
|
var control = Template;
|
|
|
|
if (control != null)
|
|
yield return control;
|
|
}
|
|
}
|
|
|
|
public override void InvalidateMeasure()
|
|
{
|
|
base.InvalidateMeasure();
|
|
IsDirty = true;
|
|
}
|
|
|
|
public override Size GetContentSize(IGuiContext context)
|
|
{
|
|
var control = Template;
|
|
|
|
if (control != null)
|
|
return Template.CalculateActualSize(context);
|
|
|
|
return Size.Empty;
|
|
}
|
|
|
|
public override void Update(IGuiContext context, float deltaSeconds)
|
|
{
|
|
var control = Template;
|
|
|
|
if (control != null)
|
|
{
|
|
if (IsDirty)
|
|
{
|
|
control.Parent = this;
|
|
control.ActualSize = new Point(ContentRectangle.Width, ContentRectangle.Height);
|
|
control.Position = new Point(Padding.Left, Padding.Top);
|
|
control.InvalidateMeasure();
|
|
IsDirty = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Draw(IGuiContext context, IGuiRenderer renderer, float deltaSeconds)
|
|
{
|
|
base.Draw(context, renderer, deltaSeconds);
|
|
|
|
var control = Template;
|
|
control?.Draw(context, renderer, deltaSeconds);
|
|
}
|
|
}
|
|
} |