More UI work
This commit is contained in:
@@ -5,6 +5,7 @@ namespace DaggerFramework.UI;
|
||||
public class MarginPanel : Panel
|
||||
{
|
||||
public Vector2 RelativeMargin { get; set; }
|
||||
public Vector2 AbsoluteMargin { get; set; }
|
||||
public MarginPanel(PanelStyle style) : base(style)
|
||||
{
|
||||
}
|
||||
@@ -14,6 +15,10 @@ public class MarginPanel : Panel
|
||||
base.RearrangeChild(idx, child);
|
||||
|
||||
var rect = child.Rect;
|
||||
rect.Position = Rect.Size * RelativeMargin;
|
||||
|
||||
var absoluteMargin = Rect.Size * RelativeMargin + AbsoluteMargin;
|
||||
|
||||
rect.Position = Rect.Position + absoluteMargin;
|
||||
rect.Size = rect.Size - absoluteMargin * 2;
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,8 @@ public abstract class UIElement
|
||||
|
||||
public void Render(Renderer renderer)
|
||||
{
|
||||
renderer.SetTransform(Rect.Position, Vector2.Zero, 0);
|
||||
Vector2 parentPos = parent != null ? parent.Rect.Position : Vector2.Zero;
|
||||
renderer.SetTransform(Rect.Position + parentPos, Vector2.Zero, 0);
|
||||
OnRender(renderer);
|
||||
|
||||
foreach (UIElement child in children)
|
||||
|
||||
Reference in New Issue
Block a user