From 9bd6d956ca3ade77ad5738c542fd3c9c5c9494dc Mon Sep 17 00:00:00 2001 From: Daniel <71837281+darmiel@users.noreply.github.com> Date: Sat, 27 Aug 2022 00:44:12 +0200 Subject: [PATCH] fix[infrared]: select first button on remote change --- applications/gui/modules/button_panel.c | 9 +++++++++ applications/gui/modules/button_panel.h | 6 ++++++ .../scenes/common/infrared_scene_universal_common.c | 1 + 3 files changed, 16 insertions(+) diff --git a/applications/gui/modules/button_panel.c b/applications/gui/modules/button_panel.c index e3ae59a36..ff52ebd8c 100644 --- a/applications/gui/modules/button_panel.c +++ b/applications/gui/modules/button_panel.c @@ -83,6 +83,15 @@ ButtonPanel* button_panel_alloc() { return button_panel; } +void button_panel_reset_selection(ButtonPanel* button_panel) { + with_view_model( + button_panel->view, (ButtonPanelModel * model) { + model->selected_item_x = 0; + model->selected_item_y = 0; + return true; + }); +} + void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t reserve_y) { furi_check(reserve_x > 0); furi_check(reserve_y > 0); diff --git a/applications/gui/modules/button_panel.h b/applications/gui/modules/button_panel.h index 0c17e3a7c..9c944ca46 100644 --- a/applications/gui/modules/button_panel.h +++ b/applications/gui/modules/button_panel.h @@ -35,6 +35,12 @@ void button_panel_free(ButtonPanel* button_panel); */ void button_panel_reset(ButtonPanel* button_panel); +/** Resets selected_item_x and selected_item_y. + * + * @param button_panel ButtonPanel instance + */ +void button_panel_reset_selection(ButtonPanel* button_panel); + /** Reserve space for adding items. * * One does not simply use button_panel_add_item() without this function. It diff --git a/applications/infrared/scenes/common/infrared_scene_universal_common.c b/applications/infrared/scenes/common/infrared_scene_universal_common.c index 57ac81168..9f1eabd24 100644 --- a/applications/infrared/scenes/common/infrared_scene_universal_common.c +++ b/applications/infrared/scenes/common/infrared_scene_universal_common.c @@ -33,6 +33,7 @@ static void infrared_scene_universal_common_hide_popup(Infrared* infrared) { void infrared_scene_universal_common_on_enter(void* context) { Infrared* infrared = context; + button_panel_reset_selection(infrared->button_panel); view_stack_add_view(infrared->view_stack, button_panel_get_view(infrared->button_panel)); }