Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
#include "gui.h"
|
|
|
|
#include "gui_i.h"
|
|
|
|
|
|
|
|
#include <flipper.h>
|
2020-10-15 18:56:47 +03:00
|
|
|
#include <flipper_v2.h>
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
#include <m-array.h>
|
2020-10-26 20:00:17 +03:00
|
|
|
#include <stdio.h>
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
|
|
|
|
#include "gui_event.h"
|
|
|
|
#include "canvas.h"
|
|
|
|
#include "canvas_i.h"
|
|
|
|
#include "widget.h"
|
|
|
|
#include "widget_i.h"
|
|
|
|
|
|
|
|
ARRAY_DEF(WidgetArray, Widget*, M_PTR_OPLIST);
|
|
|
|
|
2020-10-15 18:05:28 +03:00
|
|
|
struct Gui {
|
2020-10-16 18:25:06 +03:00
|
|
|
GuiApi api;
|
2020-10-15 18:05:28 +03:00
|
|
|
GuiEvent* event;
|
|
|
|
CanvasApi* canvas_api;
|
2020-10-26 20:00:17 +03:00
|
|
|
WidgetArray_t layers[GuiLayerMAX];
|
|
|
|
osMutexId_t mutex;
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
Widget* gui_widget_find_enabled(WidgetArray_t array) {
|
|
|
|
size_t widgets_count = WidgetArray_size(array);
|
|
|
|
for(size_t i = 0; i < widgets_count; i++) {
|
|
|
|
Widget* widget = *WidgetArray_get(array, widgets_count - i - 1);
|
|
|
|
if(widget_is_enabled(widget)) {
|
|
|
|
return widget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
void gui_update(Gui* gui) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
2020-10-26 20:00:17 +03:00
|
|
|
GuiMessage message;
|
|
|
|
message.type = GuiMessageTypeRedraw;
|
|
|
|
gui_event_messsage_send(gui->event, &message);
|
|
|
|
}
|
|
|
|
|
2020-10-15 18:05:28 +03:00
|
|
|
bool gui_redraw_fs(Gui* gui) {
|
2020-10-29 10:11:16 +03:00
|
|
|
canvas_frame_set(gui->canvas_api, 0, 0, GUI_DISPLAY_WIDTH, GUI_DISPLAY_HEIGHT);
|
2020-10-26 20:00:17 +03:00
|
|
|
Widget* widget = gui_widget_find_enabled(gui->layers[GuiLayerFullscreen]);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
if(widget) {
|
2020-10-15 18:13:18 +03:00
|
|
|
widget_draw(widget, gui->canvas_api);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-29 10:11:16 +03:00
|
|
|
void gui_redraw_status_bar(Gui* gui) {
|
|
|
|
WidgetArray_it_t it;
|
|
|
|
uint8_t x;
|
|
|
|
uint8_t x_used = 0;
|
|
|
|
uint8_t width;
|
|
|
|
Widget* widget;
|
|
|
|
// Right side
|
|
|
|
x = 128;
|
|
|
|
WidgetArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
|
|
|
while(!WidgetArray_end_p(it) && x_used < GUI_STATUS_BAR_WIDTH) {
|
|
|
|
// Render widget;
|
|
|
|
widget = *WidgetArray_ref(it);
|
|
|
|
if(widget_is_enabled(widget)) {
|
|
|
|
width = widget_get_width(widget);
|
|
|
|
if(!width) width = 8;
|
|
|
|
x_used += width;
|
|
|
|
x -= width;
|
|
|
|
canvas_frame_set(gui->canvas_api, x, GUI_STATUS_BAR_Y, width, GUI_STATUS_BAR_HEIGHT);
|
|
|
|
widget_draw(widget, gui->canvas_api);
|
|
|
|
}
|
|
|
|
WidgetArray_next(it);
|
|
|
|
}
|
|
|
|
// Left side
|
|
|
|
x = 0;
|
|
|
|
WidgetArray_it(it, gui->layers[GuiLayerStatusBarLeft]);
|
|
|
|
while(!WidgetArray_end_p(it) && x_used < GUI_STATUS_BAR_WIDTH) {
|
|
|
|
// Render widget;
|
|
|
|
widget = *WidgetArray_ref(it);
|
|
|
|
if(widget_is_enabled(widget)) {
|
|
|
|
width = widget_get_width(widget);
|
|
|
|
if(!width) width = 8;
|
|
|
|
x_used += width;
|
|
|
|
canvas_frame_set(gui->canvas_api, x, GUI_STATUS_BAR_Y, width, GUI_STATUS_BAR_HEIGHT);
|
|
|
|
widget_draw(widget, gui->canvas_api);
|
|
|
|
x += width;
|
|
|
|
}
|
|
|
|
WidgetArray_next(it);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
}
|
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
bool gui_redraw_normal(Gui* gui) {
|
2020-10-29 10:11:16 +03:00
|
|
|
canvas_frame_set(gui->canvas_api, GUI_MAIN_X, GUI_MAIN_Y, GUI_MAIN_WIDTH, GUI_MAIN_HEIGHT);
|
2020-10-26 20:00:17 +03:00
|
|
|
Widget* widget = gui_widget_find_enabled(gui->layers[GuiLayerMain]);
|
|
|
|
if(widget) {
|
|
|
|
widget_draw(widget, gui->canvas_api);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
}
|
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
bool gui_redraw_none(Gui* gui) {
|
2020-10-29 10:11:16 +03:00
|
|
|
canvas_frame_set(gui->canvas_api, GUI_MAIN_X, GUI_MAIN_Y, GUI_MAIN_WIDTH, GUI_MAIN_HEIGHT);
|
2020-10-26 20:00:17 +03:00
|
|
|
Widget* widget = gui_widget_find_enabled(gui->layers[GuiLayerNone]);
|
|
|
|
if(widget) {
|
|
|
|
widget_draw(widget, gui->canvas_api);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
}
|
|
|
|
|
2020-10-15 18:05:28 +03:00
|
|
|
void gui_redraw(Gui* gui) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
2020-10-26 20:00:17 +03:00
|
|
|
gui_lock(gui);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
|
2020-10-29 10:11:16 +03:00
|
|
|
canvas_reset(gui->canvas_api);
|
|
|
|
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
if(!gui_redraw_fs(gui)) {
|
2020-10-26 20:00:17 +03:00
|
|
|
if(!gui_redraw_normal(gui)) {
|
|
|
|
gui_redraw_none(gui);
|
|
|
|
}
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
gui_redraw_status_bar(gui);
|
|
|
|
}
|
|
|
|
|
2020-10-15 18:56:47 +03:00
|
|
|
canvas_commit(gui->canvas_api);
|
2020-10-26 20:00:17 +03:00
|
|
|
gui_unlock(gui);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
}
|
|
|
|
|
2020-10-15 18:05:28 +03:00
|
|
|
void gui_input(Gui* gui, InputEvent* input_event) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
|
|
|
furi_assert(input_event);
|
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
gui_lock(gui);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
Widget* widget = gui_widget_find_enabled(gui->layers[GuiLayerFullscreen]);
|
|
|
|
if(!widget) widget = gui_widget_find_enabled(gui->layers[GuiLayerMain]);
|
|
|
|
if(!widget) widget = gui_widget_find_enabled(gui->layers[GuiLayerNone]);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
|
|
|
|
if(widget) {
|
|
|
|
widget_input(widget, input_event);
|
|
|
|
}
|
2020-10-26 20:00:17 +03:00
|
|
|
|
|
|
|
gui_unlock(gui);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
}
|
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
void gui_lock(Gui* gui) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
|
|
|
furi_check(osMutexAcquire(gui->mutex, osWaitForever) == osOK);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_unlock(Gui* gui) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
|
|
|
furi_check(osMutexRelease(gui->mutex) == osOK);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_add_widget(GuiApi* gui_api, Widget* widget, GuiLayer layer) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui_api);
|
|
|
|
furi_assert(widget);
|
|
|
|
furi_check(layer < GuiLayerMAX);
|
2020-10-26 20:00:17 +03:00
|
|
|
Gui* gui = (Gui*)gui_api;
|
|
|
|
|
|
|
|
gui_lock(gui);
|
|
|
|
WidgetArray_push_back(gui->layers[layer], widget);
|
|
|
|
widget_gui_set(widget, gui);
|
|
|
|
gui_unlock(gui);
|
|
|
|
gui_update(gui);
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_remove_widget(GuiApi* gui_api, Widget* widget) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui_api);
|
|
|
|
furi_assert(widget);
|
2020-10-26 20:00:17 +03:00
|
|
|
Gui* gui = (Gui*)gui_api;
|
|
|
|
|
|
|
|
gui_lock(gui);
|
|
|
|
|
|
|
|
widget_gui_set(widget, NULL);
|
|
|
|
WidgetArray_it_t it;
|
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
|
|
|
WidgetArray_it(it, gui->layers[i]);
|
|
|
|
while(!WidgetArray_end_p(it)) {
|
|
|
|
if(*WidgetArray_ref(it) == widget) {
|
|
|
|
WidgetArray_remove(gui->layers[i], it);
|
|
|
|
}
|
|
|
|
WidgetArray_next(it);
|
|
|
|
}
|
|
|
|
}
|
2020-10-16 18:25:06 +03:00
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
gui_unlock(gui);
|
|
|
|
}
|
2020-10-15 11:32:48 +03:00
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
Gui* gui_alloc() {
|
|
|
|
Gui* gui = furi_alloc(sizeof(Gui));
|
|
|
|
// Set API functions
|
|
|
|
gui->api.add_widget = gui_add_widget;
|
|
|
|
gui->api.remove_widget = gui_remove_widget;
|
|
|
|
// Allocate mutex
|
|
|
|
gui->mutex = osMutexNew(NULL);
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_check(gui->mutex);
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
// Event dispatcher
|
|
|
|
gui->event = gui_event_alloc();
|
2020-10-15 18:05:28 +03:00
|
|
|
// Drawing canvas api
|
2020-10-15 18:13:18 +03:00
|
|
|
gui->canvas_api = canvas_api_init();
|
2020-10-26 20:00:17 +03:00
|
|
|
// Compose Layers
|
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
|
|
|
WidgetArray_init(gui->layers[i]);
|
|
|
|
}
|
2020-10-16 18:25:06 +03:00
|
|
|
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_task(void* p) {
|
2020-10-15 18:05:28 +03:00
|
|
|
Gui* gui = gui_alloc();
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
// Create FURI record
|
2020-10-16 18:25:06 +03:00
|
|
|
if(!furi_create("gui", gui)) {
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
printf("[gui_task] cannot create the gui record\n");
|
|
|
|
furiac_exit(NULL);
|
|
|
|
}
|
2020-10-15 11:32:48 +03:00
|
|
|
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
furiac_ready();
|
2020-10-15 11:32:48 +03:00
|
|
|
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
// Forever dispatch
|
|
|
|
while(1) {
|
2020-10-15 18:05:28 +03:00
|
|
|
GuiMessage message = gui_event_message_next(gui->event);
|
|
|
|
if(message.type == GuiMessageTypeRedraw) {
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
gui_redraw(gui);
|
2020-10-15 18:05:28 +03:00
|
|
|
} else if(message.type == GuiMessageTypeInput) {
|
Display and UI implementation (#169)
* Menu app. Lib: add mlib submodule.
* Menu: new startup lib dependency definition
* Menu: hierarchy in menu. Cube: fix heap1/4 inconsistency, stack protection.
* GUI: rendering pipeline initial version.
* GUI: layered widget composing, FURI record. Menu: FURI record, api.
* GUI: input dispatching. Menu: switch to input from GUI.
* GUI, MENU: code style cleanup, fix type conversion warnings.
* GUI, Menu: syntax check.
* Makefile: check and reinit submodules, format.
* Menu: lock on event processing. Makefile: proper submodule initialization.
* Menu: fix stack corruption by queue.
* GUI: refactor.
* Makefile: format rule fix, st-util pid.
* GUI, Menu, FURI: format with clang-format.
* GUI, MENU: locks in critical sections, fix stack corruption, ready signaling.
* Makefile: clang format rule cleanup.
* GUI,MENU: migrate to new API.
* Applications: PRODUCTION_HW variable, skip drivers build on local target.
* refactor production build
* add git to dockerfile
* GUI: uncomment lock block
Co-authored-by: Aleksandr Kutuzov <aku@plooks.com>
2020-10-14 13:21:55 +03:00
|
|
|
gui_input(gui, &message.input);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|