From 635f4ffd59599200437811eb5da2f0311f9831c3 Mon Sep 17 00:00:00 2001 From: DiSlord Date: Mon, 20 Jul 2020 00:55:05 +0300 Subject: [PATCH] Use UI_FUNCTION_ADV_CALLBACK for menu_harmonic More cleanup --- ui.c | 14 ++++++++++++++ ui_sa.c | 49 ++++++++++++------------------------------------- 2 files changed, 26 insertions(+), 37 deletions(-) diff --git a/ui.c b/ui.c index ce05103..2f43c79 100644 --- a/ui.c +++ b/ui.c @@ -1718,6 +1718,13 @@ draw_menu_buttons(const menuitem_t *menu) continue; if (MT_MASK(menu[i].type) == MT_NONE) break; + // Change area update size for form and menu + if (i == 0 && ui_mode == UI_MENU){ + if (menu[i].type & MT_FORM) + area_width = 0; + else + area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; + } button.icon = BUTTON_ICON_NONE; // Border width button.border = MENU_BUTTON_BORDER; @@ -1746,6 +1753,13 @@ draw_menu_buttons(const menuitem_t *menu) menuaction_acb_t cb = (menuaction_acb_t)menu[i].reference; if (cb) (*cb)(i, menu[i].data, &button); } + // Only keypad retrieves value + if (menu[i].type & MT_FORM && MT_MASK(menu[i].type) == MT_KEYPAD) { + keypad_mode = menu[i].data; + fetch_numeric_target(); + button.param_1.text = uistat.text; + } + // Prepare button label plot_printf(button.text, sizeof button.text, menu[i].label, button.param_1.u, button.param_2.u); diff --git a/ui_sa.c b/ui_sa.c index bef7b84..0cc04eb 100644 --- a/ui_sa.c +++ b/ui_sa.c @@ -1089,9 +1089,13 @@ static void choose_active_marker(void) } #ifdef __ULTRA__ -static UI_FUNCTION_CALLBACK(menu_harmonic_cb) +static UI_FUNCTION_ADV_CALLBACK(menu_harmonic_acb) { (void)item; + if(b){ + b->icon = setting.harmonic == data ? BUTTON_ICON_CHECK : BUTTON_ICON_NOCHECK; + return; + } set_harmonic(data); draw_menu(); } @@ -1490,10 +1494,10 @@ static const menuitem_t menu_dfu[] = { #ifdef __ULTRA__ static const menuitem_t menu_harmonic[] = { - { MT_CALLBACK, 2, "2", menu_harmonic_cb}, - { MT_CALLBACK, 3, "3", menu_harmonic_cb}, - { MT_CALLBACK, 4, "4", menu_harmonic_cb}, - { MT_CALLBACK, 5, "5", menu_harmonic_cb}, + { MT_ADV_CALLBACK, 2, "2", menu_harmonic_acb}, + { MT_ADV_CALLBACK, 3, "3", menu_harmonic_acb}, + { MT_ADV_CALLBACK, 4, "4", menu_harmonic_acb}, + { MT_ADV_CALLBACK, 5, "5", menu_harmonic_acb}, { MT_CANCEL, 0, "\032 BACK", NULL }, { MT_NONE, 0, NULL, NULL } // sentinel }; @@ -1721,9 +1725,6 @@ static void fetch_numeric_target(void); static void menu_item_modify_attribute( const menuitem_t *menu, int item, ui_button_t *button) { - int mark = false; - int m_auto = false; - if (menu == menu_mode) { if (item == 4) button->param_1.text = menu_reffer_text[setting.refer+1]; @@ -1736,11 +1737,11 @@ static void menu_item_modify_attribute( button->param_1.text = menu_modulation_text[setting.modulation]; } else if (menu == menu_display /* || menu == menu_displayhigh */) { if (item ==1 && setting.show_stored) - mark = true; + button->icon = BUTTON_ICON_CHECK; if (item == 3 && setting.subtract_stored && setting.show_stored) - mark = true; + button->icon = BUTTON_ICON_CHECK; if (item == 4 && setting.subtract_stored && !setting.show_stored) - mark = true; + button->icon = BUTTON_ICON_CHECK; } else if (menu == menu_settings) { if (item == 2) button->icon = setting.auto_IF ? BUTTON_ICON_CHECK_AUTO : BUTTON_ICON_CHECK_MANUAL; @@ -1755,11 +1756,6 @@ static void menu_item_modify_attribute( button->icon = setting.sweep_time_us != 0 ? BUTTON_ICON_CHECK_MANUAL : BUTTON_ICON_CHECK_AUTO; else if (item == 5) button->icon = setting.fast_speedup != 0 ? BUTTON_ICON_CHECK_MANUAL : BUTTON_ICON_CHECK_AUTO; -#ifdef __ULTRA__ - } else if (MT_MASK(menu[item].type) == MT_CALLBACK && menu == menu_harmonic) { - if (data == setting.harmonic) - mark = true; -#endif } else if (menu == menu_reflevel) { if (item == 1) button->icon = setting.auto_reflevel ? BUTTON_ICON_CHECK_AUTO : BUTTON_ICON_CHECK_MANUAL; @@ -1767,27 +1763,6 @@ static void menu_item_modify_attribute( if (item == 1) button->icon = setting.auto_attenuation ? BUTTON_ICON_CHECK_AUTO : BUTTON_ICON_CHECK_MANUAL; } - // Only keypad retrieves value - if (menu[item].type & MT_FORM && MT_MASK(menu[item].type) == MT_KEYPAD) { - keypad_mode = menu[item].data; - fetch_numeric_target(); - button->param_1.text = uistat.text; - } - - if (m_auto) { - button->icon = BUTTON_ICON_CHECK_AUTO; - } else if (mark) { - button->icon = BUTTON_ICON_CHECK; - } - if (ui_mode == UI_MENU && menu_is_form(menu)) { - // if (item == 0) - // redraw_frame(); - if (item <= 1) { - area_width = 0; - } - }else{ - area_width = AREA_WIDTH_NORMAL - MENU_BUTTON_WIDTH; - } } static void fetch_numeric_target(void)