abouttreesummaryrefslogcommitdiff
path: root/srcs/juloo.keyboard2/Keyboard2View.java
diff options
context:
space:
mode:
authorJules Aguillon2024-05-29 11:59:54 +0200
committerGitHub2024-05-29 11:59:54 +0200
commit1a290f96f26b848a217ee5db3d6d5920c7c38a27 (patch)
tree575b7f70c389d6b5ed2fd0e789e2374d5f7ab3bf /srcs/juloo.keyboard2/Keyboard2View.java
parent304375268d520687d41dc7834c442347d638da9c (diff)
downloadunexpected-keyboard-1a290f96f26b848a217ee5db3d6d5920c7c38a27.tar.gz
unexpected-keyboard-1a290f96f26b848a217ee5db3d6d5920c7c38a27.zip
Configure anticircle gesture per-key (#644)
This adds the new 'anticircle' attribute to layouts '<key>' elements that configure the key to send when doing a anti-clockwise circle gesture on it. Labels are drawn the same way as indication. Updated docs.
Diffstat (limited to 'srcs/juloo.keyboard2/Keyboard2View.java')
-rw-r--r--srcs/juloo.keyboard2/Keyboard2View.java37
1 files changed, 26 insertions, 11 deletions
diff --git a/srcs/juloo.keyboard2/Keyboard2View.java b/srcs/juloo.keyboard2/Keyboard2View.java
index 40def60..2eea6ea 100644
--- a/srcs/juloo.keyboard2/Keyboard2View.java
+++ b/srcs/juloo.keyboard2/Keyboard2View.java
@@ -322,10 +322,7 @@ public class Keyboard2View extends View
if (k.keys[i] != null)
drawSubLabel(canvas, k.keys[i], x, y, keyW, keyH, i, isKeyDown);
}
- if (k.indication != null)
- {
- drawIndication(canvas, k.indication, keyW / 2f + x, y, keyH);
- }
+ drawIndication(canvas, k, x, y, keyW, keyH);
x += _keyWidth * k.width;
}
y += row.height * _config.keyHeight;
@@ -443,15 +440,33 @@ public class Keyboard2View extends View
canvas.drawText(label, 0, label_len, x, y, p);
}
- private void drawIndication(Canvas canvas, String indication, float x,
- float y, float keyH)
+ private void drawIndication(Canvas canvas, KeyboardData.Key k, float x,
+ float y, float keyW, float keyH)
{
- float textSize = keyH * _config.sublabelTextSize * _config.characterSize;
- Paint p = _theme.indicationPaint();
+ boolean special_font = false;
+ String indic;
+ float text_size;
+ if (k.indication != null)
+ {
+ indic = k.indication;
+ text_size = keyH * _config.sublabelTextSize * _config.characterSize;
+ }
+ else if (k.anticircle != null)
+ {
+ indic = k.anticircle.getString();
+ special_font = k.anticircle.hasFlagsAny(KeyValue.FLAG_KEY_FONT);
+ text_size = scaleTextSize(k.anticircle, _config.sublabelTextSize, keyH);
+ }
+ else
+ {
+ return;
+ }
+ Paint p = _theme.indicationPaint(special_font);
p.setColor(_theme.subLabelColor);
- p.setTextSize(textSize);
- canvas.drawText(indication, x,
- (keyH - p.ascent() - p.descent()) * 4/5 + y, p);
+ p.setTextSize(text_size);
+ // Limit indication length to 3 characters
+ canvas.drawText(indic, 0, Math.min(indic.length(), 3),
+ x + keyW / 2f, (keyH - p.ascent() - p.descent()) * 4/5 + y, p);
}
private float scaleTextSize(KeyValue k, float rel_size, float keyH)