Skip to content

Commit

Permalink
Fix scaling for BufferLayoutElement
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Sep 6, 2024
1 parent 5182fda commit a29de10
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions NAPS2.Lib/EtoForms/Layout/BufferLayoutElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ public BufferLayoutElement(LayoutElement element, int left, int top, int right,

public override void DoLayout(LayoutContext context, RectangleF bounds)
{
Element.DoLayout(context,
new RectangleF(bounds.X + Left, bounds.Top + Top, bounds.Width - Left - Right,
bounds.Height - Top - Bottom));
Element.DoLayout(context, new RectangleF(
bounds.X + Left * context.Scale,
bounds.Y + Top * context.Scale,
bounds.Width - (Left + Right) * context.Scale,
bounds.Height - (Top + Bottom) * context.Scale));
}

protected override SizeF GetPreferredSizeCore(LayoutContext context, RectangleF parentBounds)
{
return Element.GetPreferredSize(context,
new RectangleF(parentBounds.X + Left, parentBounds.Top + Top, parentBounds.Width - Left - Right,
parentBounds.Height - Top - Bottom))
+ new SizeF(Left + Right, Top + Bottom);
new RectangleF(
parentBounds.X + Left * context.Scale,
parentBounds.Y + Top * context.Scale,
parentBounds.Width - (Left + Right) * context.Scale,
parentBounds.Height - (Top + Bottom) * context.Scale))
+ new SizeF(Left + Right, Top + Bottom) * context.Scale;
}
}

0 comments on commit a29de10

Please sign in to comment.