diff options
author | bptato <nincsnevem662@gmail.com> | 2024-06-30 12:59:55 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2024-06-30 13:08:11 +0200 |
commit | ed2d399f716a3a0fb9175857781b0f70b54db032 (patch) | |
tree | 207cce94744e98a2aca996310776d0b2fba88698 /src | |
parent | 96d3d12445c9a2e3bb00c0c242bdec6d37b11084 (diff) | |
download | chawan-ed2d399f716a3a0fb9175857781b0f70b54db032.tar.gz |
layout: flex padding/margin fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/layout/engine.nim | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/layout/engine.nim b/src/layout/engine.nim index 7fea2289..525204aa 100644 --- a/src/layout/engine.nim +++ b/src/layout/engine.nim @@ -2141,6 +2141,7 @@ proc flushMain(fctx: var FlexContext; mctx: var FlexMainContext; it.child.state.margin[odim].start fctx.box.applyOverflowDimensions(it.child) offset[dim] += it.child.state.size[dim] + offset[dim] += it.child.state.margin[dim].send fctx.totalMaxSize[dim] = max(fctx.totalMaxSize[dim], offset[dim]) fctx.mains.add(mctx) mctx = FlexMainContext() @@ -2150,7 +2151,11 @@ proc layoutFlex(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) = assert box.inline == nil let lctx = bctx.lctx var i = 0 - var fctx = FlexContext(lctx: lctx, box: box) + var fctx = FlexContext( + lctx: lctx, + box: box, + offset: offset(x = sizes.padding.left, y = sizes.padding.top) + ) var mctx = FlexMainContext() let flexDir = box.computed{"flex-direction"} let canWrap = box.computed{"flex-wrap"} != FlexWrapNowrap @@ -2161,7 +2166,8 @@ proc layoutFlex(bctx: var BlockContext; box: BlockBox; sizes: ResolvedSizes) = child.computed) let flexBasis = child.computed{"flex-basis"} if not flexBasis.auto: - childSizes.space[dim] = stretch(flexBasis.px(lctx, sizes.space[dim])) + childSizes.space[dim] = stretch(flexBasis.spx(lctx, sizes.space[dim], + child.computed, childSizes.padding[dim].sum())) lctx.layoutFlexChild(child, childSizes) if not flexBasis.auto and childSizes.space.w.isDefinite and child.state.xminwidth > childSizes.space.w.u: |