Let CultUI surfaces omit headers
This commit is contained in:
parent
825091ac04
commit
f64e138b9e
2 changed files with 20 additions and 14 deletions
|
|
@ -121,25 +121,25 @@ public sealed record AquariumUiElement(
|
|||
|
||||
public sealed class AquariumUiSurfaceBuilder(List<AquariumUiElement> children)
|
||||
{
|
||||
public AquariumUiSurfaceBuilder Vertical(string id, Action<AquariumUiSurfaceBuilder> compose, float weight = 1.0f, float gap = 8.0f, float padding = 0.0f)
|
||||
public AquariumUiSurfaceBuilder Vertical(string id, Action<AquariumUiSurfaceBuilder> compose, float weight = 1.0f, float gap = 8.0f, float padding = 0.0f, Func<bool>? isVisible = null)
|
||||
{
|
||||
var scopeChildren = new List<AquariumUiElement>();
|
||||
compose(new AquariumUiSurfaceBuilder(scopeChildren));
|
||||
children.Add(new AquariumUiElement(id, "group", Layout: AquariumUiLayout.Vertical(gap, padding), Weight: Math.Max(0.001f, weight), Children: scopeChildren));
|
||||
children.Add(new AquariumUiElement(id, "group", Layout: AquariumUiLayout.Vertical(gap, padding), IsVisible: isVisible, Weight: Math.Max(0.001f, weight), Children: scopeChildren));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AquariumUiSurfaceBuilder Horizontal(string id, Action<AquariumUiSurfaceBuilder> compose, float weight = 1.0f, float gap = 8.0f, float padding = 0.0f)
|
||||
public AquariumUiSurfaceBuilder Horizontal(string id, Action<AquariumUiSurfaceBuilder> compose, float weight = 1.0f, float gap = 8.0f, float padding = 0.0f, Func<bool>? isVisible = null)
|
||||
{
|
||||
var scopeChildren = new List<AquariumUiElement>();
|
||||
compose(new AquariumUiSurfaceBuilder(scopeChildren));
|
||||
children.Add(new AquariumUiElement(id, "group", Layout: AquariumUiLayout.Horizontal(gap, padding), Weight: Math.Max(0.001f, weight), Children: scopeChildren));
|
||||
children.Add(new AquariumUiElement(id, "group", Layout: AquariumUiLayout.Horizontal(gap, padding), IsVisible: isVisible, Weight: Math.Max(0.001f, weight), Children: scopeChildren));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AquariumUiSurfaceBuilder Row(string id, Action<AquariumUiSurfaceBuilder> compose, float weight = 1.0f)
|
||||
public AquariumUiSurfaceBuilder Row(string id, Action<AquariumUiSurfaceBuilder> compose, float weight = 1.0f, Func<bool>? isVisible = null)
|
||||
{
|
||||
return Horizontal(id, compose, weight);
|
||||
return Horizontal(id, compose, weight, isVisible: isVisible);
|
||||
}
|
||||
|
||||
public AquariumUiSurfaceBuilder Pane(string id, string title, Action<AquariumUiSurfaceBuilder> compose, string tone = "neutral", float weight = 1.0f)
|
||||
|
|
@ -158,15 +158,15 @@ public sealed class AquariumUiSurfaceBuilder(List<AquariumUiElement> children)
|
|||
return this;
|
||||
}
|
||||
|
||||
public AquariumUiSurfaceBuilder Text(string id, string text, string role = "body", float weight = 1.0f)
|
||||
public AquariumUiSurfaceBuilder Text(string id, string text, string role = "body", float weight = 1.0f, Func<bool>? isVisible = null)
|
||||
{
|
||||
children.Add(new AquariumUiElement(id, "text", text, role, Weight: Math.Max(0.001f, weight)));
|
||||
children.Add(new AquariumUiElement(id, "text", text, role, IsVisible: isVisible, Weight: Math.Max(0.001f, weight)));
|
||||
return this;
|
||||
}
|
||||
|
||||
public AquariumUiSurfaceBuilder Text(string id, Func<string> read, string role = "body", float weight = 1.0f)
|
||||
public AquariumUiSurfaceBuilder Text(string id, Func<string> read, string role = "body", float weight = 1.0f, Func<bool>? isVisible = null)
|
||||
{
|
||||
children.Add(new AquariumUiElement(id, "text", Role: role, ReadText: read, Weight: Math.Max(0.001f, weight)));
|
||||
children.Add(new AquariumUiElement(id, "text", Role: role, ReadText: read, IsVisible: isVisible, Weight: Math.Max(0.001f, weight)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -194,9 +194,9 @@ public sealed class AquariumUiSurfaceBuilder(List<AquariumUiElement> children)
|
|||
return this;
|
||||
}
|
||||
|
||||
public AquariumUiSurfaceBuilder Button(string id, string label, Action invoke, float weight = 1.0f)
|
||||
public AquariumUiSurfaceBuilder Button(string id, string label, Action invoke, float weight = 1.0f, Func<bool>? isVisible = null)
|
||||
{
|
||||
children.Add(new AquariumUiElement(id, "button", label, Invoke: invoke, Weight: Math.Max(0.001f, weight)));
|
||||
children.Add(new AquariumUiElement(id, "button", label, Invoke: invoke, IsVisible: isVisible, Weight: Math.Max(0.001f, weight)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,8 +189,14 @@ internal sealed class DirectWriteOverlay : IDisposable
|
|||
Math.Clamp(surface.Bounds.Top + surface.Bounds.Height, 56.0f, height - 8.0f));
|
||||
renderTarget.FillRectangle(bounds, panelBrush);
|
||||
renderTarget.DrawRectangle(bounds, outlineBrush, 1.0f);
|
||||
DrawHeader(surface.Title, titleFormat, RectFromEdges(bounds.Left + 12.0f, bounds.Top + 8.0f, bounds.Right - 12.0f, bounds.Top + 34.0f), primaryTextBrush);
|
||||
var content = RectFromEdges(bounds.Left + 8.0f, bounds.Top + 42.0f, bounds.Right - 8.0f, bounds.Bottom - 8.0f);
|
||||
var hasTitle = !string.IsNullOrWhiteSpace(surface.Title);
|
||||
if (hasTitle)
|
||||
{
|
||||
DrawHeader(surface.Title, titleFormat, RectFromEdges(bounds.Left + 12.0f, bounds.Top + 8.0f, bounds.Right - 12.0f, bounds.Top + 34.0f), primaryTextBrush);
|
||||
}
|
||||
|
||||
var contentTop = hasTitle ? bounds.Top + 42.0f : bounds.Top + 8.0f;
|
||||
var content = RectFromEdges(bounds.Left + 8.0f, contentTop, bounds.Right - 8.0f, bounds.Bottom - 8.0f);
|
||||
DrawSurfaceChildren(surface.Root.Children ?? [], content, surface.Root.Layout ?? AquariumUiLayout.Vertical());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue