From 833dfa31bb17e5fa14681f15969391ecc7a28014 Mon Sep 17 00:00:00 2001 From: Jules Aguillon Date: Sat, 15 Jan 2022 20:24:27 +0100 Subject: Fix miscalculation of the space between the keys 'keyVerticalInterval' was mistakenly used to compute the height of the keyboard and the vertical position of keys. While the code handling pointers did not use this value, the hit box of the bottom row was shifted by several pixels. Make sure 'keyVerticalInterval' is only used for rendering and not for placing the keys. --- srcs/juloo.keyboard2/Keyboard2View.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'srcs/juloo.keyboard2/Keyboard2View.java') diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java index 5e687d7..18a6c72 100644 --- a/srcs/juloo.keyboard2/Keyboard2View.java +++ b/srcs/juloo.keyboard2/Keyboard2View.java @@ -349,7 +349,7 @@ public class Keyboard2View extends View int width = dm.widthPixels; int height = (int)(_config.keyHeight * _keyboard.keysHeight - + _keyboard.rows.size() * _config.keyVerticalInterval + + _keyboard.rows.size() + _config.marginTop + _config.marginBottom); setMeasuredDimension(width, height); _keyWidth = (width - (_config.horizontalMargin * 2)) / _keyboard.keysWidth; @@ -358,15 +358,15 @@ public class Keyboard2View extends View @Override protected void onDraw(Canvas canvas) { - float y = _config.marginTop; + float y = _config.marginTop + _config.keyVerticalInterval / 2; for (KeyboardData.Row row : _keyboard.rows) { y += row.shift * _config.keyHeight; - float x = _config.horizontalMargin; - float keyH = row.height * _config.keyHeight; + float x = _config.horizontalMargin + _config.keyHorizontalInterval / 2; + float keyH = row.height * _config.keyHeight - _config.keyVerticalInterval; for (KeyboardData.Key k : row.keys) { - x += k.shift * _keyWidth + _config.keyHorizontalInterval; + x += k.shift * _keyWidth; float keyW = _keyWidth * k.width - _config.keyHorizontalInterval; KeyDown keyDown = getKeyDown(k); _tmpRect.set(x, y, x + keyW, y + keyH); @@ -383,9 +383,9 @@ public class Keyboard2View extends View drawSubLabel(canvas, k.key2, x + keyW - subPadding, y + subPadding, true, true, keyDown); if (k.key4 != null) drawSubLabel(canvas, k.key4, x + keyW - subPadding, y + keyH - subPadding, true, false, keyDown); - x += keyW; + x += _keyWidth * k.width; } - y += keyH + _config.keyVerticalInterval; + y += row.height * _config.keyHeight; } } -- cgit v1.2.3