aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-04-20 16:29:03 +0200
committerbptato <nincsnevem662@gmail.com>2024-04-20 16:39:35 +0200
commitf21496a3e1eb7b9f53fd93529e273f8821e9de00 (patch)
treeefa2e86802ef0844724bd3f91efc70d6ae771d5a /src
parentd0ca9b255b3c3c18f3ac62b836a1f9ed0aa08157 (diff)
downloadchawan-f21496a3e1eb7b9f53fd93529e273f8821e9de00.tar.gz
layout: fix double padding in flex
sizes.space regulates content-box width, in which padding is not included, so we must to subtract padding here. (Neither is margin, but margin is applied by outer layout, in this case flex itself, so it's not relevant here. Not to say it isn't broken...)
Diffstat (limited to 'src')
-rw-r--r--src/layout/engine.nim6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim
index aafa703d..6ac11cd7 100644
--- a/src/layout/engine.nim
+++ b/src/layout/engine.nim
@@ -2165,7 +2165,8 @@ proc redistributeWidth(mctx: var FlexMainContext; sizes: ResolvedSizes) =
diff += w - maxw
it.weights[wt] = 0
w = maxw
- it.sizes.space.w = stretch(w)
+ it.sizes.space.w = stretch(w - it.sizes.padding.left -
+ it.sizes.padding.right)
totalWeight += it.weights[wt]
#TODO we should call this only on freeze, and then put another loop to
# the end for non-freezed items
@@ -2207,7 +2208,8 @@ proc redistributeHeight(mctx: var FlexMainContext; sizes: ResolvedSizes) =
diff += h - maxh
it.weights[wt] = 0
h = maxh
- it.sizes.space.h = stretch(h)
+ it.sizes.space.h = stretch(h - it.sizes.padding.top -
+ it.sizes.padding.bottom)
totalWeight += it.weights[wt]
it.child = lctx.layoutFlexChild(builder, it.sizes)
mctx.maxSize.h = max(mctx.maxSize.h, it.child.size.h)