Use the same font as elsewhere for keymap dropdown

This commit is contained in:
Johannes Marbach 2021-09-06 21:53:35 +02:00
parent c957d6993b
commit a173c76f38
2 changed files with 18 additions and 5 deletions

View file

@ -101,8 +101,8 @@
**/
static const char * const names =
NAME_ENGLISH_US "\n"
NAME_GERMAN;
LV_SYMBOL_KEYBOARD " " NAME_ENGLISH_US "\n"
LV_SYMBOL_KEYBOARD " " NAME_GERMAN;
static const char ** const keys_lower[] = {
(const char * const [])KEYS_LOWER_ENGLISH_US,

19
main.c
View file

@ -185,10 +185,18 @@ void theme_switcher_event_cb(lv_event_t *e) {
void keymap_dropdown_event_cb(lv_event_t *e);
void keymap_dropdown_event_cb(lv_event_t *e) {
if(lv_event_get_code(e) != LV_EVENT_VALUE_CHANGED) {
return;
switch (lv_event_get_code(e)) {
case LV_EVENT_READY: {
lv_obj_t *list = lv_dropdown_get_list(lv_event_get_target(e));
lv_obj_set_style_text_font(list, &montserrat_extended_32, 0);
break;
}
case LV_EVENT_VALUE_CHANGED:
apply_layout(keyboard, lv_dropdown_get_selected(lv_event_get_target(e)));
break;
default:
break;
}
apply_layout(keyboard, lv_dropdown_get_selected(lv_event_get_target(e)));
}
// Main
@ -373,7 +381,12 @@ int main(void)
// Keymap dropdown
lv_obj_t *dropdown = lv_dropdown_create(lv_scr_act());
lv_dropdown_set_options(dropdown, get_layout_names());
lv_obj_set_width(dropdown, 300);
lv_obj_align(dropdown, LV_ALIGN_TOP_RIGHT, -20, 20);
lv_style_t style_dropdown;
lv_style_init(&style_dropdown);
lv_style_set_text_font(&style_dropdown, &montserrat_extended_32);
lv_obj_add_style(dropdown, &style_dropdown, 0);
lv_obj_add_event_cb(dropdown, keymap_dropdown_event_cb, LV_EVENT_ALL, NULL);
// Run lvgl in tickless mode