2021-10-03 13:36:05 +03: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 13:21:55 +03:00
|
|
|
#pragma once
|
|
|
|
|
2021-02-10 12:06:29 +03:00
|
|
|
#include "gui.h"
|
|
|
|
|
|
|
|
#include <furi.h>
|
|
|
|
#include <m-array.h>
|
2022-03-17 12:44:54 +03:00
|
|
|
#include <m-algo.h>
|
2021-02-10 12:06:29 +03: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 15:19:30 +03: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 20:09:15 +03:00
|
|
|
#define GUI_STATUS_BAR_HEIGHT 13
|
2021-11-26 15:19:30 +03:00
|
|
|
/* icon itself area (battery, sd card, etc) excluding frame.
|
|
|
|
* painted 2 pixels below GUI_STATUS_BAR_X.
|
|
|
|
*/
|
2021-11-24 21:19:34 +03:00
|
|
|
#define GUI_STATUS_BAR_WORKAREA_HEIGHT 8
|
2021-02-10 12:06:29 +03:00
|
|
|
|
2021-11-24 19:21:12 +03: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 12:06:29 +03: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 12:44:54 +03: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 13:36:05 +03:00
|
|
|
/** Gui structure */
|
2021-02-10 12:06:29 +03:00
|
|
|
struct Gui {
|
|
|
|
// Thread and lock
|
2022-06-20 17:54:48 +03:00
|
|
|
FuriThreadId thread_id;
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriMutex* mutex;
|
2021-08-31 11:22:52 +03:00
|
|
|
|
2021-02-10 12:06:29 +03:00
|
|
|
// Layers and Canvas
|
2022-01-29 14:20:55 +03:00
|
|
|
bool lockdown;
|
2022-12-29 14:35:26 +03:00
|
|
|
bool direct_draw;
|
2021-02-10 12:06:29 +03:00
|
|
|
ViewPortArray_t layers[GuiLayerMAX];
|
|
|
|
Canvas* canvas;
|
2022-03-17 12:44:54 +03:00
|
|
|
CanvasCallbackPairArray_t canvas_callback_pair;
|
2021-08-31 11:22:52 +03:00
|
|
|
|
2021-02-10 12:06:29 +03:00
|
|
|
// Input
|
2022-07-20 13:56:33 +03:00
|
|
|
FuriMessageQueue* input_queue;
|
2021-11-01 23:35:54 +03:00
|
|
|
FuriPubSub* input_events;
|
2021-08-31 11:22:52 +03:00
|
|
|
uint8_t ongoing_input;
|
|
|
|
ViewPort* ongoing_input_view_port;
|
2021-02-10 12:06:29 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
ViewPort* gui_view_port_find_enabled(ViewPortArray_t array);
|
|
|
|
|
2021-10-03 13:36:05 +03:00
|
|
|
/** Update GUI, request redraw
|
|
|
|
*
|
|
|
|
* @param gui Gui instance
|
2021-02-10 12:06:29 +03:00
|
|
|
*/
|
2021-02-15 02:46:59 +03:00
|
|
|
void gui_update(Gui* gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
|
|
|
|
void gui_input_events_callback(const void* value, void* ctx);
|
2020-10-16 18:25:06 +03:00
|
|
|
|
2020-10-26 20:00:17 +03:00
|
|
|
void gui_lock(Gui* gui);
|
2021-02-10 12:06:29 +03:00
|
|
|
|
2021-02-13 14:40:20 +03:00
|
|
|
void gui_unlock(Gui* gui);
|