Wrap top buttons in grid for easier alignment
This commit is contained in:
parent
b60466cca7
commit
c820a379de
1 changed files with 19 additions and 5 deletions
24
main.c
24
main.c
|
|
@ -360,11 +360,24 @@ int main(void)
|
|||
lv_obj_add_event_cb(keyboard, keyboard_event_cancel_cb, LV_EVENT_CANCEL, NULL);
|
||||
lv_obj_add_event_cb(keyboard, keyboard_event_ready_cb, LV_EVENT_READY, NULL);
|
||||
|
||||
// Button row
|
||||
static lv_coord_t btn_row_col_dsc[] = { 64, 300, LV_GRID_FR(1), LV_GRID_TEMPLATE_LAST };
|
||||
static lv_coord_t btn_row_row_dsc[] = { 64, LV_GRID_TEMPLATE_LAST };
|
||||
lv_obj_t *btn_row = lv_obj_create(lv_scr_act());
|
||||
lv_obj_set_size(btn_row, hor_res, LV_SIZE_CONTENT);
|
||||
lv_obj_align(btn_row, LV_ALIGN_TOP_MID, 0, 0);
|
||||
lv_obj_set_grid_dsc_array(btn_row, btn_row_col_dsc, btn_row_row_dsc);
|
||||
|
||||
// lv_obj_t *btn_row = lv_obj_create(lv_scr_act());
|
||||
// lv_obj_set_size(btn_row, hor_res, LV_SIZE_CONTENT);
|
||||
// lv_obj_align(btn_row, LV_ALIGN_TOP_MID, 0, 0);
|
||||
// lv_obj_set_flex_flow(btn_row, LV_FLEX_FLOW_ROW);
|
||||
|
||||
// Theme switcher
|
||||
lv_obj_t *theme_switcher = lv_btn_create(lv_scr_act());
|
||||
lv_obj_align(theme_switcher, LV_ALIGN_TOP_LEFT, 20, 20);
|
||||
lv_obj_t *theme_switcher = lv_btn_create(btn_row);
|
||||
lv_obj_add_flag(theme_switcher, LV_OBJ_FLAG_CHECKABLE);
|
||||
lv_obj_set_height(theme_switcher, LV_SIZE_CONTENT);
|
||||
lv_obj_set_height(theme_switcher, 64);
|
||||
lv_obj_set_grid_cell(theme_switcher, LV_GRID_ALIGN_CENTER, 0, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
lv_obj_t *theme_switcher_label = lv_label_create(theme_switcher);
|
||||
lv_obj_add_style(theme_switcher_label, &style_text_normal, 0);
|
||||
lv_obj_center(theme_switcher_label);
|
||||
|
|
@ -372,10 +385,11 @@ int main(void)
|
|||
lv_obj_add_event_cb(theme_switcher, theme_switcher_event_cb, LV_EVENT_ALL, NULL);
|
||||
|
||||
// Keymap dropdown
|
||||
lv_obj_t *dropdown = lv_dropdown_create(lv_scr_act());
|
||||
lv_obj_t *dropdown = lv_dropdown_create(btn_row);
|
||||
lv_dropdown_set_options(dropdown, get_layout_names());
|
||||
lv_obj_set_height(dropdown, 64);
|
||||
lv_obj_set_width(dropdown, 300);
|
||||
lv_obj_align(dropdown, LV_ALIGN_TOP_RIGHT, -20, 20);
|
||||
lv_obj_set_grid_cell(dropdown, LV_GRID_ALIGN_CENTER, 1, 1, LV_GRID_ALIGN_CENTER, 0, 1);
|
||||
lv_obj_add_style(dropdown, &style_text_normal, 0);
|
||||
lv_obj_add_event_cb(dropdown, keymap_dropdown_event_cb, LV_EVENT_ALL, NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue