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_i.h"
|
2022-10-28 17:08:50 +03:00
|
|
|
#include <assets_icons.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
|
|
|
|
2021-11-12 16:04:35 +03:00
|
|
|
#define TAG "GuiSrv"
|
|
|
|
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPort* gui_view_port_find_enabled(ViewPortArray_t array) {
|
2021-02-10 12:06:29 +03:00
|
|
|
// Iterating backward
|
|
|
|
ViewPortArray_it_t it;
|
|
|
|
ViewPortArray_it_last(it, array);
|
|
|
|
while(!ViewPortArray_end_p(it)) {
|
|
|
|
ViewPort* view_port = *ViewPortArray_ref(it);
|
2021-01-29 16:52:16 +03:00
|
|
|
if(view_port_is_enabled(view_port)) {
|
|
|
|
return view_port;
|
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
|
|
|
}
|
2021-02-10 12:06:29 +03:00
|
|
|
ViewPortArray_previous(it);
|
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 NULL;
|
|
|
|
}
|
|
|
|
|
2023-08-10 19:10:15 +03:00
|
|
|
size_t gui_active_view_port_count(Gui* gui, GuiLayer layer) {
|
|
|
|
furi_assert(gui);
|
|
|
|
furi_check(layer < GuiLayerMAX);
|
|
|
|
size_t ret = 0;
|
|
|
|
|
|
|
|
gui_lock(gui);
|
|
|
|
ViewPortArray_it_t it;
|
|
|
|
ViewPortArray_it_last(it, gui->layers[layer]);
|
|
|
|
while(!ViewPortArray_end_p(it)) {
|
|
|
|
ViewPort* view_port = *ViewPortArray_ref(it);
|
|
|
|
if(view_port_is_enabled(view_port)) {
|
|
|
|
ret++;
|
|
|
|
}
|
|
|
|
ViewPortArray_previous(it);
|
|
|
|
}
|
|
|
|
gui_unlock(gui);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-02-15 02:46:59 +03:00
|
|
|
void gui_update(Gui* gui) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
2022-12-29 14:35:26 +03:00
|
|
|
if(!gui->direct_draw) furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_DRAW);
|
2021-02-10 12:06:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_input_events_callback(const void* value, void* ctx) {
|
|
|
|
furi_assert(value);
|
|
|
|
furi_assert(ctx);
|
|
|
|
|
|
|
|
Gui* gui = ctx;
|
|
|
|
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_message_queue_put(gui->input_queue, value, FuriWaitForever);
|
2022-06-20 17:54:48 +03:00
|
|
|
furi_thread_flags_set(gui->thread_id, GUI_THREAD_FLAG_INPUT);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
|
2021-05-19 12:43:15 +03:00
|
|
|
// Only Fullscreen supports vertical display for now
|
2022-12-29 14:35:26 +03:00
|
|
|
static bool gui_redraw_fs(Gui* gui) {
|
2021-09-02 00:05:00 +03:00
|
|
|
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontal);
|
|
|
|
canvas_frame_set(gui->canvas, 0, 0, GUI_DISPLAY_WIDTH, GUI_DISPLAY_HEIGHT);
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]);
|
|
|
|
if(view_port) {
|
|
|
|
view_port_draw(view_port, gui->canvas);
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-29 14:20:55 +03:00
|
|
|
static void gui_redraw_status_bar(Gui* gui, bool need_attention) {
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_it_t it;
|
2022-05-06 20:35:52 +03:00
|
|
|
uint8_t left_used = 0;
|
|
|
|
uint8_t right_used = 0;
|
2020-10-29 10:11:16 +03:00
|
|
|
uint8_t width;
|
2023-03-09 20:13:18 +03:00
|
|
|
|
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagHandOrient)) {
|
|
|
|
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontalFlip);
|
|
|
|
} else {
|
|
|
|
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontal);
|
|
|
|
}
|
|
|
|
|
2021-03-25 20:48:58 +03:00
|
|
|
canvas_frame_set(
|
|
|
|
gui->canvas, GUI_STATUS_BAR_X, GUI_STATUS_BAR_Y, GUI_DISPLAY_WIDTH, GUI_STATUS_BAR_HEIGHT);
|
2021-11-26 15:19:30 +03:00
|
|
|
|
|
|
|
/* for support black theme - paint white area and
|
|
|
|
* draw icon with transparent white color
|
|
|
|
*/
|
|
|
|
canvas_set_color(gui->canvas, ColorWhite);
|
|
|
|
canvas_draw_box(gui->canvas, 1, 1, 9, 7);
|
|
|
|
canvas_draw_box(gui->canvas, 7, 3, 58, 6);
|
|
|
|
canvas_draw_box(gui->canvas, 61, 1, 32, 7);
|
|
|
|
canvas_draw_box(gui->canvas, 89, 3, 38, 6);
|
|
|
|
canvas_set_color(gui->canvas, ColorBlack);
|
|
|
|
canvas_set_bitmap_mode(gui->canvas, 1);
|
2021-07-07 11:57:49 +03:00
|
|
|
canvas_draw_icon(gui->canvas, 0, 0, &I_Background_128x11);
|
2021-11-26 15:19:30 +03:00
|
|
|
canvas_set_bitmap_mode(gui->canvas, 0);
|
2021-03-25 20:48:58 +03:00
|
|
|
|
2020-10-29 10:11:16 +03:00
|
|
|
// Right side
|
2022-05-06 20:35:52 +03:00
|
|
|
uint8_t x = GUI_DISPLAY_WIDTH - 1;
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarRight]);
|
2022-05-06 20:35:52 +03:00
|
|
|
while(!ViewPortArray_end_p(it) && right_used < GUI_STATUS_BAR_WIDTH) {
|
|
|
|
ViewPort* view_port = *ViewPortArray_ref(it);
|
2021-01-29 16:52:16 +03:00
|
|
|
if(view_port_is_enabled(view_port)) {
|
|
|
|
width = view_port_get_width(view_port);
|
2020-10-29 10:11:16 +03:00
|
|
|
if(!width) width = 8;
|
2022-05-06 20:35:52 +03:00
|
|
|
// Recalculate next position
|
|
|
|
right_used += (width + 2);
|
2020-12-14 13:50:32 +03:00
|
|
|
x -= (width + 2);
|
2022-05-06 20:35:52 +03:00
|
|
|
// Prepare work area background
|
2021-11-26 15:19:30 +03:00
|
|
|
canvas_frame_set(
|
2022-05-06 20:35:52 +03:00
|
|
|
gui->canvas,
|
|
|
|
x - 1,
|
|
|
|
GUI_STATUS_BAR_Y + 1,
|
|
|
|
width + 2,
|
|
|
|
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
2021-03-25 20:48:58 +03:00
|
|
|
canvas_set_color(gui->canvas, ColorWhite);
|
2022-05-06 20:35:52 +03:00
|
|
|
canvas_draw_box(
|
|
|
|
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas));
|
2021-03-25 20:48:58 +03:00
|
|
|
canvas_set_color(gui->canvas, ColorBlack);
|
2022-05-06 20:35:52 +03:00
|
|
|
// ViewPort draw
|
2021-11-24 21:19:34 +03:00
|
|
|
canvas_frame_set(
|
2022-05-06 20:35:52 +03:00
|
|
|
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
2021-01-29 16:52:16 +03:00
|
|
|
view_port_draw(view_port, gui->canvas);
|
2020-10-29 10:11:16 +03:00
|
|
|
}
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_next(it);
|
2020-10-29 10:11:16 +03:00
|
|
|
}
|
2022-05-06 20:35:52 +03:00
|
|
|
// Draw frame around icons on the right
|
|
|
|
if(right_used) {
|
|
|
|
canvas_frame_set(
|
|
|
|
gui->canvas,
|
|
|
|
GUI_DISPLAY_WIDTH - 3 - right_used,
|
|
|
|
GUI_STATUS_BAR_Y,
|
|
|
|
right_used + 3,
|
|
|
|
GUI_STATUS_BAR_HEIGHT);
|
|
|
|
canvas_set_color(gui->canvas, ColorBlack);
|
|
|
|
canvas_draw_rframe(
|
|
|
|
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
|
|
|
canvas_draw_line(
|
|
|
|
gui->canvas,
|
|
|
|
canvas_width(gui->canvas) - 2,
|
|
|
|
1,
|
|
|
|
canvas_width(gui->canvas) - 2,
|
|
|
|
canvas_height(gui->canvas) - 2);
|
|
|
|
canvas_draw_line(
|
|
|
|
gui->canvas,
|
|
|
|
1,
|
|
|
|
canvas_height(gui->canvas) - 2,
|
|
|
|
canvas_width(gui->canvas) - 2,
|
|
|
|
canvas_height(gui->canvas) - 2);
|
|
|
|
}
|
|
|
|
|
2020-10-29 10:11:16 +03:00
|
|
|
// Left side
|
2022-05-06 20:35:52 +03:00
|
|
|
x = 2;
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_it(it, gui->layers[GuiLayerStatusBarLeft]);
|
2022-05-06 20:35:52 +03:00
|
|
|
while(!ViewPortArray_end_p(it) && (right_used + left_used) < GUI_STATUS_BAR_WIDTH) {
|
|
|
|
ViewPort* view_port = *ViewPortArray_ref(it);
|
2021-01-29 16:52:16 +03:00
|
|
|
if(view_port_is_enabled(view_port)) {
|
|
|
|
width = view_port_get_width(view_port);
|
2020-10-29 10:11:16 +03:00
|
|
|
if(!width) width = 8;
|
2022-05-06 20:35:52 +03:00
|
|
|
// Prepare work area background
|
2021-11-26 15:19:30 +03:00
|
|
|
canvas_frame_set(
|
|
|
|
gui->canvas,
|
2022-05-06 20:35:52 +03:00
|
|
|
x - 1,
|
|
|
|
GUI_STATUS_BAR_Y + 1,
|
|
|
|
width + 2,
|
|
|
|
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
2021-03-25 20:48:58 +03:00
|
|
|
canvas_set_color(gui->canvas, ColorWhite);
|
2022-05-06 20:35:52 +03:00
|
|
|
canvas_draw_box(
|
|
|
|
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas));
|
2021-03-25 20:48:58 +03:00
|
|
|
canvas_set_color(gui->canvas, ColorBlack);
|
2022-05-06 20:35:52 +03:00
|
|
|
// ViewPort draw
|
2021-03-25 20:48:58 +03:00
|
|
|
canvas_frame_set(
|
2022-05-06 20:35:52 +03:00
|
|
|
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
2021-01-29 16:52:16 +03:00
|
|
|
view_port_draw(view_port, gui->canvas);
|
2022-05-06 20:35:52 +03:00
|
|
|
// Recalculate next position
|
|
|
|
left_used += (width + 2);
|
2020-12-14 13:50:32 +03:00
|
|
|
x += (width + 2);
|
2020-10-29 10:11:16 +03:00
|
|
|
}
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_next(it);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
2022-05-06 20:35:52 +03:00
|
|
|
// Extra notification
|
2022-01-29 14:20:55 +03:00
|
|
|
if(need_attention) {
|
2022-10-22 18:21:10 +03:00
|
|
|
width = icon_get_width(&I_Hidden_window_9x8);
|
2022-05-06 20:35:52 +03:00
|
|
|
// Prepare work area background
|
|
|
|
canvas_frame_set(
|
|
|
|
gui->canvas,
|
|
|
|
x - 1,
|
|
|
|
GUI_STATUS_BAR_Y + 1,
|
|
|
|
width + 2,
|
|
|
|
GUI_STATUS_BAR_WORKAREA_HEIGHT + 2);
|
|
|
|
canvas_set_color(gui->canvas, ColorWhite);
|
|
|
|
canvas_draw_box(gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas));
|
|
|
|
canvas_set_color(gui->canvas, ColorBlack);
|
|
|
|
// Draw Icon
|
|
|
|
canvas_frame_set(
|
|
|
|
gui->canvas, x, GUI_STATUS_BAR_Y + 2, width, GUI_STATUS_BAR_WORKAREA_HEIGHT);
|
2022-10-22 18:21:10 +03:00
|
|
|
canvas_draw_icon(gui->canvas, 0, 0, &I_Hidden_window_9x8);
|
2022-05-06 20:35:52 +03:00
|
|
|
// Recalculate next position
|
|
|
|
left_used += (width + 2);
|
|
|
|
x += (width + 2);
|
|
|
|
}
|
|
|
|
// Draw frame around icons on the left
|
|
|
|
if(left_used) {
|
|
|
|
canvas_frame_set(gui->canvas, 0, 0, left_used + 3, GUI_STATUS_BAR_HEIGHT);
|
2022-01-29 14:20:55 +03:00
|
|
|
canvas_draw_rframe(
|
|
|
|
gui->canvas, 0, 0, canvas_width(gui->canvas), canvas_height(gui->canvas), 1);
|
|
|
|
canvas_draw_line(
|
|
|
|
gui->canvas,
|
2022-05-06 20:35:52 +03:00
|
|
|
canvas_width(gui->canvas) - 2,
|
|
|
|
1,
|
|
|
|
canvas_width(gui->canvas) - 2,
|
|
|
|
canvas_height(gui->canvas) - 2);
|
|
|
|
canvas_draw_line(
|
|
|
|
gui->canvas,
|
|
|
|
1,
|
2022-01-29 14:20:55 +03:00
|
|
|
canvas_height(gui->canvas) - 2,
|
|
|
|
canvas_width(gui->canvas) - 2,
|
|
|
|
canvas_height(gui->canvas) - 2);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
static bool gui_redraw_window(Gui* gui) {
|
2021-05-19 12:43:15 +03:00
|
|
|
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontal);
|
2021-11-24 19:21:12 +03:00
|
|
|
canvas_frame_set(gui->canvas, GUI_WINDOW_X, GUI_WINDOW_Y, GUI_WINDOW_WIDTH, GUI_WINDOW_HEIGHT);
|
|
|
|
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]);
|
2021-01-29 16:52:16 +03:00
|
|
|
if(view_port) {
|
|
|
|
view_port_draw(view_port, gui->canvas);
|
2020-10-26 20:00:17 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
static bool gui_redraw_desktop(Gui* gui) {
|
2021-05-19 12:43:15 +03:00
|
|
|
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontal);
|
2021-11-26 15:19:30 +03:00
|
|
|
canvas_frame_set(gui->canvas, 0, 0, GUI_DISPLAY_WIDTH, GUI_DISPLAY_HEIGHT);
|
2021-11-24 19:21:12 +03:00
|
|
|
ViewPort* view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]);
|
2021-01-29 16:52:16 +03:00
|
|
|
if(view_port) {
|
|
|
|
view_port_draw(view_port, gui->canvas);
|
2020-10-26 20:00:17 +03:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
static 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
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
do {
|
|
|
|
if(gui->direct_draw) break;
|
|
|
|
|
|
|
|
canvas_reset(gui->canvas);
|
|
|
|
|
|
|
|
if(gui->lockdown) {
|
|
|
|
gui_redraw_desktop(gui);
|
|
|
|
bool need_attention =
|
|
|
|
(gui_view_port_find_enabled(gui->layers[GuiLayerWindow]) != 0 ||
|
|
|
|
gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]) != 0);
|
|
|
|
gui_redraw_status_bar(gui, need_attention);
|
|
|
|
} else {
|
|
|
|
if(!gui_redraw_fs(gui)) {
|
|
|
|
if(!gui_redraw_window(gui)) {
|
|
|
|
gui_redraw_desktop(gui);
|
|
|
|
}
|
|
|
|
gui_redraw_status_bar(gui, false);
|
2022-01-29 14:20:55 +03:00
|
|
|
}
|
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
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
canvas_commit(gui->canvas);
|
|
|
|
} while(false);
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
static void gui_input(Gui* gui, InputEvent* input_event) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
|
|
|
furi_assert(input_event);
|
|
|
|
|
2021-08-31 11:22:52 +03:00
|
|
|
// Check input complementarity
|
|
|
|
uint8_t key_bit = (1 << input_event->key);
|
|
|
|
if(input_event->type == InputTypeRelease) {
|
|
|
|
gui->ongoing_input &= ~key_bit;
|
|
|
|
} else if(input_event->type == InputTypePress) {
|
|
|
|
gui->ongoing_input |= key_bit;
|
|
|
|
} else if(!(gui->ongoing_input & key_bit)) {
|
2021-11-04 20:26:41 +03:00
|
|
|
FURI_LOG_D(
|
2021-11-12 16:04:35 +03:00
|
|
|
TAG,
|
2021-09-02 00:05:00 +03:00
|
|
|
"non-complementary input, discarding key: %s type: %s, sequence: %p",
|
2021-08-31 11:22:52 +03:00
|
|
|
input_get_key_name(input_event->key),
|
2021-09-02 00:05:00 +03:00
|
|
|
input_get_type_name(input_event->type),
|
2022-10-07 16:35:15 +03:00
|
|
|
(void*)input_event->sequence);
|
2021-08-31 11:22:52 +03:00
|
|
|
return;
|
|
|
|
}
|
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
|
|
|
|
2021-08-31 11:22:52 +03:00
|
|
|
gui_lock(gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
do {
|
|
|
|
if(gui->direct_draw && !gui->ongoing_input_view_port) {
|
|
|
|
break;
|
|
|
|
}
|
2022-01-29 14:20:55 +03:00
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
ViewPort* view_port = NULL;
|
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
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
if(gui->lockdown) {
|
|
|
|
view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]);
|
|
|
|
} else {
|
|
|
|
view_port = gui_view_port_find_enabled(gui->layers[GuiLayerFullscreen]);
|
|
|
|
if(!view_port) view_port = gui_view_port_find_enabled(gui->layers[GuiLayerWindow]);
|
|
|
|
if(!view_port) view_port = gui_view_port_find_enabled(gui->layers[GuiLayerDesktop]);
|
|
|
|
}
|
2021-08-31 11:22:52 +03:00
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
if(!(gui->ongoing_input & ~key_bit) && input_event->type == InputTypePress) {
|
|
|
|
gui->ongoing_input_view_port = view_port;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(view_port && view_port == gui->ongoing_input_view_port) {
|
|
|
|
view_port_input(view_port, input_event);
|
|
|
|
} else if(gui->ongoing_input_view_port && input_event->type == InputTypeRelease) {
|
|
|
|
FURI_LOG_D(
|
|
|
|
TAG,
|
|
|
|
"ViewPort changed while key press %p -> %p. Sending key: %s, type: %s, sequence: %p to previous view port",
|
|
|
|
gui->ongoing_input_view_port,
|
|
|
|
view_port,
|
|
|
|
input_get_key_name(input_event->key),
|
|
|
|
input_get_type_name(input_event->type),
|
|
|
|
(void*)input_event->sequence);
|
|
|
|
view_port_input(gui->ongoing_input_view_port, input_event);
|
|
|
|
} else {
|
|
|
|
FURI_LOG_D(
|
|
|
|
TAG,
|
|
|
|
"ViewPort changed while key press %p -> %p. Discarding key: %s, type: %s, sequence: %p",
|
|
|
|
gui->ongoing_input_view_port,
|
|
|
|
view_port,
|
|
|
|
input_get_key_name(input_event->key),
|
|
|
|
input_get_type_name(input_event->type),
|
|
|
|
(void*)input_event->sequence);
|
|
|
|
}
|
|
|
|
} while(false);
|
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);
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_check(furi_mutex_acquire(gui->mutex, FuriWaitForever) == FuriStatusOk);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void gui_unlock(Gui* gui) {
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_assert(gui);
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_check(furi_mutex_release(gui->mutex) == FuriStatusOk);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
|
2021-01-29 16:52:16 +03:00
|
|
|
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
|
|
|
furi_check(view_port);
|
2020-10-29 09:27:17 +03:00
|
|
|
furi_check(layer < GuiLayerMAX);
|
2024-03-19 17:43:52 +03:00
|
|
|
|
2021-05-19 12:43:15 +03:00
|
|
|
// Only fullscreen supports Vertical orientation for now
|
2023-09-01 04:54:52 +03:00
|
|
|
ViewPortOrientation view_port_orientation = view_port_get_orientation(view_port);
|
|
|
|
furi_check(
|
2022-10-26 21:35:49 +03:00
|
|
|
(layer == GuiLayerFullscreen) ||
|
2023-09-01 04:54:52 +03:00
|
|
|
((view_port_orientation != ViewPortOrientationVertical) &&
|
|
|
|
(view_port_orientation != ViewPortOrientationVerticalFlip)));
|
2020-10-26 20:00:17 +03:00
|
|
|
|
|
|
|
gui_lock(gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
// Verify that view port is not yet added
|
|
|
|
ViewPortArray_it_t it;
|
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
|
|
|
ViewPortArray_it(it, gui->layers[i]);
|
|
|
|
while(!ViewPortArray_end_p(it)) {
|
|
|
|
furi_assert(*ViewPortArray_ref(it) != view_port);
|
|
|
|
ViewPortArray_next(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Add view port and link with gui
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_push_back(gui->layers[layer], view_port);
|
|
|
|
view_port_gui_set(view_port, gui);
|
2020-10-26 20:00:17 +03:00
|
|
|
gui_unlock(gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
|
2022-04-18 01:29:45 +03:00
|
|
|
// Request redraw
|
2021-02-15 02:46:59 +03:00
|
|
|
gui_update(gui);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
|
2021-01-29 16:52:16 +03:00
|
|
|
void gui_remove_view_port(Gui* gui, ViewPort* view_port) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
|
|
|
furi_check(view_port);
|
2020-10-26 20:00:17 +03:00
|
|
|
|
|
|
|
gui_lock(gui);
|
2021-01-29 16:52:16 +03:00
|
|
|
view_port_gui_set(view_port, NULL);
|
|
|
|
ViewPortArray_it_t it;
|
2020-10-26 20:00:17 +03:00
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_it(it, gui->layers[i]);
|
|
|
|
while(!ViewPortArray_end_p(it)) {
|
|
|
|
if(*ViewPortArray_ref(it) == view_port) {
|
|
|
|
ViewPortArray_remove(gui->layers[i], it);
|
2021-02-10 12:06:29 +03:00
|
|
|
} else {
|
|
|
|
ViewPortArray_next(it);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-09-02 00:05:00 +03:00
|
|
|
if(gui->ongoing_input_view_port == view_port) {
|
|
|
|
gui->ongoing_input_view_port = NULL;
|
|
|
|
}
|
2020-10-26 20:00:17 +03:00
|
|
|
gui_unlock(gui);
|
2022-04-18 01:29:45 +03:00
|
|
|
|
|
|
|
// Request redraw
|
|
|
|
gui_update(gui);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
2020-10-15 11:32:48 +03:00
|
|
|
|
2021-10-06 18:41:22 +03:00
|
|
|
void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
|
|
|
furi_check(view_port);
|
2021-02-10 12:06:29 +03:00
|
|
|
|
|
|
|
gui_lock(gui);
|
|
|
|
// Remove
|
|
|
|
GuiLayer layer = GuiLayerMAX;
|
|
|
|
ViewPortArray_it_t it;
|
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
|
|
|
ViewPortArray_it(it, gui->layers[i]);
|
|
|
|
while(!ViewPortArray_end_p(it)) {
|
|
|
|
if(*ViewPortArray_ref(it) == view_port) {
|
|
|
|
ViewPortArray_remove(gui->layers[i], it);
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(layer == GuiLayerMAX);
|
2021-02-10 12:06:29 +03:00
|
|
|
layer = i;
|
|
|
|
} else {
|
|
|
|
ViewPortArray_next(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(layer != GuiLayerMAX);
|
2021-02-10 12:06:29 +03:00
|
|
|
// Return to the top
|
|
|
|
ViewPortArray_push_back(gui->layers[layer], view_port);
|
|
|
|
gui_unlock(gui);
|
2022-04-18 01:29:45 +03:00
|
|
|
|
|
|
|
// Request redraw
|
|
|
|
gui_update(gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
}
|
|
|
|
|
2021-10-06 18:41:22 +03:00
|
|
|
void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port) {
|
2021-02-10 12:06:29 +03:00
|
|
|
furi_assert(gui);
|
|
|
|
furi_assert(view_port);
|
|
|
|
|
|
|
|
gui_lock(gui);
|
|
|
|
// Remove
|
|
|
|
GuiLayer layer = GuiLayerMAX;
|
|
|
|
ViewPortArray_it_t it;
|
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
|
|
|
ViewPortArray_it(it, gui->layers[i]);
|
|
|
|
while(!ViewPortArray_end_p(it)) {
|
|
|
|
if(*ViewPortArray_ref(it) == view_port) {
|
|
|
|
ViewPortArray_remove(gui->layers[i], it);
|
|
|
|
furi_assert(layer == GuiLayerMAX);
|
|
|
|
layer = i;
|
|
|
|
} else {
|
|
|
|
ViewPortArray_next(it);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
furi_assert(layer != GuiLayerMAX);
|
|
|
|
// Return to the top
|
|
|
|
ViewPortArray_push_at(gui->layers[layer], 0, view_port);
|
|
|
|
gui_unlock(gui);
|
2022-04-18 01:29:45 +03:00
|
|
|
|
|
|
|
// Request redraw
|
|
|
|
gui_update(gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
}
|
|
|
|
|
2022-03-17 12:44:54 +03:00
|
|
|
void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
2022-03-17 12:44:54 +03:00
|
|
|
|
2024-02-07 05:38:20 +03:00
|
|
|
canvas_add_framebuffer_callback(gui->canvas, callback, context);
|
2022-04-18 01:29:45 +03:00
|
|
|
|
|
|
|
// Request redraw
|
2022-03-17 12:44:54 +03:00
|
|
|
gui_update(gui);
|
2021-02-13 14:40:20 +03:00
|
|
|
}
|
|
|
|
|
2022-03-17 12:44:54 +03:00
|
|
|
void gui_remove_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
2022-03-17 12:44:54 +03:00
|
|
|
|
2024-02-07 05:38:20 +03:00
|
|
|
canvas_remove_framebuffer_callback(gui->canvas, callback, context);
|
2022-03-17 12:44:54 +03:00
|
|
|
}
|
|
|
|
|
2023-02-09 07:58:01 +03:00
|
|
|
size_t gui_get_framebuffer_size(const Gui* gui) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
|
|
|
|
2022-03-17 12:44:54 +03:00
|
|
|
return canvas_get_buffer_size(gui->canvas);
|
2022-03-16 11:52:11 +03:00
|
|
|
}
|
|
|
|
|
2022-01-29 14:20:55 +03:00
|
|
|
void gui_set_lockdown(Gui* gui, bool lockdown) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
2022-04-18 01:29:45 +03:00
|
|
|
|
2022-01-29 14:20:55 +03:00
|
|
|
gui_lock(gui);
|
|
|
|
gui->lockdown = lockdown;
|
|
|
|
gui_unlock(gui);
|
2022-04-18 01:29:45 +03:00
|
|
|
|
|
|
|
// Request redraw
|
2022-01-29 14:20:55 +03:00
|
|
|
gui_update(gui);
|
|
|
|
}
|
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
Canvas* gui_direct_draw_acquire(Gui* gui) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
|
|
|
|
2022-12-29 14:35:26 +03:00
|
|
|
gui_lock(gui);
|
|
|
|
gui->direct_draw = true;
|
|
|
|
gui_unlock(gui);
|
|
|
|
|
2024-02-29 01:09:55 +03:00
|
|
|
canvas_set_orientation(gui->canvas, CanvasOrientationHorizontal);
|
|
|
|
canvas_frame_set(gui->canvas, 0, 0, GUI_DISPLAY_WIDTH, GUI_DISPLAY_HEIGHT);
|
2022-12-29 14:35:26 +03:00
|
|
|
canvas_reset(gui->canvas);
|
|
|
|
canvas_commit(gui->canvas);
|
|
|
|
|
|
|
|
return gui->canvas;
|
|
|
|
}
|
|
|
|
|
|
|
|
void gui_direct_draw_release(Gui* gui) {
|
2024-03-19 17:43:52 +03:00
|
|
|
furi_check(gui);
|
2022-12-29 14:35:26 +03:00
|
|
|
|
|
|
|
canvas_reset(gui->canvas);
|
|
|
|
canvas_commit(gui->canvas);
|
|
|
|
|
|
|
|
gui_lock(gui);
|
|
|
|
gui->direct_draw = false;
|
|
|
|
gui_unlock(gui);
|
|
|
|
|
|
|
|
gui_update(gui);
|
|
|
|
}
|
|
|
|
|
2024-03-19 17:43:52 +03:00
|
|
|
Gui* gui_alloc(void) {
|
2022-02-18 22:53:46 +03:00
|
|
|
Gui* gui = malloc(sizeof(Gui));
|
2021-02-10 12:06:29 +03:00
|
|
|
// Thread ID
|
2022-06-20 17:54:48 +03:00
|
|
|
gui->thread_id = furi_thread_get_current_id();
|
2020-10-26 20:00:17 +03:00
|
|
|
// Allocate mutex
|
2022-07-20 13:56:33 +03:00
|
|
|
gui->mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
2024-02-07 05:38:20 +03:00
|
|
|
|
2021-02-10 12:06:29 +03:00
|
|
|
// Layers
|
2020-10-26 20:00:17 +03:00
|
|
|
for(size_t i = 0; i < GuiLayerMAX; i++) {
|
2021-01-29 16:52:16 +03:00
|
|
|
ViewPortArray_init(gui->layers[i]);
|
2020-10-26 20:00:17 +03:00
|
|
|
}
|
2024-02-07 05:38:20 +03:00
|
|
|
|
2021-02-10 12:06:29 +03:00
|
|
|
// Drawing canvas
|
|
|
|
gui->canvas = canvas_init();
|
2022-03-17 12:44:54 +03:00
|
|
|
|
2021-02-10 12:06:29 +03:00
|
|
|
// Input
|
2022-07-20 13:56:33 +03:00
|
|
|
gui->input_queue = furi_message_queue_alloc(8, sizeof(InputEvent));
|
2022-07-26 15:21:51 +03:00
|
|
|
gui->input_events = furi_record_open(RECORD_INPUT_EVENTS);
|
2022-03-17 12:44:54 +03:00
|
|
|
|
2021-11-01 23:35:54 +03:00
|
|
|
furi_pubsub_subscribe(gui->input_events, gui_input_events_callback, gui);
|
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;
|
|
|
|
}
|
|
|
|
|
2021-08-07 19:54:42 +03:00
|
|
|
int32_t gui_srv(void* p) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(p);
|
2020-10-15 18:05:28 +03:00
|
|
|
Gui* gui = gui_alloc();
|
2020-10-15 11:32:48 +03:00
|
|
|
|
2022-07-26 15:21:51 +03:00
|
|
|
furi_record_create(RECORD_GUI, gui);
|
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
|
|
|
while(1) {
|
2022-06-20 17:54:48 +03:00
|
|
|
uint32_t flags =
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_thread_flags_wait(GUI_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
2021-02-10 12:06:29 +03:00
|
|
|
// Process and dispatch input
|
|
|
|
if(flags & GUI_THREAD_FLAG_INPUT) {
|
|
|
|
// Process till queue become empty
|
|
|
|
InputEvent input_event;
|
2022-07-20 13:56:33 +03:00
|
|
|
while(furi_message_queue_get(gui->input_queue, &input_event, 0) == FuriStatusOk) {
|
2021-02-10 12:06:29 +03:00
|
|
|
gui_input(gui, &input_event);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Process and dispatch draw call
|
|
|
|
if(flags & GUI_THREAD_FLAG_DRAW) {
|
|
|
|
// Clear flags that arrived on input step
|
2022-06-20 17:54:48 +03:00
|
|
|
furi_thread_flags_clear(GUI_THREAD_FLAG_DRAW);
|
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);
|
|
|
|
}
|
|
|
|
}
|
2021-02-12 20:24:34 +03:00
|
|
|
|
|
|
|
return 0;
|
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
|
|
|
}
|