This commit is contained in:
kraus 2021-09-19 22:25:52 +02:00
parent d6d18345b8
commit d16b09fe20
3 changed files with 82 additions and 11 deletions

View File

@ -782,7 +782,7 @@ uint8_t mui_u8g2_u8_opt_line_wa_mse_pi(mui_t *ui, uint8_t msg)
{
*value = 0;
mui_fds_get_nth_token(ui, *value);
}
}
mui_u8g2_draw_button_utf(ui, mui_u8g2_get_draw_button_pi_flags(ui), ui->arg, 1, MUI_U8G2_V_PADDING, ui->text);
//u8g2_DrawButtonUTF8(u8g2, mui_get_x(ui), mui_get_y(ui), mui_u8g2_get_draw_button_pi_flags(ui), ui->arg, 1, MUI_U8G2_V_PADDING, ui->text);
@ -1042,7 +1042,7 @@ uint8_t mui_u8g2_u8_opt_child_mse_common(mui_t *ui, uint8_t msg)
break;
case MUIF_MSG_FORM_START:
/* we can assume that the list starts at the top. It will be adjisted by cursor down events later */
/* ui->form_scroll_top = 0; */ /* done during mui_EnterForm() */
/* ui->form_scroll_top = 0 and all other form_scroll values are set to 0 if a new form is entered in mui_EnterForm() */
if ( ui->form_scroll_visible <= arg )
ui->form_scroll_visible = arg+1;
if ( ui->form_scroll_total == 0 )
@ -1191,21 +1191,21 @@ uint8_t mui_u8g2_u8_opt_radio_child_w1_mse_pi(mui_t *ui, uint8_t msg)
uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
//uint8_t *value = (uint8_t *)muif_get_data(ui->uif);
uint8_t arg = ui->arg; // remember the arg value, because it might be overwritten
switch(msg)
{
case MUIF_MSG_DRAW:
{
u8g2_uint_t w = 0;
//u8g2_uint_t w = 0;
u8g2_uint_t x = mui_get_x(ui); // if mui_GetSelectableFieldTextOption is called, then field vars are overwritten, so get the value
u8g2_uint_t y = mui_get_y(ui); // if mui_GetSelectableFieldTextOption is called, then field vars are overwritten, so get the value
uint8_t flags = 0;
if ( mui_IsCursorFocus(ui) )
{
flags = U8G2_BTN_INV;
}
uint8_t flags = mui_u8g2_get_draw_button_pi_flags(ui);
//if ( mui_IsCursorFocus(ui) )
//{
// flags = U8G2_BTN_INV;
//}
if ( ui->text[0] == '\0' )
{
@ -1215,7 +1215,7 @@ uint8_t mui_u8g2_u8_opt_child_wm_mse_pi(mui_t *ui, uint8_t msg)
}
if ( ui->text[0] != '\0' )
{
u8g2_DrawButtonUTF8(u8g2, x, y, flags, w, 1, 1, ui->text);
u8g2_DrawButtonUTF8(u8g2, x, y, flags, 0, 1, MUI_U8G2_V_PADDING, ui->text);
}
}
break;
@ -1464,3 +1464,31 @@ uint8_t mui_u8g2_u16_list_child_w1_mse_pi(mui_t *ui, uint8_t msg)
}
return 0;
}
uint8_t mui_u8g2_u16_list_goto_w1_mse_pi(mui_t *ui, uint8_t msg)
{
u8g2_t *u8g2 = mui_get_U8g2(ui);
mui_u8g2_list_t *list = (mui_u8g2_list_t *)muif_get_data(ui->uif);
uint16_t *selection = mui_u8g2_list_get_selection_ptr(list);
void *data = mui_u8g2_list_get_data_ptr(list);
mui_u8g2_get_list_element_cb element_cb = mui_u8g2_list_get_element_cb(list);
//mui_u8g2_get_list_count_cb count_cb = mui_u8g2_list_get_count_cb(list);
uint16_t pos = ui->arg; // remember the arg value, because it might be overwritten
pos += ui->form_scroll_top;
switch(msg)
{
case MUIF_MSG_DRAW:
mui_u8g2_draw_button_utf(ui, mui_u8g2_get_draw_button_pi_flags(ui), u8g2_GetDisplayWidth(u8g2), 1, MUI_U8G2_V_PADDING, element_cb(data, pos)+1);
break;
case MUIF_MSG_CURSOR_SELECT:
if ( selection != NULL )
*selection = pos;
mui_GotoForm(ui, (uint8_t)element_cb(data, pos)[0], 0);
break;
default:
return mui_u8g2_u16_list_child_mse_common(ui, msg);
}
return 0;
}

View File

@ -166,6 +166,8 @@ uint8_t mui_u8g2_u16_list_line_wa_mud_pi(mui_t *ui, uint8_t msg);
uint8_t mui_u8g2_u16_list_parent_wm_mse_pi(mui_t *ui, uint8_t msg);
uint8_t mui_u8g2_u16_list_child_w1_mse_pi(mui_t *ui, uint8_t msg);
uint8_t mui_u8g2_u16_list_goto_w1_mse_pi(mui_t *ui, uint8_t msg); /* first char of the string denotes the target form */
#ifdef __cplusplus
}

View File

@ -95,6 +95,7 @@ uint8_t exit_code = 0;
uint16_t list_selection = 0;
uint16_t list_selection2 = 0;
uint16_t list_selection3 = 0;
uint16_t list_selection4 = 0;
uint8_t array_pos = 0;
uint8_t array_led_off_time[4] = { 10, 5, 3, 1};
@ -145,6 +146,33 @@ const char *list_get_str(void *data, uint16_t index)
return animals[index];
}
uint16_t menu_get_cnt(void *data)
{
return 10; /* number of menu entries */
}
const char *menu_get_str(void *data, uint16_t index)
{
static const char *menu[] =
{
MUI_0 "Goto Main Menu",
MUI_10 "Enter a number",
MUI_11 "Parent/Child Selection",
MUI_13 "Checkbox",
MUI_14 "Radio Selection",
MUI_15 "Text Input",
MUI_16 "Single Line Selection",
MUI_17 "List Line Selection",
MUI_18 "Parent/Child List",
MUI_20 "Array Edit",
};
return menu[index];
}
/*
User interface fields list. Each entry is defined with the MUIF macro MUIF(id,cflags,data,cb)
@ -233,6 +261,7 @@ muif_t muif_list[] MUI_PROGMEM = {
MUIF_U8G2_U16_LIST("LP", &list_selection3, NULL, list_get_str, list_get_cnt, mui_u8g2_u16_list_parent_wm_mse_pi),
MUIF_U8G2_U16_LIST("LC", &list_selection3, NULL, list_get_str, list_get_cnt, mui_u8g2_u16_list_child_w1_mse_pi),
MUIF_U8G2_U16_LIST("LG", &list_selection4, NULL, menu_get_str, menu_get_cnt, mui_u8g2_u16_list_goto_w1_mse_pi),
/* MUI_GOTO uses the fixed ".G" id and is intended for goto buttons. This is a full display width style button */
MUIF_GOTO(mui_u8g2_btn_jmp_w1_pi),
@ -246,6 +275,7 @@ muif_t muif_list[] MUI_PROGMEM = {
MUIF_U8G2_U8_MIN_MAX("AF", &led_off_time, 0, 20, mui_u8g2_u8_min_max_wm_mse_pi),
MUIF_U8G2_U8_MIN_MAX("AN", &led_on_time, 0, 20, mui_u8g2_u8_min_max_wm_mse_pi),
/* button for the minimal example */
@ -306,7 +336,18 @@ MUI_STYLE(0)
MUI_GOTO(5,25,17, "List Line Selection")
MUI_GOTO(5,37,18, "Parent/Child List")
MUI_GOTO(5,49,20, "Array Edit")
MUI_GOTO(5,61,0, "Back...")
MUI_GOTO(5,61,3, "Alternative Menu")
MUI_FORM(3)
MUI_STYLE(1)
MUI_LABEL(5,10, "Alternative Menu")
MUI_XY("HR", 0,13)
MUI_STYLE(0)
MUI_XYA("LG", 5, 25, 0)
MUI_XYA("LG", 5, 37, 1)
MUI_XYA("LG", 5, 49, 2)
MUI_XYA("LG", 5, 61, 3)
/* number entry demo */
MUI_FORM(10)