abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2View.java
diff options
context:
space:
mode:
authorJules Aguillon2024-01-28 19:38:29 +0100
committerJules Aguillon2024-01-28 19:38:29 +0100
commitbbc622683961a04a2e3fd41d043ad54855c6c131 (patch)
tree27b75ad4dd6306363eb0bca5832248151ed504fe /srcs/juloo.keyboard2/Keyboard2View.java
parentc5f2c0b727c0ef70a76e897402e0247f148553fc (diff)
downloadunexpected-keyboard-bbc622683961a04a2e3fd41d043ad54855c6c131.tar.gz
unexpected-keyboard-bbc622683961a04a2e3fd41d043ad54855c6c131.zip
Redefined the key margin options in percent
Define the key margin options relative to the baseline dimensions of keys. This removes the doubling of the horizontal margin in landscape mode.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2View.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index a4cfeb0..8c9a035 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -299,16 +299,20 @@ public class Keyboard2View extends View
_theme.keyBgPaint.setAlpha(_config.keyOpacity);
_theme.keyDownBgPaint.setAlpha(_config.keyActivatedOpacity);
_theme.keyBorderPaint.setAlpha(_config.keyOpacity);
- float y = _config.marginTop + _config.keyVerticalInterval / 2;
+ float key_vertical_margin = _config.key_vertical_margin * _config.keyHeight;
+ float key_horizontal_margin = _config.key_horizontal_margin * _keyWidth;
+ // Add half of the key margin on the left and on the top as it's then added
+ // on the right and on the bottom of every keys.
+ float y = _config.marginTop + key_vertical_margin / 2;
for (KeyboardData.Row row : _keyboard.rows)
{
y += row.shift * _config.keyHeight;
- float x = _config.horizontal_margin + _config.keyHorizontalInterval / 2;
- float keyH = row.height * _config.keyHeight - _config.keyVerticalInterval;
+ float x = _config.horizontal_margin + key_horizontal_margin / 2;
+ float keyH = row.height * _config.keyHeight - key_vertical_margin;
for (KeyboardData.Key k : row.keys)
{
x += k.shift * _keyWidth;
- float keyW = _keyWidth * k.width - _config.keyHorizontalInterval;
+ float keyW = _keyWidth * k.width - key_horizontal_margin;
boolean isKeyDown = _pointers.isKeyDown(k);
drawKeyFrame(canvas, x, y, keyW, keyH, isKeyDown);
if (k.keys[0] != null)