Use custom colors for keys depending on state
This commit is contained in:
parent
67816664f5
commit
fabde150ce
2 changed files with 35 additions and 1 deletions
|
|
@ -14,6 +14,7 @@ While partially usable, buffyboard currently still is a work in progress.
|
|||
- On-screen keyboard control via mouse, trackpad or touchscreen
|
||||
- Multi-layer keyboard layout including lowercase letters, uppercase letters, numbers and selected symbols (based on top three layers of [squeekboard's US terminal layout])
|
||||
- Key chords with one or more modifiers terminated by a single non-modifier (e.g. `CTRL-c`)
|
||||
- Highlighting of active modifiers
|
||||
|
||||
## To do
|
||||
|
||||
|
|
@ -24,7 +25,6 @@ While partially usable, buffyboard currently still is a work in progress.
|
|||
- Add remaining layers from [squeekboard's US terminal layout] (symbols and actions)
|
||||
- Warn about mismatches between on-screen keyboard layout and terminal keyboard layout
|
||||
- Add [squeekboard's FR terminal layout]
|
||||
- Use better / separate color for active modifiers (currently reuses checked color)
|
||||
- And, and, and ...
|
||||
|
||||
# Development
|
||||
|
|
|
|||
34
main.c
34
main.c
|
|
@ -157,6 +157,39 @@ static void pop_checked_modifier_keys(lv_obj_t *keyboard) {
|
|||
}
|
||||
}
|
||||
|
||||
static void keyboard_draw_part_begin_cb(lv_event_t *event) {
|
||||
lv_obj_t *obj = lv_event_get_target(event);
|
||||
lv_obj_draw_part_dsc_t *dsc = lv_event_get_param(event);
|
||||
|
||||
if (dsc->part != LV_PART_ITEMS) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (lv_btnmatrix_get_selected_btn(obj) == dsc->id) { /* key is held down */
|
||||
if (lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_BTNMATRIX_CTRL_CHECKED)) {
|
||||
if (lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_BTNMATRIX_CTRL_CHECKABLE)) { /* inactive modifiers */
|
||||
dsc->rect_dsc->bg_color = lv_palette_lighten(LV_PALETTE_TEAL, 1);
|
||||
} else { /* non-letters */
|
||||
dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_BLUE_GREY, 3);
|
||||
}
|
||||
} else {
|
||||
if (lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_BTNMATRIX_CTRL_CHECKABLE)) { /* active modifiers */
|
||||
dsc->rect_dsc->bg_color = lv_palette_lighten(LV_PALETTE_TEAL, 1);
|
||||
} else { /* letters */
|
||||
dsc->rect_dsc->bg_color = lv_palette_lighten(LV_PALETTE_BLUE_GREY, 1);
|
||||
}
|
||||
}
|
||||
} else { /* key is not held down */
|
||||
if (lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_BTNMATRIX_CTRL_CHECKED)) { /* inactive modifiers & non-letters */
|
||||
dsc->rect_dsc->bg_color = lv_palette_darken(LV_PALETTE_BLUE_GREY, 4);
|
||||
} else if (lv_btnmatrix_has_btn_ctrl(obj, dsc->id, LV_BTNMATRIX_CTRL_CHECKABLE)) { /* active modifiers */
|
||||
dsc->rect_dsc->bg_color = lv_palette_main(LV_PALETTE_TEAL);
|
||||
} else { /* letters */
|
||||
dsc->rect_dsc->bg_color = lv_palette_main(LV_PALETTE_BLUE_GREY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Main
|
||||
|
|
@ -255,6 +288,7 @@ int main(void)
|
|||
/* Set up keyboard event handlers */
|
||||
lv_obj_remove_event_cb(keyboard, lv_keyboard_def_event_cb);
|
||||
lv_obj_add_event_cb(keyboard, keyboard_value_changed_cb, LV_EVENT_VALUE_CHANGED, NULL);
|
||||
lv_obj_add_event_cb(keyboard, keyboard_draw_part_begin_cb, LV_EVENT_DRAW_PART_BEGIN, NULL);
|
||||
|
||||
/* Apply default keyboard layout */
|
||||
bb_layout_switch_layout(keyboard, SQ2LV_LAYOUT_TERMINAL_US);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue