abouttreesummaryrefslogcommitdiff
diff options
context:
space:
mode:
authorJules Aguillon2022-01-15 20:24:27 +0100
committerJules Aguillon2022-01-15 20:24:27 +0100
commit833dfa31bb17e5fa14681f15969391ecc7a28014 (patch)
treeaf89b415c00864a270a9d8ff231d20024f081b16
parentfa9250a89e657082c505f0fafdcd38f00df94be1 (diff)
downloadunexpected-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.
-rw-r--r--srcs/juloo.keyboard2/Config.java4
-rw-r--r--srcs/juloo.keyboard2/Keyboard2View.java14
2 files changed, 10 insertions, 8 deletions
diff --git a/srcs/juloo.keyboard2/Config.java b/srcs/juloo.keyboard2/Config.java
index 63befa5..92cd8a6 100644
--- a/srcs/juloo.keyboard2/Config.java
+++ b/srcs/juloo.keyboard2/Config.java
@@ -86,7 +86,9 @@ final class Config
longPressTimeout = prefs.getInt("longpress_timeout", (int)longPressTimeout);
longPressInterval = prefs.getInt("longpress_interval", (int)longPressInterval);
marginBottom = getDipPref(dm, prefs, "margin_bottom", marginBottom);
- keyHeight = getDipPref(dm, prefs, "key_height", keyHeight);
+ // Add keyVerticalInterval to keyHeight because the space between the keys
+ // is removed from the keys during rendering
+ keyHeight = getDipPref(dm, prefs, "key_height", keyHeight) + keyVerticalInterval;
horizontalMargin = getDipPref(dm, prefs, "horizontal_margin", horizontalMargin);
preciseRepeat = prefs.getBoolean("precise_repeat", preciseRepeat);
characterSize = prefs.getFloat("character_size", characterSize);
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;
}
}