New GUI/View ASCII input API

This commit is contained in:
Willy-JL
2024-01-17 22:41:28 +00:00
parent cc6805891a
commit 9d877eb59d
16 changed files with 326 additions and 1 deletions
+21
View File
@@ -16,6 +16,7 @@ struct ViewStack {
static void view_stack_draw(Canvas* canvas, void* model);
static bool view_stack_input(InputEvent* event, void* context);
static bool view_stack_ascii(AsciiEvent* event, void* context);
static void view_stack_update_callback(View* view_top_or_bottom, void* context) {
furi_assert(view_top_or_bottom);
@@ -69,6 +70,7 @@ ViewStack* view_stack_alloc(void) {
view_allocate_model(view_stack->view, ViewModelTypeLocking, sizeof(ViewStackModel));
view_set_draw_callback(view_stack->view, view_stack_draw);
view_set_input_callback(view_stack->view, view_stack_input);
view_set_ascii_callback(view_stack->view, view_stack_ascii);
view_set_context(view_stack->view, view_stack);
view_set_enter_callback(view_stack->view, view_stack_enter);
view_set_exit_callback(view_stack->view, view_stack_exit);
@@ -121,6 +123,25 @@ static bool view_stack_input(InputEvent* event, void* context) {
return consumed;
}
static bool view_stack_ascii(AsciiEvent* event, void* context) {
furi_assert(event);
furi_assert(context);
ViewStack* view_stack = context;
bool consumed = false;
ViewStackModel* model = view_get_model(view_stack->view);
for(int i = MAX_VIEWS - 1; i >= 0; i--) {
if(model->views[i] && view_ascii(model->views[i], event)) {
consumed = true;
break;
}
}
view_commit_model(view_stack->view, false);
return consumed;
}
void view_stack_add_view(ViewStack* view_stack, View* view) {
furi_assert(view_stack);
furi_assert(view);