Mac: Improve groupbox styling

This commit is contained in:
Ben Olden-Cooligan 2022-12-04 13:12:22 -08:00
parent df4355e3a2
commit 1f529e7add
3 changed files with 28 additions and 2 deletions

View File

@ -1,7 +1,9 @@
using Eto;
using Eto.Drawing;
using Eto.Forms;
using Eto.Mac;
using Eto.Mac.Drawing;
using NAPS2.EtoForms.Layout;
using NAPS2.Images.Mac;
using sd = System.Drawing;
@ -66,4 +68,22 @@ public class MacEtoPlatform : EtoPlatform
// TODO
return new NSView().ToEto();
}
public override LayoutElement CreateGroupBox(string title, LayoutElement content)
{
var titleLabel = new Label
{
Text = title,
Font = NSFont.BoldSystemFontOfSize(12).ToEto()
};
var groupBox = new GroupBox();
return L.Overlay(
L.Column(
titleLabel.Padding(top: 8).SpacingAfter(6),
groupBox.YScale()
),
L.Buffer(content, 6, 32, 6, 6)
);
}
}

View File

@ -97,6 +97,12 @@ public abstract class EtoPlatform
{
}
public virtual LayoutElement CreateGroupBox(string title, LayoutElement content)
{
var groupBox = new GroupBox { Text = title };
return L.Overlay(groupBox, L.Buffer(content, 6, 18, 6, 6));
}
public virtual void ShowIcon(Dialog dialog)
{
}

View File

@ -47,10 +47,10 @@ public static class L
public static LayoutElement GroupBox(string title, LayoutElement content)
{
return L.Overlay(new GroupBox { Text = title }, L.Buffer(content, 6, 18, 6, 6));
return EtoPlatform.Current.CreateGroupBox(title, content);
}
private static LayoutElement Buffer(LayoutElement element, int left, int top, int right, int bottom)
public static LayoutElement Buffer(LayoutElement element, int left, int top, int right, int bottom)
{
return new BufferLayoutElement(element, left, top, right, bottom);
}