From 3626e867bcb9493d900e1e157ab05fb5cc4c2e01 Mon Sep 17 00:00:00 2001 From: trustable-code Date: Sun, 16 Feb 2020 01:50:18 +0100 Subject: Label: Use canvas instead of control to measure text dimensions --- src/nigui.nim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nigui.nim b/src/nigui.nim index 125a346..96af6f4 100755 --- a/src/nigui.nim +++ b/src/nigui.nim @@ -2603,17 +2603,17 @@ method handleDrawEvent(label: Label, event: DrawEvent) = of XTextAlign_Left: 0 of XTextAlign_Center: - (label.width - label.naturalWidth) div 2 + (label.width - label.canvas.getTextLineWidth(label.text)) div 2 of XTextAlign_Right: - label.width - label.naturalWidth + label.width - label.canvas.getTextLineWidth(label.text) let y = case label.yTextAlign of YTextAlign_Top: 0 of YTextAlign_Center: - (label.height - label.naturalHeight) div 2 + (label.height - label.canvas.getTextLineHeight() * label.text.countLines) div 2 of YTextAlign_Bottom: - label.height - label.naturalHeight + label.height - label.canvas.getTextLineHeight() * label.text.countLines label.canvas.drawText(label.text, x, y) -- cgit v1.2.3