@@ -19,37 +19,15 @@ constexpr int maxCols = 10;
1919constexpr int defaultPadding = 16 ;
2020constexpr double PI = 3.14159 ;
2121
22- KeypadTheme retroTheme = {
23- ._bg = 0x1e1e1e , // Dark gray background
24- ._key = 0x2d2d2d , // Darker key face
25- ._keyHighlight = 0x3d3d3d ,// Key highlight: medium-dark gray
26- ._text = 0xffffff , // White text
27- ._outline = 0x5e5e5e , // Medium gray outlines
28- ._funcKeyBg = 0x4b0082 , // Dark purple (Indigo)
29- ._funcKeyHighlight = 0x000dad , // Vivid deep blue
30- ._funcText = 0xffffff , // White function key text
31- };
32-
3322KeypadTheme modernDarkTheme = {
34- ._bg = 0x121212 , // Very dark gray background
35- ._key = 0x1f1f1f , // Slightly lighter dark gray keys
36- ._keyHighlight = 0x2c2c2c ,// Highlighted key: a bit lighter
37- ._text = 0xe0e0e0 , // Soft light gray text (was wrongly blue)
38- ._outline = 0x3a3a3a , // Subtle gray outlines
39- ._funcKeyBg = 0x2962ff , // Vibrant Material blue
40- ._funcKeyHighlight = 0x448aff , // Lighter vibrant blue
41- ._funcText = 0xffffff , // White function key text
42- };
43-
44- KeypadTheme modernLightTheme = {
45- ._bg = 0xfafafa , // Very light gray (off-white)
46- ._key = 0xffffff , // White key background
47- ._keyHighlight = 0xe0e0e0 ,// Light gray for pressed keys
48- ._text = 0x212121 , // Dark gray text
49- ._outline = 0xcccccc , // Soft gray outlines (corrected from teal-ish 0x00cccc)
50- ._funcKeyBg = 0x1976d2 , // Material Design blue
51- ._funcKeyHighlight = 0x63a4ff , // Lighter blue highlight
52- ._funcText = 0xffffff , // White text
23+ ._bg = 0x101114 , // Cool dark slate (true dark with a bluish tint)
24+ ._key = 0x1c1e22 , // Cool gray keys
25+ ._keyHighlight = 0x2b2e34 , // Slightly brighter for key press
26+ ._text = 0xe4e6ea , // Icy white-gray text (bluish white)
27+ ._outline = 0x2f3137 , // Subtle cool gray outlines
28+ ._funcKeyBg = 0x8e88aa , // Muted lavender-gray (soft cool purple)
29+ ._funcKeyHighlight = 0xc6c2dc , // Light lavender highlight
30+ ._funcText = 0xffffff , // Crisp white function key text
5331};
5432
5533constexpr RawKey letters[][maxCols] = {
@@ -60,30 +38,22 @@ constexpr RawKey letters[][maxCols] = {
6038 {{K_TOGGLE, K_TOGGLE}, {K_SPACE, K_SPACE}, {K_ENTER, K_ENTER}}
6139};
6240
63- constexpr RawKey numbers[][maxCols] = {
64- {{K_CUT, K_CUT}, {K_COPY, K_COPY}, {K_PASTE, K_PASTE}, {K_SAVE, K_SAVE}, {K_RUN, K_RUN}, {K_HELP, K_HELP}},
65- {{K_1, K_EXCLAIM}, {K_2, K_AT}, {K_3, K_HASH}, {K_4, K_DOLLAR}, {K_5, K_PERCENT}, {K_6, K_CARET}, {K_7, K_AMPERSAND}, {K_8, K_ASTERISK}, {K_9, K_LPAREN}, {K_0, K_RPAREN}},
66- {{K_MINUS, K_UNDERSCORE}, {K_SLASH, K_BACKSLASH}, {K_COLON, K_SEMICOLON}, {K_LPAREN, K_RPAREN}, {K_DOLLAR, K_DOLLAR}, {K_AMPERSAND, K_PIPE}, {K_AT, K_TILDE}, {K_QUOTE, K_APOSTROPHE}, {K_BACKSPACE, K_BACKSPACE}},
67- {{K_TOGGLE, K_TOGGLE}, {K_SPACE, K_SPACE}, {K_ENTER, K_ENTER}}
68- };
69-
7041constexpr RawKey symbols[][maxCols] = {
7142 {{K_CUT, K_CUT}, {K_COPY, K_COPY}, {K_PASTE, K_PASTE}, {K_SAVE, K_SAVE}, {K_RUN, K_RUN}, {K_HELP, K_HELP}},
72- {{K_LBRACKET, K_LBRACE}, {K_RBRACKET, K_RBRACE}, {K_LBRACE, K_LBRACE}, {K_RBRACE, K_RBRACE}, {K_HASH, K_HASH}, {K_PERCENT, K_PERCENT}, {K_CARET, K_CARET}, {K_ASTERISK, K_ASTERISK}, {K_PLUS, K_PLUS}, {K_EQUALS, K_EQUALS}},
73- {{K_UNDERSCORE, K_UNDERSCORE}, {K_BACKSLASH, K_BACKSLASH}, {K_PIPE, K_PIPE}, {K_TILDE, K_TILDE}, {K_LESS, K_LESS}, {K_GREATER, K_GREATER}, {K_BACKTICK, K_BACKTICK}, {K_BACKSPACE, K_BACKSPACE}},
43+ {{K_1, K_EXCLAIM}, {K_2, K_AT}, {K_3, K_HASH}, {K_4, K_DOLLAR}, {K_5, K_PERCENT}, {K_6, K_CARET}, {K_7, K_AMPERSAND}, {K_8, K_ASTERISK}, {K_9, K_LPAREN}, {K_0, K_RPAREN}},
44+ {{K_BACKTICK, K_TILDE}, {K_MINUS, K_UNDERSCORE}, {K_EQUALS, K_PLUS}, {K_LBRACKET, K_LBRACE}, {K_RBRACKET, K_RBRACE}, {K_BACKSLASH, K_PIPE}, {K_SEMICOLON, K_COLON}, {K_LPAREN, K_QUOTE}, {K_RPAREN, K_COMMA}},
45+ {{K_SHIFT, K_SHIFT}, {K_LESS, K_COMMA}, {K_GREATER, K_PERIOD}, {K_QUESTION, K_SLASH}, {K_SEMICOLON, K_COLON}, {K_APOSTROPHE, K_QUOTE}, {K_LBRACKET, K_LBRACE}, {K_RBRACKET, K_RBRACE}, {K_BACKSPACE, K_BACKSPACE}},
7446 {{K_TOGGLE, K_TOGGLE}, {K_SPACE, K_SPACE}, {K_ENTER, K_ENTER}}
7547};
7648
7749constexpr int rowLengths[][5 ] = {
7850 {6 , 10 , 9 , 9 , 3 }, // letters
79- {6 , 10 , 9 , 3 , 0 }, // numbers
80- {6 , 10 , 8 , 3 , 0 }, // symbols
51+ {6 , 10 , 9 , 9 , 3 }, // symbols
8152};
8253
8354constexpr int rowCharLengths[][5 ] = {
84- {6 , 10 , 9 , 16 , 14 },// letters
85- {6 , 10 , 9 , 14 , 0 }, // numbers
86- {6 , 10 , 8 , 14 , 0 }, // symbols
55+ {12 , 10 , 9 , 12 , 14 },// letters
56+ {12 , 10 , 9 , 12 , 14 },// letters
8757};
8858
8959//
@@ -186,8 +156,6 @@ int Key::color(const KeypadTheme *theme, bool shiftActive) const {
186156 result = !_printable ? theme->_funcKeyHighlight : theme->_keyHighlight ;
187157 } else if (_number) {
188158 result = theme->_funcKeyHighlight ;
189- } else if (_printable) {
190- result = theme->_funcKeyHighlight ;
191159 } else {
192160 result = theme->_text ;
193161 }
@@ -212,21 +180,23 @@ void Key::draw(const KeypadTheme *theme, const KeypadDrawContext *context) const
212180 maSetColor (_printable ? theme->_key : theme->_funcKeyBg );
213181 maFillRect (_x, _y, _w, _h);
214182
215- maSetColor (_printable ? theme->_keyHighlight : theme->_funcKeyHighlight );
216-
217- // Draw edges (excluding the rounded corners)
218- maLine (lt, _y + pad, rt, _y + pad); // top edge
219- maLine (_x + pad, vt, _x + pad, bt); // left edge
220- maLine (lt, by, rt, by); // bottom edge
221- maLine (rx, vt, rx, bt); // right edge
222-
223- // Draw rounded corners using arcs (quarter circles)
224- // Arcs: maArc(xc, yc, r, startAngle, endAngle, aspect)
225- double aspect = 1.0 ; // Circle
226- maArc (xcL, ycT, rc, PI, PI * 3 / 2 , aspect); // Top-left corner
227- maArc (xcR, ycT, rc, PI * 3 / 2 , 0 , aspect); // Top-right corner
228- maArc (xcR, ycB, rc, 0 , PI / 2 , aspect); // Bottom-right corner
229- maArc (xcL, ycB, rc, PI / 2 , PI, aspect); // Bottom-left corner
183+ if (_printable || _pressed) {
184+ maSetColor (_printable ? theme->_keyHighlight : theme->_funcKeyHighlight );
185+
186+ // Draw edges (excluding the rounded corners)
187+ maLine (lt, _y + pad, rt, _y + pad); // top edge
188+ maLine (_x + pad, vt, _x + pad, bt); // left edge
189+ maLine (lt, by, rt, by); // bottom edge
190+ maLine (rx, vt, rx, bt); // right edge
191+
192+ // Draw rounded corners using arcs (quarter circles)
193+ // Arcs: maArc(xc, yc, r, startAngle, endAngle, aspect)
194+ double aspect = 1.0 ; // Circle
195+ maArc (xcL, ycT, rc, PI, PI * 3 / 2 , aspect); // Top-left corner
196+ maArc (xcR, ycT, rc, PI * 3 / 2 , 0 , aspect); // Top-right corner
197+ maArc (xcR, ycB, rc, 0 , PI / 2 , aspect); // Bottom-right corner
198+ maArc (xcL, ycB, rc, PI / 2 , PI, aspect); // Bottom-left corner
199+ }
230200
231201 if (_printable) {
232202 bool useShift = context->_shiftActive ^ context->_capsLockActive ;
@@ -320,9 +290,6 @@ void Keypad::generateKeys() {
320290 case LayoutLetters:
321291 activeLayout = letters;
322292 break ;
323- case LayoutNumbers:
324- activeLayout = numbers;
325- break ;
326293 default :
327294 activeLayout = symbols;
328295 break ;
@@ -383,6 +350,9 @@ void Keypad::layout(int x, int y, int w, int h) {
383350 Key *key = _keys[index++];
384351 int length = key->_printable ? 1 : 2 ;
385352 int keyWidth = keyW;
353+ if (key->_key == K_SPACE) {
354+ length = 12 ;
355+ }
386356 if (length > 1 ) {
387357 keyWidth = (length * charWidth) + (padding * 2 );
388358 }
@@ -405,7 +375,7 @@ void Keypad::clicked(int x, int y, bool pressed) {
405375 if (key->_key == K_SHIFT) {
406376 _context.toggleShift ();
407377 } else if (key->_key == K_TOGGLE) {
408- _currentLayout = static_cast <KeypadLayout>((_currentLayout + 1 ) % 3 );
378+ _currentLayout = static_cast <KeypadLayout>((_currentLayout + 1 ) % 2 );
409379 generateKeys ();
410380 layout (_posX, _posY, _width, _height);
411381 break ;
0 commit comments