|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The text keyboard. See ui_textkey.h. More...
#include "ui_textkey.h"#include <stdio.h>#include <string.h>#include "card_tree.h"#include "fm_name.h"#include "ui_text.h"#include "ui_theme.h"#include "ui_widgets.h"Macros | |
| #define | TK_PAD 8 |
| The room around the title, the text and the keys: 8px. | |
| #define | TK_HDR 32 |
| The title row: the 10 x 20 face and 6px above it. | |
| #define | TK_ENTRY_H 52 |
| The text: the 20 x 36 face and 8px above and below. | |
| #define | TK_GAP 6 |
| The gap between the text and the keys, and between keys. | |
| #define | TK_COLS 10 |
| The key grid: 10 columns ... | |
| #define | TK_ROWS 5 |
| ... and 5 rows, the last the bottom row of words. | |
| #define | TK_KEY_PAD 4 |
| The room a key keeps left and right of its label: 4px. | |
| #define | TK_FACES ((int)(sizeof(k_faces) / sizeof(k_faces[0]))) |
| The count of k_faces. | |
Functions | |
| void | ui_textkey_open (ui_textkey_t *k, gfx_rect_t area, const char *title, const char *text, int max_len) |
Open over area on text. | |
| void | ui_textkey_open_search (ui_textkey_t *k, gfx_rect_t area, const char *title, const char *text, int max_len) |
| Open for a search pattern; see the top of this file. | |
| void | ui_textkey_open_folder (ui_textkey_t *k, gfx_rect_t area, const char *title, const char *text) |
| Open for a folder of the card; see the top of this file. Up to UI_TEXTKEY_MAX characters. | |
| void | ui_textkey_open_wifi (ui_textkey_t *k, gfx_rect_t area, const char *title, const char *text, bool secret) |
| Open for a Wi-Fi password or network name; see the top of this file. Lower case first. | |
| void | ui_textkey_open_file (ui_textkey_t *k, gfx_rect_t area, const char *title, const char *text) |
| Open for a file name; see the top of this file. Lower case first. | |
| void | ui_textkey_close (ui_textkey_t *k) |
| Close, dropping a press under way. | |
| void | ui_textkey_cancel_press (ui_textkey_t *k) |
| A press under way is dropped: the touch stream lost an event. What was typed stays typed. | |
| const char * | ui_textkey_label (int key) |
| A key's label as a name keyboard shows it. | |
| const char * | ui_textkey_key_label (const ui_textkey_t *k, int key) |
A key's label as k shows it. | |
| static char | wifi_char (const ui_textkey_t *k, int key) |
| The character a Wi-Fi key types. | |
| gfx_rect_t | ui_textkey_key_rect (const ui_textkey_t *k, int key) |
| Where a key is drawn and hit: the grid ends 8px inside the area, or at UI_KEYS_FOOT (4px above the alert band, body coordinates) where the area reaches further. | |
| static void | add (ui_textkey_t *k, char ch) |
ch after the text, while it is shorter than its most. | |
| static ui_textkey_result_t | press (ui_textkey_t *k, int key, char *out, size_t n) |
Key key pressed and released. | |
| ui_textkey_result_t | ui_textkey_event (ui_textkey_t *k, const touch_event_t *evt, char *out, size_t n) |
| One touch event. | |
| static const char * | folder_why (uint8_t why) |
| Why a folder was refused, in the words of its line. | |
| static const char * | file_why (uint8_t why) |
| Why a file name was refused, in the words of its line. | |
| static const gfx_font_t * | entry_face (gfx_rect_t box) |
The face of the text field: 20 x 36 when UI_TEXTKEY_MAX characters and the caret fit box with 10px each side and the face's height fits it, else 16 x 28. A Wi-Fi text longer than the field shows its end in either. | |
| static bool | is_word (const ui_textkey_t *k, int key) |
Whether key key of k is a word rather than one character: the bottom row, DEL, and the Wi-Fi layer keys (the capitals key types "}" on the marks layer, a character there). | |
| static int | char_face (const ui_textkey_t *k) |
| Where the character keys' face is in k_faces: the first whose cell fits a character key with TK_KEY_PAD on each of its 4 sides. | |
| const gfx_font_t * | ui_textkey_char_font (const ui_textkey_t *k) |
| The face of the character keys: the largest of 20 x 36, 16 x 28, 12 x 24 and 10 x 20 whose cell fits a character key with 4px on each side, else 8 x 16. Over the WI-FI screen's 1008 x 484px a key is 93 x 71px and takes 20 x 36. | |
| const gfx_font_t * | ui_textkey_word_font (const ui_textkey_t *k) |
| The face of the word keys (the bottom row, DEL, and the Wi-Fi layer keys) in the language shown: the largest of 20 x 36, 16 x 28, 12 x 24 and 10 x 20, never larger than ui_textkey_char_font(), in which every one of them fits its key with 4px each side, in every state it can show (SHOW and HIDE, ABC, abc and #+=), so the words of one keyboard share one face and a press does not change it; else 8 x 16. | |
| void | ui_textkey_render (const ui_textkey_t *k, gfx_canvas_t *c) |
| The whole keyboard over its area: the title and the count in 10 x 20 (8 x 16 where they do not fit side by side), the text in 20 x 36 (16 x 28 in a field narrower than UI_TEXTKEY_MAX characters and the caret), the character keys in ui_textkey_char_font() and the word keys in ui_textkey_word_font(). Nothing while it is closed. | |
Variables | |
| static const char | k_chars [UI_TEXTKEY_CHARS+1] |
| The character rows, in reading order; the last is DEL. | |
| static const char | k_wifi [3][UI_TEXTKEY_CHARS+1] |
| The Wi-Fi layers. Key UI_TK_SHIFT and key UI_TK_LAYER switch them and type nothing; a blank ("\0") types nothing either. The marks are the 32 printable ASCII characters that are neither a letter, a digit nor a space, in code order. | |
| static const ui_text_id_t | k_bottom_tx [] |
| The bottom row's texts: SPACE and CANCEL are translated. | |
| static const char *const | k_bottom [] = { NULL, "CLR", NULL, "OK" } |
| The bottom row's legends: CLR and OK, the same in every language. | |
| static const int | k_bottom_span [] = { 4, 2, 2, 2 } |
| How many columns each bottom key spans, for a name. | |
| static const int | k_search_span [] = { 3, 2, 3, 2 } |
| How many columns each bottom key spans, for a search and a Wi-Fi name. | |
| static const int | k_secret_col [] = { 0, 4, 6, 8, 2 } |
| A password's bottom row, in key order SPACE, CLR, CANCEL, OK, SHOW: where each starts, two columns each, SHOW second from the left. | |
| static const gfx_font_t *const | k_faces [] |
| The key faces, largest first: 20 x 36, 16 x 28, 12 x 24, 10 x 20 and 8 x 16. | |
The text keyboard. See ui_textkey.h.
SPDX-License-Identifier: MIT
|
static |
ch after the text, while it is shorter than its most.
| k | The keyboard. |
| ch | The character. |
|
static |
Where the character keys' face is in k_faces: the first whose cell fits a character key with TK_KEY_PAD on each of its 4 sides.
| k | The keyboard. |
|
static |
The face of the text field: 20 x 36 when UI_TEXTKEY_MAX characters and the caret fit box with 10px each side and the face's height fits it, else 16 x 28. A Wi-Fi text longer than the field shows its end in either.
| box | The field. |
|
static |
|
static |
|
static |
Whether key key of k is a word rather than one character: the bottom row, DEL, and the Wi-Fi layer keys (the capitals key types "}" on the marks layer, a character there).
| k | The keyboard. |
| key | The key. |
|
static |
Key key pressed and released.
| k | The keyboard. |
| key | The key. |
| out | Where OK writes what it takes. |
| n | The bytes at out. |
| void ui_textkey_cancel_press | ( | ui_textkey_t * | k | ) |
A press under way is dropped: the touch stream lost an event. What was typed stays typed.
| k | The keyboard; NULL does nothing. |
| const gfx_font_t * ui_textkey_char_font | ( | const ui_textkey_t * | k | ) |
The face of the character keys: the largest of 20 x 36, 16 x 28, 12 x 24 and 10 x 20 whose cell fits a character key with 4px on each side, else 8 x 16. Over the WI-FI screen's 1008 x 484px a key is 93 x 71px and takes 20 x 36.
| k | The keyboard, opened. |
| void ui_textkey_close | ( | ui_textkey_t * | k | ) |
Close, dropping a press under way.
| k | The keyboard; NULL does nothing. |
| ui_textkey_result_t ui_textkey_event | ( | ui_textkey_t * | k, |
| const touch_event_t * | evt, | ||
| char * | out, | ||
| size_t | n ) |
One touch event.
A key acts on the release of the contact that pressed it, over the same key; a second contact is ignored while one is down.
| k | The keyboard. |
| evt | The event, in the keyboard's coordinates. |
| out | Where OK writes the name, ends trimmed; a search's text as typed; a folder in upper case, as card_folder_check() writes it. |
| n | The bytes at out: CARD_DIR_MAX or more for a folder. |
| const char * ui_textkey_key_label | ( | const ui_textkey_t * | k, |
| int | key ) |
A key's label as k shows it.
| k | The keyboard. |
| key | The key. |
| gfx_rect_t ui_textkey_key_rect | ( | const ui_textkey_t * | k, |
| int | key ) |
Where a key is drawn and hit: the grid ends 8px inside the area, or at UI_KEYS_FOOT (4px above the alert band, body coordinates) where the area reaches further.
| k | The keyboard. |
| key | The key: 0 to UI_TK_OK, or UI_TK_SHOW on a password. |
| const char * ui_textkey_label | ( | int | key | ) |
A key's label as a name keyboard shows it.
| key | The key. |
| void ui_textkey_open | ( | ui_textkey_t * | k, |
| gfx_rect_t | area, | ||
| const char * | title, | ||
| const char * | text, | ||
| int | max_len ) |
Open over area on text.
| k | The keyboard; NULL does nothing. |
| area | Where it draws and takes presses. |
| title | What is typed, top left. |
| text | The text it starts with, cut to max_len. |
| max_len | The most characters it takes; 0, less, or more than UI_TEXTKEY_MAX is UI_TEXTKEY_MAX. |
| void ui_textkey_open_file | ( | ui_textkey_t * | k, |
| gfx_rect_t | area, | ||
| const char * | title, | ||
| const char * | text ) |
Open for a file name; see the top of this file. Lower case first.
| k | The keyboard; NULL does nothing. |
| area | Where it draws. |
| title | What is typed. |
| text | The name it starts with, cut to FM_NAME_MAX bytes between two characters. |
| void ui_textkey_open_folder | ( | ui_textkey_t * | k, |
| gfx_rect_t | area, | ||
| const char * | title, | ||
| const char * | text ) |
Open for a folder of the card; see the top of this file. Up to UI_TEXTKEY_MAX characters.
| k | The keyboard; NULL does nothing. |
| area | Where it draws. |
| title | The setting's name. |
| text | The folder in force. |
| void ui_textkey_open_search | ( | ui_textkey_t * | k, |
| gfx_rect_t | area, | ||
| const char * | title, | ||
| const char * | text, | ||
| int | max_len ) |
Open for a search pattern; see the top of this file.
| k | The keyboard; NULL does nothing. |
| area | Where it draws. |
| title | What is searched for. |
| text | The pattern it starts with. |
| max_len | The most characters, as ui_textkey_open() takes it. |
| void ui_textkey_open_wifi | ( | ui_textkey_t * | k, |
| gfx_rect_t | area, | ||
| const char * | title, | ||
| const char * | text, | ||
| bool | secret ) |
Open for a Wi-Fi password or network name; see the top of this file. Lower case first.
| k | The keyboard; NULL does nothing. |
| area | Where it draws. |
| title | What is typed. |
| text | The text it starts with. |
| secret | A password: masked, 8 to 63 characters; else a name of 1 to 32 bytes. |
| void ui_textkey_render | ( | const ui_textkey_t * | k, |
| gfx_canvas_t * | c ) |
The whole keyboard over its area: the title and the count in 10 x 20 (8 x 16 where they do not fit side by side), the text in 20 x 36 (16 x 28 in a field narrower than UI_TEXTKEY_MAX characters and the caret), the character keys in ui_textkey_char_font() and the word keys in ui_textkey_word_font(). Nothing while it is closed.
| k | The keyboard. |
| c | Canvas. |
| const gfx_font_t * ui_textkey_word_font | ( | const ui_textkey_t * | k | ) |
The face of the word keys (the bottom row, DEL, and the Wi-Fi layer keys) in the language shown: the largest of 20 x 36, 16 x 28, 12 x 24 and 10 x 20, never larger than ui_textkey_char_font(), in which every one of them fits its key with 4px each side, in every state it can show (SHOW and HIDE, ABC, abc and #+=), so the words of one keyboard share one face and a press does not change it; else 8 x 16.
| k | The keyboard, opened. |
|
static |
The character a Wi-Fi key types.
| k | The keyboard. |
| key | The key. |
|
static |
The bottom row's texts: SPACE and CANCEL are translated.
|
static |
The character rows, in reading order; the last is DEL.
|
static |
The key faces, largest first: 20 x 36, 16 x 28, 12 x 24, 10 x 20 and 8 x 16.
|
static |
The Wi-Fi layers. Key UI_TK_SHIFT and key UI_TK_LAYER switch them and type nothing; a blank ("\0") types nothing either. The marks are the 32 printable ASCII characters that are neither a letter, a digit nor a space, in code order.