Skip to content

Commit c0221f6

Browse files
committed
UI: re-arranged keypad layout according punctuation frequency
1 parent 6ec9bec commit c0221f6

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

src/ui/keypad.cpp

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ constexpr int IMAGE_SIZE = 30;
2424
constexpr double PI = 3.14159;
2525

2626
// padding size based on character height
27-
constexpr double PADDING_FACTOR = 1.1;
27+
constexpr double PADDING_FACTOR = PLATFORM_PADDING;
2828

2929
// maximum keyboard height as based on screen height
3030
constexpr double MAX_HEIGHT_FACTOR = 0.48;
@@ -78,14 +78,14 @@ constexpr RawKey KEYS[MAX_ROWS][MAX_COLS] = {
7878
},
7979
// ASDF
8080
{
81-
{K_a, K_COMMA, K_SLASH, K_A},
82-
{K_s, K_EQUALS, K_HASH, K_S},
83-
{K_d, K_LPAREN, K_SEMICOLON, K_D},
84-
{K_f, K_RPAREN, K_QUESTION, K_F},
85-
{K_g, K_QUOTE, K_AMPERSAND, K_G},
86-
{K_h, K_APOSTROPHE, K_DOLLAR, K_H},
87-
{K_j, K_PERIOD, K_EXCLAIM, K_J},
88-
{K_k, K_MINUS, K_AT, K_K},
81+
{K_a, K_COMMA, K_HASH, K_A},
82+
{K_s, K_EQUALS, K_SEMICOLON, K_S},
83+
{K_d, K_LPAREN, K_QUESTION, K_D},
84+
{K_f, K_RPAREN, K_AMPERSAND, K_F},
85+
{K_g, K_QUOTE, K_DOLLAR, K_G},
86+
{K_h, K_APOSTROPHE, K_EXCLAIM, K_H},
87+
{K_j, K_PERIOD, K_AT, K_J},
88+
{K_k, K_MINUS, K_SLASH, K_K},
8989
{K_l, K_ASTERISK, K_BACKSLASH, K_L},
9090
{K_NULL}
9191
},
@@ -276,16 +276,17 @@ int Key::color(const KeypadTheme *theme) const {
276276
void Key::draw(const KeypadTheme *theme, const KeypadDrawContext *context, bool pressed) const {
277277
int rc = 5;
278278
int pad = 2;
279+
int pad_rc = pad + rc;
279280
int rx = _x + _w - pad; // right x
280281
int by = _y + _h - pad; // bottom y
281-
int lt = _x + rc + pad; // left x (after corner)
282-
int vt = _y + rc + pad; // top y (after corner)
282+
int lt = _x + pad_rc; // left x (after corner)
283+
int vt = _y + pad_rc; // top y (after corner)
283284
int rt = rx - rc; // right x (before corner)
284285
int bt = by - rc; // bottom y (before corner)
285-
int xcL = _x + rc + pad; // x center for left arcs
286-
int xcR = rx - rc; // x center for right arcs
287-
int ycT = _y + rc + pad; // y center for top arcs
288-
int ycB = by - rc; // y center for bottom arcs
286+
int xcL = _x + pad_rc; // x center for left arcs
287+
int xcR = rx - rc; // x center for right arcs
288+
int ycT = _y + pad_rc; // y center for top arcs
289+
int ycB = by - rc; // y center for bottom arcs
289290

290291
char keyChar = context->getKey(_key);
291292
bool printable = _printable && keyChar != K_TAG;

src/ui/keypad.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ using namespace strlib;
1818
#if defined(_SDL)
1919
// for cursor display
2020
#define HAS_HOVER true
21+
#define PLATFORM_PADDING 0.5
2122
#else
2223
#define HAS_HOVER false
24+
#define PLATFORM_PADDING 1.1
2325
#endif
2426

2527
struct KeypadTheme {

0 commit comments

Comments
 (0)