@@ -163,20 +163,20 @@ static void keyboardDrawCommonLines(nbgl_keyboard_t *keyboard)
163
163
rectArea .y0 = keyboard -> obj .area .y0 ;
164
164
rectArea .width = keyboard -> obj .area .width ;
165
165
rectArea .height = 1 ;
166
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor ); // 1st line (top)
166
+ nbgl_frontDrawLine (& rectArea , 1 , keyboard -> borderColor ); // 1st line (top)
167
167
rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
168
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor ); // 2nd line
168
+ nbgl_frontDrawLine (& rectArea , 1 , keyboard -> borderColor ); // 2nd line
169
169
rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
170
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor ); // 3rd line
170
+ nbgl_frontDrawLine (& rectArea , 1 , keyboard -> borderColor ); // 3rd line
171
171
// in letter only mode, only draw the last line if not at bottom of screen
172
172
if ((keyboard -> obj .alignmentMarginY > 0 ) || (!keyboard -> lettersOnly )) {
173
173
rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
174
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor ); // 4th line
174
+ nbgl_frontDrawLine (& rectArea , 1 , keyboard -> borderColor ); // 4th line
175
175
}
176
176
// in non letter only mode, only draw the last line if not at bottom of screen
177
177
if ((keyboard -> obj .alignmentMarginY > 0 ) && (!keyboard -> lettersOnly )) {
178
178
rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
179
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor ); // 5th line
179
+ nbgl_frontDrawLine (& rectArea , 1 , keyboard -> borderColor ); // 5th line
180
180
}
181
181
#ifdef TARGET_STAX
182
182
/// then draw vertical line
@@ -191,8 +191,8 @@ static void keyboardDrawCommonLines(nbgl_keyboard_t *keyboard)
191
191
#endif // TARGET_STAX
192
192
}
193
193
194
- // draw full grid for letters mode
195
- static void keyboardDrawLetterGrid (nbgl_keyboard_t * keyboard )
194
+ // draw full grid
195
+ static void keyboardDrawGrid (nbgl_keyboard_t * keyboard )
196
196
{
197
197
nbgl_area_t rectArea ;
198
198
uint8_t i ;
@@ -206,91 +206,66 @@ static void keyboardDrawLetterGrid(nbgl_keyboard_t *keyboard)
206
206
rectArea .y0 = keyboard -> obj .area .y0 ;
207
207
rectArea .width = 1 ;
208
208
rectArea .height = KEYBOARD_KEY_HEIGHT ;
209
- // First row of keys: 10 letters (qwertyuiop)
209
+ #ifdef TARGET_APEX
210
+ // On Apex, we start all lines 1px under the horizontal one
211
+ rectArea .y0 ++ ;
212
+ rectArea .height -- ;
213
+ #endif
214
+
215
+ // First row of keys: 10 letters (qwertyuiop) or digits, so 9 separations
210
216
for (i = 0 ; i < 9 ; i ++ ) {
211
217
rectArea .x0 += NORMAL_KEY_WIDTH ;
212
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
218
+ nbgl_frontDrawLine (& rectArea , 2 , keyboard -> borderColor );
213
219
}
214
220
215
- // Second row: 9 letters (asdfghjkl)
221
+ // Second row: 9 letters (asdfghjkl) or digits
216
222
rectArea .x0 = keyboard -> obj .area .x0 + SECOND_LINE_OFFSET ;
217
223
rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
218
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
224
+ nbgl_frontDrawLine (& rectArea , 2 , keyboard -> borderColor );
219
225
for (i = 10 ; i < 19 ; i ++ ) {
220
226
rectArea .x0 += NORMAL_KEY_WIDTH ;
221
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
227
+ nbgl_frontDrawLine (& rectArea , 2 , keyboard -> borderColor );
222
228
}
223
- // Third row: Shift key, 7 letters (zxcvbnm) and backspace in normal mode
224
- // Third row: 7 letters (zxcvbnm) and backspace in letters only mode
225
- rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
226
- if (!keyboard -> lettersOnly ) {
227
- rectArea .x0 = keyboard -> obj .area .x0 + SHIFT_KEY_WIDTH ;
229
+
230
+ // Third row, it depends of the mode:
231
+ // - 9 keys: Shift, 7 letters (zxcvbnm) and backspace in normal mode
232
+ // - 8 keys: 7 letters (zxcvbnm) and backspace in letters only mode
233
+ // - 7 keys: Special char key, 5 keys and backspace in digits mode
234
+ uint8_t nbLines , firstShift ;
235
+ if (keyboard -> mode == MODE_LETTERS ) {
236
+ if (keyboard -> lettersOnly ) {
237
+ nbLines = 7 ;
238
+ firstShift = NORMAL_KEY_WIDTH ;
239
+ }
240
+ else {
241
+ nbLines = 8 ;
242
+ firstShift = SHIFT_KEY_WIDTH ;
243
+ }
228
244
}
229
245
else {
230
- rectArea .x0 = NORMAL_KEY_WIDTH ;
231
- }
232
- for (i = 0 ; i < 6 ; i ++ ) {
233
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
234
- rectArea .x0 += NORMAL_KEY_WIDTH ;
246
+ nbLines = 6 ;
247
+ firstShift = SPECIAL_CHARS_KEY_WIDTH ;
235
248
}
236
- if (!keyboard -> lettersOnly ) {
237
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
249
+ rectArea .x0 = keyboard -> obj .area .x0 + firstShift ;
250
+ rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
251
+ for (i = 0 ; i < nbLines ; i ++ ) {
252
+ nbgl_frontDrawLine (& rectArea , 2 , keyboard -> borderColor );
238
253
rectArea .x0 += NORMAL_KEY_WIDTH ;
239
254
}
240
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
241
255
242
256
// 4th row, only in Full mode
243
- if (!keyboard -> lettersOnly ) {
244
- rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
257
+ if (!keyboard -> lettersOnly || (keyboard -> mode != MODE_LETTERS )) {
245
258
rectArea .x0 = keyboard -> obj .area .x0 + SWITCH_KEY_WIDTH ;
259
+ rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
260
+ #ifdef TARGET_APEX
261
+ // On Apex, we start the last line 2px under the horizontal one
262
+ rectArea .y0 += 2 ;
263
+ rectArea .height -= 2 ;
264
+ #endif
246
265
nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
247
266
}
248
267
}
249
268
250
- // draw full grid for digits/special mode
251
- static void keyboardDrawDigitsGrid (nbgl_keyboard_t * keyboard )
252
- {
253
- nbgl_area_t rectArea ;
254
- uint8_t i ;
255
-
256
- /// draw common lines
257
- keyboardDrawCommonLines (keyboard );
258
-
259
- // then all vertical lines separating keys
260
- rectArea .backgroundColor = keyboard -> obj .area .backgroundColor ;
261
- rectArea .x0 = keyboard -> obj .area .x0 ;
262
- rectArea .y0 = keyboard -> obj .area .y0 ;
263
- rectArea .width = 1 ;
264
- rectArea .height = KEYBOARD_KEY_HEIGHT ;
265
- // First row of keys: 10 keys so 9 separations
266
- for (i = 0 ; i < 9 ; i ++ ) {
267
- rectArea .x0 += NORMAL_KEY_WIDTH ;
268
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
269
- }
270
-
271
- // Second row: 9 keys
272
- rectArea .x0 = keyboard -> obj .area .x0 + SECOND_LINE_OFFSET ;
273
- rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
274
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
275
- for (i = 10 ; i < 19 ; i ++ ) {
276
- rectArea .x0 += NORMAL_KEY_WIDTH ;
277
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
278
- }
279
- // Third row: Special char key, 5 keys and backspace
280
- rectArea .x0 = keyboard -> obj .area .x0 + SPECIAL_CHARS_KEY_WIDTH ;
281
- rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
282
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
283
- for (i = 0 ; i < 5 ; i ++ ) {
284
- rectArea .x0 += NORMAL_KEY_WIDTH ;
285
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
286
- }
287
-
288
- // 4th row, switch to letters and space
289
- rectArea .y0 += KEYBOARD_KEY_HEIGHT ;
290
- rectArea .x0 = keyboard -> obj .area .x0 + SWITCH_KEY_WIDTH ;
291
- nbgl_frontDrawLine (& rectArea , 0 , keyboard -> borderColor );
292
- }
293
-
294
269
// draw letters for letters mode
295
270
static void keyboardDrawLetters (nbgl_keyboard_t * keyboard )
296
271
{
@@ -525,17 +500,13 @@ static void keyboardDrawDigits(nbgl_keyboard_t *keyboard)
525
500
526
501
static void keyboardDraw (nbgl_keyboard_t * keyboard )
527
502
{
503
+ // At first, draw grid
504
+ keyboardDrawGrid (keyboard );
528
505
if (keyboard -> mode == MODE_LETTERS ) {
529
- // At first, draw grid
530
- keyboardDrawLetterGrid (keyboard );
531
-
532
506
// then draw key content
533
507
keyboardDrawLetters (keyboard );
534
508
}
535
509
else {
536
- ////// At first, draw grid //////
537
- keyboardDrawDigitsGrid (keyboard );
538
-
539
510
////// then draw key content //////
540
511
keyboardDrawDigits (keyboard );
541
512
}
0 commit comments