2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file gui_i.h
|
|
|
|
* GUI: main API internals
|
|
|
|
*/
|
|
|
|
|
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 10:21:55 +00:00
|
|
|
#pragma once
|
|
|
|
|
2021-02-10 09:06:29 +00:00
|
|
|
#include "gui.h"
|
|
|
|
|
|
|
|
#include <furi.h>
|
|
|
|
#include <m-array.h>
|
2022-03-17 09:44:54 +00:00
|
|
|
#include <m-algo.h>
|
2021-02-10 09:06:29 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "canvas.h"
|
|
|
|
#include "canvas_i.h"
|
|
|
|
#include "view_port.h"
|
|
|
|
#include "view_port_i.h"
|
|
|
|
|
|
|
|
#define GUI_DISPLAY_WIDTH 128
|
|
|
|
#define GUI_DISPLAY_HEIGHT 64
|
|
|
|
|
|
|
|
#define GUI_STATUS_BAR_X 0
|
|
|
|
#define GUI_STATUS_BAR_Y 0
|
|
|
|
#define GUI_STATUS_BAR_WIDTH GUI_DISPLAY_WIDTH
|
2021-11-26 12:19:30 +00:00
|
|
|
/* 0-1 pixels for upper thin frame
|
|
|
|
* 2-9 pixels for icons (battery, sd card, etc)
|
|
|
|
* 10-12 pixels for lower bold line */
|
2021-04-06 17:09:15 +00:00
|
|
|
#define GUI_STATUS_BAR_HEIGHT 13
|
2021-11-26 12:19:30 +00:00
|
|
|
/* icon itself area (battery, sd card, etc) excluding frame.
|
|
|
|
* painted 2 pixels below GUI_STATUS_BAR_X.
|
|
|
|
*/
|
2021-11-24 18:19:34 +00:00
|
|
|
#define GUI_STATUS_BAR_WORKAREA_HEIGHT 8
|
2021-02-10 09:06:29 +00:00
|
|
|
|
2021-11-24 16:21:12 +00:00
|
|
|
#define GUI_WINDOW_X 0
|
|
|
|
#define GUI_WINDOW_Y GUI_STATUS_BAR_HEIGHT
|
|
|
|
#define GUI_WINDOW_WIDTH GUI_DISPLAY_WIDTH
|
|
|
|
#define GUI_WINDOW_HEIGHT (GUI_DISPLAY_HEIGHT - GUI_WINDOW_Y)
|
2021-02-10 09:06:29 +00:00
|
|
|
|
|
|
|
#define GUI_THREAD_FLAG_DRAW (1 << 0)
|
|
|
|
#define GUI_THREAD_FLAG_INPUT (1 << 1)
|
|
|
|
#define GUI_THREAD_FLAG_ALL (GUI_THREAD_FLAG_DRAW | GUI_THREAD_FLAG_INPUT)
|
|
|
|
|
|
|
|
ARRAY_DEF(ViewPortArray, ViewPort*, M_PTR_OPLIST);
|
|
|
|
|
2022-03-17 09:44:54 +00:00
|
|
|
typedef struct {
|
|
|
|
GuiCanvasCommitCallback callback;
|
|
|
|
void* context;
|
|
|
|
} CanvasCallbackPair;
|
|
|
|
|
|
|
|
ARRAY_DEF(CanvasCallbackPairArray, CanvasCallbackPair, M_POD_OPLIST);
|
|
|
|
|
|
|
|
#define M_OPL_CanvasCallbackPairArray_t() ARRAY_OPLIST(CanvasCallbackPairArray, M_POD_OPLIST)
|
|
|
|
|
|
|
|
ALGO_DEF(CanvasCallbackPairArray, CanvasCallbackPairArray_t);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Gui structure */
|
2021-02-10 09:06:29 +00:00
|
|
|
struct Gui {
|
|
|
|
// Thread and lock
|
2022-06-20 14:54:48 +00:00
|
|
|
FuriThreadId thread_id;
|
2022-07-20 10:56:33 +00:00
|
|
|
FuriMutex* mutex;
|
2021-08-31 08:22:52 +00:00
|
|
|
|
2021-02-10 09:06:29 +00:00
|
|
|
// Layers and Canvas
|
2022-01-29 11:20:55 +00:00
|
|
|
bool lockdown;
|
2022-12-29 11:35:26 +00:00
|
|
|
bool direct_draw;
|
2021-02-10 09:06:29 +00:00
|
|
|
ViewPortArray_t layers[GuiLayerMAX];
|
|
|
|
Canvas* canvas;
|
2022-03-17 09:44:54 +00:00
|
|
|
CanvasCallbackPairArray_t canvas_callback_pair;
|
2021-08-31 08:22:52 +00:00
|
|
|
|
2021-02-10 09:06:29 +00:00
|
|
|
// Input
|
2022-07-20 10:56:33 +00:00
|
|
|
FuriMessageQueue* input_queue;
|
2021-11-01 20:35:54 +00:00
|
|
|
FuriPubSub* input_events;
|
2021-08-31 08:22:52 +00:00
|
|
|
uint8_t ongoing_input;
|
|
|
|
ViewPort* ongoing_input_view_port;
|
2021-02-10 09:06:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
ViewPort* gui_view_port_find_enabled(ViewPortArray_t array);
|
|
|
|
|
2021-10-03 10:36:05 +00:00
|
|
|
/** Update GUI, request redraw
|
|
|
|
*
|
|
|
|
* @param gui Gui instance
|
2021-02-10 09:06:29 +00:00
|
|
|
*/
|
2021-02-14 23:46:59 +00:00
|
|
|
void gui_update(Gui* gui);
|
2021-02-10 09:06:29 +00:00
|
|
|
|
|
|
|
void gui_input_events_callback(const void* value, void* ctx);
|
2020-10-16 15:25:06 +00:00
|
|
|
|
2020-10-26 17:00:17 +00:00
|
|
|
void gui_lock(Gui* gui);
|
2021-02-10 09:06:29 +00:00
|
|
|
|
2021-02-13 11:40:20 +00:00
|
|
|
void gui_unlock(Gui* gui);
|