Add the ability to turn pages in infrared (#2271)
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
75e9de12b0
commit
073fb3861a
@ -178,6 +178,47 @@ static void button_menu_process_down(ButtonMenu* button_menu) {
|
|||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void button_menu_process_right(ButtonMenu* button_menu) {
|
||||||
|
furi_assert(button_menu);
|
||||||
|
|
||||||
|
with_view_model(
|
||||||
|
button_menu->view,
|
||||||
|
ButtonMenuModel * model,
|
||||||
|
{
|
||||||
|
if(ButtonMenuItemArray_size(model->items) > BUTTONS_PER_SCREEN) {
|
||||||
|
size_t position_candidate = model->position + BUTTONS_PER_SCREEN;
|
||||||
|
position_candidate -= position_candidate % BUTTONS_PER_SCREEN;
|
||||||
|
if(position_candidate < (ButtonMenuItemArray_size(model->items))) {
|
||||||
|
model->position = position_candidate;
|
||||||
|
} else {
|
||||||
|
model->position = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void button_menu_process_left(ButtonMenu* button_menu) {
|
||||||
|
furi_assert(button_menu);
|
||||||
|
|
||||||
|
with_view_model(
|
||||||
|
button_menu->view,
|
||||||
|
ButtonMenuModel * model,
|
||||||
|
{
|
||||||
|
if(ButtonMenuItemArray_size(model->items) > BUTTONS_PER_SCREEN) {
|
||||||
|
size_t position_candidate;
|
||||||
|
if(model->position < BUTTONS_PER_SCREEN) {
|
||||||
|
position_candidate = (ButtonMenuItemArray_size(model->items) - 1);
|
||||||
|
} else {
|
||||||
|
position_candidate = model->position - BUTTONS_PER_SCREEN;
|
||||||
|
};
|
||||||
|
position_candidate -= position_candidate % BUTTONS_PER_SCREEN;
|
||||||
|
model->position = position_candidate;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
true);
|
||||||
|
}
|
||||||
|
|
||||||
static void button_menu_process_ok(ButtonMenu* button_menu, InputType type) {
|
static void button_menu_process_ok(ButtonMenu* button_menu, InputType type) {
|
||||||
furi_assert(button_menu);
|
furi_assert(button_menu);
|
||||||
|
|
||||||
@ -239,6 +280,14 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) {
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
button_menu_process_down(button_menu);
|
button_menu_process_down(button_menu);
|
||||||
break;
|
break;
|
||||||
|
case InputKeyRight:
|
||||||
|
consumed = true;
|
||||||
|
button_menu_process_right(button_menu);
|
||||||
|
break;
|
||||||
|
case InputKeyLeft:
|
||||||
|
consumed = true;
|
||||||
|
button_menu_process_left(button_menu);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user