abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Theme.java
diff options
context:
space:
mode:
authorJules Aguillon2025-05-30 00:08:59 +0200
committerJules Aguillon2025-05-30 20:07:26 +0200
commit2a50a4a129f96784af15f82c0a5d9b09d780dd61 (patch)
tree04b849b0ce6321d31b471cade70e8fde1f9d591a /srcs/juloo.keyboard2/Theme.java
parent9ab099175d8b0548eeeb77cc963dd1c13b9cbaf7 (diff)
downloadunexpected-keyboard-2a50a4a129f96784af15f82c0a5d9b09d780dd61.tar.gz
unexpected-keyboard-2a50a4a129f96784af15f82c0a5d9b09d780dd61.zip
Fix high keyboard height making it overflows
The calculation for the size of each rows now avoid making the keyboard bigger than the screen if the Keyboard Height option is unusually high. The height calculation with the default settings is changed slightly, it is now assuming that a layout is 3.95 rows high instead of 4. This is because the bottom row is usually 0.95% the size of other rows.
Diffstat (limited to 'srcs/juloo.keyboard2/Theme.java')
-rw-r--r--srcs/juloo.keyboard2/Theme.java13
1 files changed, 11 insertions, 2 deletions
diff --git a/srcs/juloo.keyboard2/Theme.java b/srcs/juloo.keyboard2/Theme.java
index c5f3e20..9af0d01 100644
--- a/srcs/juloo.keyboard2/Theme.java
+++ b/srcs/juloo.keyboard2/Theme.java
@@ -94,14 +94,23 @@ public class Theme
public final float horizontal_margin;
public final float margin_top;
public final float margin_left;
+ public final float row_height;
public final Paint indication_paint;
public final Key key;
public final Key key_activated;
- public Computed(Theme theme, Config config, float keyWidth)
+ public Computed(Theme theme, Config config, float keyWidth, KeyboardData layout)
{
- vertical_margin = config.key_vertical_margin * config.keyHeight;
+ // Rows height is proportional to the keyboard height, meaning it doesn't
+ // change for layouts with more or less rows. 3.95 is the usual height of
+ // a layout in KeyboardData unit. The keyboard will be higher if the
+ // layout has more rows and smaller if it has less because rows stay the
+ // same height.
+ row_height = Math.min(
+ config.screenHeightPixels * config.keyboardHeightPercent / 100 / 3.95f,
+ config.screenHeightPixels / layout.keysHeight);
+ vertical_margin = config.key_vertical_margin * row_height;
horizontal_margin = config.key_horizontal_margin * keyWidth;
// Add half of the key margin on the left and on the top as it's also
// added on the right and on the bottom of every keys.