diff options
| author | Jules Aguillon | 2022-01-15 20:24:27 +0100 |
|---|---|---|
| committer | Jules Aguillon | 2022-01-15 20:24:27 +0100 |
| commit | 833dfa31bb17e5fa14681f15969391ecc7a28014 (patch) | |
| tree | af89b415c00864a270a9d8ff231d20024f081b16 /srcs/juloo.keyboard2/Keyboard2View.java | |
| parent | fa9250a89e657082c505f0fafdcd38f00df94be1 (diff) | |
| download | unexpected-keyboard-833dfa31bb17e5fa14681f15969391ecc7a28014.tar.gz unexpected-keyboard-833dfa31bb17e5fa14681f15969391ecc7a28014.zip | |
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.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
| -rw-r--r-- | srcs/juloo.keyboard2/Keyboard2View.java | 14 |
1 files changed, 7 insertions, 7 deletions
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; } } |
