diff options
| author | trustable-code <krauter.simon@arcor.de> | 2020-02-16 01:50:18 +0100 |
|---|---|---|
| committer | trustable-code <krauter.simon@arcor.de> | 2020-02-16 01:50:18 +0100 |
| commit | 3626e867bcb9493d900e1e157ab05fb5cc4c2e01 (patch) | |
| tree | b962ae3eea408d075af474b08119f9c16b0b5041 | |
| parent | ec650392735515f663d079f40ce07cb036d3f97d (diff) | |
| download | NiGui-3626e867bcb9493d900e1e157ab05fb5cc4c2e01.tar.gz NiGui-3626e867bcb9493d900e1e157ab05fb5cc4c2e01.zip | |
Label: Use canvas instead of control to measure text dimensions
| -rwxr-xr-x | src/nigui.nim | 8 |
1 files changed, 4 insertions, 4 deletions
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) |
