Skip to content

Commit a3b129b

Browse files
committed
Fix cCenter and vCenter.
1 parent a29ca4f commit a3b129b

File tree

2 files changed

+16
-18
lines changed

2 files changed

+16
-18
lines changed

src/fidget/common.nim

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -371,23 +371,6 @@ proc computeLayout*(parent, node: Node) =
371371
for n in node.nodes:
372372
computeLayout(node, n)
373373
374-
# Typeset text
375-
if node.kind == nkText:
376-
computeTextLayout(node)
377-
print node.textLayoutWidth
378-
print node.textLayoutHeight
379-
case node.textStyle.autoResize:
380-
of tsNone:
381-
# Fixed sized text node.
382-
discard
383-
of tsHeight:
384-
# Text will grow down.
385-
node.box.h = node.textLayoutHeight
386-
of tsWidthAndHeight:
387-
# Text will grow down and wide.
388-
node.box.w = node.textLayoutWidth
389-
node.box.h = node.textLayoutHeight
390-
391374
# Constraints code.
392375
case node.constraintsVertical:
393376
of cMin: discard
@@ -421,6 +404,21 @@ proc computeLayout*(parent, node: Node) =
421404
let offset = floor((node.orgBox.h - parent.orgBox.h) / 2.0 + node.orgBox.y)
422405
node.box.y = floor((parent.box.h - node.box.h) / 2.0) + offset
423406
407+
# Typeset text
408+
if node.kind == nkText:
409+
computeTextLayout(node)
410+
case node.textStyle.autoResize:
411+
of tsNone:
412+
# Fixed sized text node.
413+
discard
414+
of tsHeight:
415+
# Text will grow down.
416+
node.box.h = node.textLayoutHeight
417+
of tsWidthAndHeight:
418+
# Text will grow down and wide.
419+
node.box.w = node.textLayoutWidth
420+
node.box.h = node.textLayoutHeight
421+
424422
# Auto-layout code.
425423
if node.layoutMode == lmVertical:
426424
if node.counterAxisSizingMode == csAuto:

src/fidget/openglbackend.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ computeTextLayout = proc(node: Node) =
2727
boundsMax: Vec2
2828
size = node.box.wh
2929
if node.textStyle.autoResize == tsWidthAndHeight:
30-
size = vec2(0, 0)
30+
size.x = 0
3131
node.textLayout = font.typeset(
3232
node.text.toRunes(),
3333
pos = vec2(0, 0),

0 commit comments

Comments
 (0)