From 40e79dd4b42f4d93a8de8e24786e450b59ddc4de Mon Sep 17 00:00:00 2001 From: bptato Date: Sat, 30 Mar 2024 02:27:13 +0100 Subject: layout: fix float positioning with margins Here we are restricting the float to the same width constraint as its parent, so we must add offset.x both when the float is larger than this constraint *and* when the float fits into the constraint. An example of what this fixes:
wat ^ previously the float was positioned as if the padding had been on the *right*, because it did not take into account offset.x. --- src/layout/engine.nim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/layout') diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 79822cd0..66e0589b 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -1296,7 +1296,7 @@ func findNextFloatOffset(bctx: BlockContext; offset: Offset; size: Size; # Algorithm originally from QEmacs. var y = offset.y let leftStart = offset.x - let rightStart = max(offset.x + size.w, space.w.u) + let rightStart = offset.x + max(size.w, space.w.u) while true: var left = leftStart var right = rightStart -- cgit