Skip to content

Commit

Permalink
Scale DynamicWrap
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Sep 8, 2024
1 parent 104c7f4 commit 31a2d30
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions NAPS2.Lib/EtoForms/Layout/LayoutControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ protected override SizeF GetPreferredSizeCore(LayoutContext context, RectangleF
private SizeF GetWrappedSize(LayoutContext context, RectangleF parentBounds, int wrapDefaultWidth)
{
if (Control == null) throw new InvalidOperationException();
int scaledWrapDefaultWidth = (int) Math.Round(wrapDefaultWidth * context.Scale);
// Label wrapping is fairly complicated.
if (!context.IsLayout)
{
// If we're not in a layout operation (i.e. we're getting a minimum or default form size), the
// measured size should be based on the default width for wrapping.
// This produces the label width (if small) or the default width (if long enough to wrap).
return EtoPlatform.Current.GetWrappedSize(Control, wrapDefaultWidth);
return EtoPlatform.Current.GetWrappedSize(Control, scaledWrapDefaultWidth);
}
if (context.IsCellLengthQuery)
{
Expand All @@ -134,7 +135,7 @@ private SizeF GetWrappedSize(LayoutContext context, RectangleF parentBounds, int
// usually what we want.
return new SizeF(
EtoPlatform.Current.GetWrappedSize(Control, (int) parentBounds.Width).Width,
EtoPlatform.Current.GetWrappedSize(Control, Math.Min((int) parentBounds.Width, wrapDefaultWidth))
EtoPlatform.Current.GetWrappedSize(Control, Math.Min((int) parentBounds.Width, scaledWrapDefaultWidth))
.Height);
}
// Now that we've handled the special cases, this measures the real dimensions of the label given
Expand Down

0 comments on commit 31a2d30

Please sign in to comment.