Fix any remaining bugs with anchor positioning system, use LocalPosition for UIElement, and make containers use that for arrangement.
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Voile.UI.Containers;
|
||||
public abstract class Container : UIElement, IParentableElement
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<IElement> Children => _children;
|
||||
public IReadOnlyList<UIElement> Children => _children;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies if this <see cref="Container"/>'s minimum size will be confined to contents.
|
||||
@@ -31,7 +31,7 @@ public abstract class Container : UIElement, IParentableElement
|
||||
MarkDirty();
|
||||
}
|
||||
|
||||
public Container(Rect minimumSize, List<IElement> children)
|
||||
public Container(Rect minimumSize, List<UIElement> children)
|
||||
{
|
||||
_minimumSize = minimumSize;
|
||||
_children = children;
|
||||
@@ -50,7 +50,7 @@ public abstract class Container : UIElement, IParentableElement
|
||||
|
||||
if (child is IAnchorableElement anchorable)
|
||||
{
|
||||
anchorable.ApplyAnchor(Position, Size);
|
||||
anchorable.ApplyAnchor(GlobalPosition, Size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public abstract class Container : UIElement, IParentableElement
|
||||
|
||||
foreach (var child in Children)
|
||||
{
|
||||
var pos = child.Position;
|
||||
var pos = child.GlobalPosition;
|
||||
var size = child.Size;
|
||||
|
||||
minX = MathF.Min(minX, pos.X);
|
||||
@@ -105,15 +105,16 @@ public abstract class Container : UIElement, IParentableElement
|
||||
}
|
||||
}
|
||||
|
||||
public void AddChild(IElement child)
|
||||
public void AddChild(UIElement child)
|
||||
{
|
||||
_children.Add(child);
|
||||
child.SetParent(this);
|
||||
|
||||
MarkDirty();
|
||||
Update();
|
||||
}
|
||||
|
||||
public void RemoveChild(IElement child)
|
||||
public void RemoveChild(UIElement child)
|
||||
{
|
||||
_children.Remove(child);
|
||||
|
||||
@@ -130,6 +131,6 @@ public abstract class Container : UIElement, IParentableElement
|
||||
}
|
||||
}
|
||||
|
||||
private List<IElement> _children = new();
|
||||
private List<UIElement> _children = new();
|
||||
private Rect _minimumSize = Rect.Zero;
|
||||
}
|
||||
Reference in New Issue
Block a user