Add MarginContainer, mark parent elements dirty when child gets marked dirty too.
This commit is contained in:
@@ -23,8 +23,6 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme
|
||||
get => _size;
|
||||
set
|
||||
{
|
||||
_size = value;
|
||||
|
||||
if (value.Width < MinimumSize.Width)
|
||||
{
|
||||
_size.Width = MinimumSize.Width;
|
||||
@@ -35,7 +33,12 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme
|
||||
_size.Height = MinimumSize.Height;
|
||||
}
|
||||
|
||||
MarkDirty();
|
||||
if (_size != value)
|
||||
{
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
_size = value;
|
||||
}
|
||||
}
|
||||
public Vector2 AnchorOffset { get; set; } = Vector2.Zero;
|
||||
@@ -44,7 +47,15 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme
|
||||
public abstract Rect MinimumSize { get; }
|
||||
public bool Dirty => _dirty;
|
||||
|
||||
public virtual void MarkDirty() => _dirty = true;
|
||||
public virtual void MarkDirty()
|
||||
{
|
||||
if (Parent != null && !Parent.Dirty)
|
||||
{
|
||||
Parent.MarkDirty();
|
||||
}
|
||||
|
||||
_dirty = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets a parent element for this <see cref="UIElement"/>.
|
||||
|
||||
Reference in New Issue
Block a user