[FL-1906] Documentation: add Doxyfile, prepare sources for doxygen. (#741)
* Documentation: add Doxyfile, prepare sources for doxygen. * Update ReadMe and remove obsolete CLA * Add contribution guide * Contributing: update text * Correct spelling
This commit is contained in:
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file canvas.h
|
||||
* GUI: Canvas API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -8,13 +13,16 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** Color enumeration */
|
||||
typedef enum {
|
||||
ColorWhite = 0x00,
|
||||
ColorBlack = 0x01,
|
||||
} Color;
|
||||
|
||||
/** Fonts enumeration */
|
||||
typedef enum { FontPrimary, FontSecondary, FontKeyboard } Font;
|
||||
|
||||
/** Alignment enumeration */
|
||||
typedef enum {
|
||||
AlignLeft,
|
||||
AlignRight,
|
||||
@@ -23,59 +31,85 @@ typedef enum {
|
||||
AlignCenter,
|
||||
} Align;
|
||||
|
||||
/** Canvas Orientation */
|
||||
typedef enum {
|
||||
CanvasOrientationHorizontal,
|
||||
CanvasOrientationVertical,
|
||||
} CanvasOrientation;
|
||||
|
||||
/** Canvas anonymouse structure */
|
||||
typedef struct Canvas Canvas;
|
||||
|
||||
/*
|
||||
* Canvas width
|
||||
* @return width in pixels.
|
||||
/** Get Canvas width
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*
|
||||
* @return width in pixels.
|
||||
*/
|
||||
uint8_t canvas_width(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Canvas height
|
||||
* @return height in pixels.
|
||||
/** Get Canvas height
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*
|
||||
* @return height in pixels.
|
||||
*/
|
||||
uint8_t canvas_height(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Get current font height
|
||||
* @return height in pixels.
|
||||
/** Get current font height
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*
|
||||
* @return height in pixels.
|
||||
*/
|
||||
uint8_t canvas_current_font_height(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Clear canvas, clear rendering buffer
|
||||
/** Clear canvas
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*/
|
||||
void canvas_clear(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Set drawing color
|
||||
/** Set drawing color
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param color Color
|
||||
*/
|
||||
void canvas_set_color(Canvas* canvas, Color color);
|
||||
|
||||
/*
|
||||
* Invert drawing color
|
||||
/** Invert drawing color
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*/
|
||||
void canvas_invert_color(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Set drawing font
|
||||
/** Set drawing font
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param font Font
|
||||
*/
|
||||
void canvas_set_font(Canvas* canvas, Font font);
|
||||
|
||||
/*
|
||||
* Draw string at position of baseline defined by x, y.
|
||||
/** Draw string at position of baseline defined by x, y.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x anchor point x coordinate
|
||||
* @param y anchor point y coordinate
|
||||
* @param str C-string
|
||||
*/
|
||||
void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str);
|
||||
|
||||
/*
|
||||
* Draw aligned string defined by x, y.
|
||||
* Align calculated from position of baseline, string width and ascent (height of the glyphs above the baseline)
|
||||
/** Draw aligned string defined by x, y.
|
||||
*
|
||||
* Align calculated from position of baseline, string width and ascent (height
|
||||
* of the glyphs above the baseline)
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x anchor point x coordinate
|
||||
* @param y anchor point y coordinate
|
||||
* @param horizontal horizontal alignment
|
||||
* @param vertical vertical alignment
|
||||
* @param str C-string
|
||||
*/
|
||||
void canvas_draw_str_aligned(
|
||||
Canvas* canvas,
|
||||
@@ -85,22 +119,30 @@ void canvas_draw_str_aligned(
|
||||
Align vertical,
|
||||
const char* str);
|
||||
|
||||
/*
|
||||
* Get string width
|
||||
* @return width in pixels.
|
||||
/** Get string width
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param str C-string
|
||||
*
|
||||
* @return width in pixels.
|
||||
*/
|
||||
uint16_t canvas_string_width(Canvas* canvas, const char* str);
|
||||
|
||||
/** Get glyph width
|
||||
* @return width in pixels
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param[in] symbol character
|
||||
*
|
||||
* @return width in pixels
|
||||
*/
|
||||
uint8_t canvas_glyph_width(Canvas* canvas, char symbol);
|
||||
|
||||
/** Draw animation at position defined by x,y.
|
||||
* @param canvas - canvas instance
|
||||
* @param x - x coordinate
|
||||
* @param y - y coordinate
|
||||
* @param icon_animation - data pointer to IconAnimation
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param icon_animation IconAnimation instance
|
||||
*/
|
||||
void canvas_draw_icon_animation(
|
||||
Canvas* canvas,
|
||||
@@ -109,15 +151,22 @@ void canvas_draw_icon_animation(
|
||||
IconAnimation* icon_animation);
|
||||
|
||||
/** Draw icon at position defined by x,y.
|
||||
* @param canvas - canvas instance
|
||||
* @param x - x coordinate
|
||||
* @param y - y coordinate
|
||||
* @param icon - data pointer to Icon
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param icon Icon instance
|
||||
*/
|
||||
void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon);
|
||||
|
||||
/*
|
||||
* Draw xbm icon of width, height at position defined by x,y.
|
||||
/** Draw XBM bitmap
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param w bitmap width
|
||||
* @param h bitmap height
|
||||
* @param bitmap pointer to XBM bitmap data
|
||||
*/
|
||||
void canvas_draw_xbm(
|
||||
Canvas* canvas,
|
||||
@@ -127,48 +176,86 @@ void canvas_draw_xbm(
|
||||
uint8_t h,
|
||||
const uint8_t* bitmap);
|
||||
|
||||
/*
|
||||
* Draw dot at x,y
|
||||
/** Draw dot at x,y
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
*/
|
||||
void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y);
|
||||
|
||||
/*
|
||||
* Draw box of width, height at x,y
|
||||
/** Draw box of width, height at x,y
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width box width
|
||||
* @param height box height
|
||||
*/
|
||||
void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||||
|
||||
/*
|
||||
* Draw frame of width, height at x,y
|
||||
/** Draw frame of width, height at x,y
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width frame width
|
||||
* @param height frame height
|
||||
*/
|
||||
void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height);
|
||||
|
||||
/*
|
||||
* Draw line from x1,y1 to x2,y2
|
||||
/** Draw line from x1,y1 to x2,y2
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x1 x1 coordinate
|
||||
* @param y1 y1 coordinate
|
||||
* @param x2 x2 coordinate
|
||||
* @param y2 y2 coordinate
|
||||
*/
|
||||
void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2);
|
||||
|
||||
/*
|
||||
* Draw circle at x,y with radius r
|
||||
/** Draw circle at x,y with radius r
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param r radius
|
||||
*/
|
||||
void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
|
||||
|
||||
/*
|
||||
* Draw disc at x,y with radius r
|
||||
/** Draw disc at x,y with radius r
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param r radius
|
||||
*/
|
||||
void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t r);
|
||||
|
||||
/*
|
||||
* Draw glyph
|
||||
/** Draw glyph
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param ch character
|
||||
*/
|
||||
void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch);
|
||||
|
||||
/*
|
||||
* Set transparency mode
|
||||
/** Set transparency mode
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param alpha transparency mode
|
||||
*/
|
||||
void canvas_set_bitmap_mode(Canvas* canvas, bool alpha);
|
||||
|
||||
/*
|
||||
* Draw rounded-corner frame of width, height at x,y, with round value raduis
|
||||
/** Draw rounded-corner frame of width, height at x,y, with round value raduis
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width frame width
|
||||
* @param height frame height
|
||||
* @param radius frame corner radius
|
||||
*/
|
||||
void canvas_draw_rframe(
|
||||
Canvas* canvas,
|
||||
@@ -178,8 +265,14 @@ void canvas_draw_rframe(
|
||||
uint8_t height,
|
||||
uint8_t radius);
|
||||
|
||||
/*
|
||||
* Draw rounded-corner box of width, height at x,y, with round value raduis
|
||||
/** Draw rounded-corner box of width, height at x,y, with round value raduis
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param width box width
|
||||
* @param height box height
|
||||
* @param radius box corner radius
|
||||
*/
|
||||
void canvas_draw_rbox(
|
||||
Canvas* canvas,
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
/**
|
||||
* @file canvas_i.h
|
||||
* GUI: internal Canvas API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "canvas.h"
|
||||
#include <u8g2.h>
|
||||
|
||||
/** Canvas structure
|
||||
*/
|
||||
struct Canvas {
|
||||
u8g2_t fb;
|
||||
CanvasOrientation orientation;
|
||||
@@ -12,40 +19,53 @@ struct Canvas {
|
||||
uint8_t height;
|
||||
};
|
||||
|
||||
/*
|
||||
* Allocate memory and initialize canvas
|
||||
/** Allocate memory and initialize canvas
|
||||
*
|
||||
* @return Canvas instance
|
||||
*/
|
||||
Canvas* canvas_init();
|
||||
|
||||
/*
|
||||
* Free canvas memory
|
||||
/** Free canvas memory
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*/
|
||||
void canvas_free(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Reset canvas drawing tools configuration
|
||||
/** Reset canvas drawing tools configuration
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*/
|
||||
void canvas_reset(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Commit canvas. Send buffer to display
|
||||
/** Commit canvas. Send buffer to display
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*/
|
||||
void canvas_commit(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Get canvas buffer.
|
||||
* @return pointer to buffer
|
||||
/** Get canvas buffer.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*
|
||||
* @return pointer to buffer
|
||||
*/
|
||||
uint8_t* canvas_get_buffer(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Get canvas buffer size.
|
||||
* @return size of canvas in bytes
|
||||
/** Get canvas buffer size.
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*
|
||||
* @return size of canvas in bytes
|
||||
*/
|
||||
size_t canvas_get_buffer_size(Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Set drawing region relative to real screen buffer
|
||||
/** Set drawing region relative to real screen buffer
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param offset_x x coordinate offset
|
||||
* @param offset_y y coordinate offset
|
||||
* @param width width
|
||||
* @param height height
|
||||
*/
|
||||
void canvas_frame_set(
|
||||
Canvas* canvas,
|
||||
@@ -54,12 +74,17 @@ void canvas_frame_set(
|
||||
uint8_t width,
|
||||
uint8_t height);
|
||||
|
||||
/*
|
||||
* Set canvas orientation
|
||||
/** Set canvas orientation
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
* @param orientation CanvasOrientation
|
||||
*/
|
||||
void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation);
|
||||
|
||||
/*
|
||||
* Get canvas orientation
|
||||
/** Get canvas orientation
|
||||
*
|
||||
* @param canvas Canvas instance
|
||||
*
|
||||
* @return CanvasOrientation
|
||||
*/
|
||||
CanvasOrientation canvas_get_orientation(const Canvas* canvas);
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
/**
|
||||
* @file elements.h
|
||||
* GUI: Elements API
|
||||
*
|
||||
* Canvas helpers and UI building blocks.
|
||||
*
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file gui.h
|
||||
* GUI: main API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "view_port.h"
|
||||
@@ -7,60 +12,74 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Gui layers */
|
||||
/** Gui layers */
|
||||
typedef enum {
|
||||
GuiLayerNone, /* Special layer for internal use only */
|
||||
GuiLayerNone, /**< Special layer for internal use only */
|
||||
|
||||
GuiLayerStatusBarLeft, /* Status bar left-side layer, auto-layout */
|
||||
GuiLayerStatusBarRight, /* Status bar right-side layer, auto-layout */
|
||||
GuiLayerMain, /* Main layer, status bar is shown */
|
||||
GuiLayerFullscreen, /* Fullscreen layer */
|
||||
GuiLayerStatusBarLeft, /**< Status bar left-side layer, auto-layout */
|
||||
GuiLayerStatusBarRight, /**< Status bar right-side layer, auto-layout */
|
||||
GuiLayerMain, /**< Main layer, status bar is shown */
|
||||
GuiLayerFullscreen, /**< Fullscreen layer */
|
||||
|
||||
GuiLayerMAX /* Don't use or move, special value */
|
||||
GuiLayerMAX /**< Don't use or move, special value */
|
||||
} GuiLayer;
|
||||
|
||||
/* Gui frame buffer callback */
|
||||
/** Gui Canvas Commit Callback */
|
||||
typedef void (*GuiCanvasCommitCallback)(uint8_t* data, size_t size, void* context);
|
||||
|
||||
typedef struct Gui Gui;
|
||||
|
||||
/*
|
||||
* Add view_port to view_port tree
|
||||
* @remarks thread safe
|
||||
/** Add view_port to view_port tree
|
||||
*
|
||||
* @remark thread safe
|
||||
*
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
* @param[in] layer GuiLayer where to place view_port
|
||||
*/
|
||||
void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer);
|
||||
|
||||
/*
|
||||
* Remove view_port from rendering tree
|
||||
* @remarks thread safe
|
||||
/** Remove view_port from rendering tree
|
||||
*
|
||||
* @remark thread safe
|
||||
*
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void gui_remove_view_port(Gui* gui, ViewPort* view_port);
|
||||
|
||||
/* Send ViewPort to the front
|
||||
/** Send ViewPort to the front
|
||||
*
|
||||
* Places selected ViewPort to the top of the drawing stack
|
||||
* @param gui - Gui instance
|
||||
* @param view_port - ViewPort instance
|
||||
*
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void gui_send_view_port_front(Gui* gui, ViewPort* view_port);
|
||||
|
||||
/* Send ViewPort to the back
|
||||
/** Send ViewPort to the back
|
||||
*
|
||||
* Places selected ViewPort to the bottom of the drawing stack
|
||||
* @param gui - Gui instance
|
||||
* @param view_port - ViewPort instance
|
||||
*
|
||||
* @param gui Gui instance
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void gui_send_view_port_back(Gui* gui, ViewPort* view_port);
|
||||
|
||||
/* Set gui canvas commit callback
|
||||
* This callback will be called upon Canvas commit
|
||||
* Callback dispatched from GUI thread and is time critical
|
||||
* @param gui - Gui instance
|
||||
* @param callback - GuiCanvasCommitCallback
|
||||
/** Set gui canvas commit callback
|
||||
*
|
||||
* This callback will be called upon Canvas commit Callback dispatched from GUI
|
||||
* thread and is time critical
|
||||
*
|
||||
* @param gui Gui instance
|
||||
* @param callback GuiCanvasCommitCallback
|
||||
*/
|
||||
void gui_set_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback);
|
||||
|
||||
/* Set gui canvas commit callback context
|
||||
* @param gui - Gui instance
|
||||
* @param context - pointer to context
|
||||
/** Set gui canvas commit callback context
|
||||
*
|
||||
* @param gui Gui instance
|
||||
* @param context pointer to context
|
||||
*/
|
||||
void gui_set_framebuffer_callback_context(Gui* gui, void* context);
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file gui_i.h
|
||||
* GUI: main API internals
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gui.h"
|
||||
@@ -31,6 +36,7 @@
|
||||
|
||||
ARRAY_DEF(ViewPortArray, ViewPort*, M_PTR_OPLIST);
|
||||
|
||||
/** Gui structure */
|
||||
struct Gui {
|
||||
// Thread and lock
|
||||
osThreadId_t thread;
|
||||
@@ -54,8 +60,9 @@ struct Gui {
|
||||
|
||||
ViewPort* gui_view_port_find_enabled(ViewPortArray_t array);
|
||||
|
||||
/* Update GUI, request redraw
|
||||
* @param gui, Gui instance
|
||||
/** Update GUI, request redraw
|
||||
*
|
||||
* @param gui Gui instance
|
||||
*/
|
||||
void gui_update(Gui* gui);
|
||||
|
||||
@@ -67,4 +74,4 @@ void gui_unlock(Gui* gui);
|
||||
|
||||
void gui_cli_screen_stream_callback(uint8_t* data, size_t size, void* context);
|
||||
|
||||
void gui_cli_screen_stream(Cli* cli, string_t args, void* context);
|
||||
void gui_cli_screen_stream(Cli* cli, string_t args, void* context);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file icon.h
|
||||
* GUI: Icon API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
@@ -8,10 +13,28 @@ extern "C" {
|
||||
|
||||
typedef struct Icon Icon;
|
||||
|
||||
/** Get icon width
|
||||
*
|
||||
* @param[in] instance pointer to Icon data
|
||||
*
|
||||
* @return width in pixels
|
||||
*/
|
||||
uint8_t icon_get_width(const Icon* instance);
|
||||
|
||||
/** Get icon height
|
||||
*
|
||||
* @param[in] instance pointer to Icon data
|
||||
*
|
||||
* @return height in pixels
|
||||
*/
|
||||
uint8_t icon_get_height(const Icon* instance);
|
||||
|
||||
/** Get Icon XBM bitmap data
|
||||
*
|
||||
* @param[in] instance pointer to Icon data
|
||||
*
|
||||
* @return pointer to XBM bitmap data
|
||||
*/
|
||||
const uint8_t* icon_get_data(const Icon* instance);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,28 +1,48 @@
|
||||
/**
|
||||
* @file icon_animation.h
|
||||
* GUI: IconAnimation API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <assets_icons.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <assets_icons.h>
|
||||
|
||||
/** Icon Animation */
|
||||
typedef struct IconAnimation IconAnimation;
|
||||
|
||||
/** Icon Animation Callback. Used for update notification */
|
||||
typedef void (*IconAnimationCallback)(IconAnimation* instance, void* context);
|
||||
|
||||
/** Allocate icon animation instance with const icon data.
|
||||
*
|
||||
* always returns Icon or stops system if not enough memory
|
||||
*
|
||||
* @param[in] icon pointer to Icon data
|
||||
*
|
||||
* @return IconAnimation instance
|
||||
*/
|
||||
IconAnimation* icon_animation_alloc(const Icon* icon);
|
||||
|
||||
/** Release icon animation instance
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*/
|
||||
void icon_animation_free(IconAnimation* instance);
|
||||
|
||||
/** Get icon animation width
|
||||
/** Set IconAnimation update callback
|
||||
*
|
||||
* Normally you do not need to use this function, use view_tie_icon_animation
|
||||
* instead.
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
* @param[in] callback IconAnimationCallback
|
||||
* @param context callback context
|
||||
*/
|
||||
void icon_animation_set_update_callback(
|
||||
IconAnimation* instance,
|
||||
@@ -30,22 +50,38 @@ void icon_animation_set_update_callback(
|
||||
void* context);
|
||||
|
||||
/** Get icon animation width
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*
|
||||
* @return width in pixels
|
||||
*/
|
||||
uint8_t icon_animation_get_width(IconAnimation* instance);
|
||||
|
||||
/** Get icon animation height
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*
|
||||
* @return height in pixels
|
||||
*/
|
||||
uint8_t icon_animation_get_height(IconAnimation* instance);
|
||||
|
||||
/** Start icon animation
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*/
|
||||
void icon_animation_start(IconAnimation* instance);
|
||||
|
||||
/** Stop icon animation
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*/
|
||||
void icon_animation_stop(IconAnimation* instance);
|
||||
|
||||
/** Returns true if current frame is a last one
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*
|
||||
* @return true if last frame
|
||||
*/
|
||||
bool icon_animation_is_last_frame(IconAnimation* instance);
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file icon_animation_i.h
|
||||
* GUI: internal IconAnimation API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "icon_animation.h"
|
||||
@@ -13,11 +18,22 @@ struct IconAnimation {
|
||||
void* callback_context;
|
||||
};
|
||||
|
||||
/** Get pointer to current frame data */
|
||||
/** Get pointer to current frame data
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*
|
||||
* @return pointer to current frame XBM bitmap data
|
||||
*/
|
||||
const uint8_t* icon_animation_get_data(IconAnimation* instance);
|
||||
|
||||
/** Advance to next frame */
|
||||
/** Advance to next frame
|
||||
*
|
||||
* @param instance IconAnimation instance
|
||||
*/
|
||||
void icon_animation_next_frame(IconAnimation* instance);
|
||||
|
||||
/** IconAnimation timer callback */
|
||||
/** IconAnimation timer callback
|
||||
*
|
||||
* @param context pointer to IconAnimation
|
||||
*/
|
||||
void icon_animation_timer_callback(void* context);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file icon_i.h
|
||||
* GUI: internal Icon API
|
||||
*/
|
||||
|
||||
#include "icon.h"
|
||||
|
||||
struct Icon {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
/**
|
||||
* @file button_menu.h
|
||||
* GUI: ButtonMenu view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <gui/view.h>
|
||||
|
||||
@@ -6,40 +12,48 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ButtonMenu anonymous structure */
|
||||
/** ButtonMenu anonymous structure */
|
||||
typedef struct ButtonMenu ButtonMenu;
|
||||
|
||||
/** ButtonMenuItem anonymous structure */
|
||||
typedef struct ButtonMenuItem ButtonMenuItem;
|
||||
|
||||
/* Callback for any button menu actions */
|
||||
/** Callback for any button menu actions */
|
||||
typedef void (*ButtonMenuItemCallback)(void* context, int32_t index, InputType type);
|
||||
|
||||
/* Type of button. Difference in drawing buttons. */
|
||||
/** Type of button. Difference in drawing buttons. */
|
||||
typedef enum {
|
||||
ButtonMenuItemTypeCommon,
|
||||
ButtonMenuItemTypeControl,
|
||||
} ButtonMenuItemType;
|
||||
|
||||
/**
|
||||
* @brief Get button menu view
|
||||
* @param button_menu - ButtonMenu instance
|
||||
* @return View instance that can be used for embedding
|
||||
/** Get button menu view
|
||||
*
|
||||
* @param button_menu ButtonMenu instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* button_menu_get_view(ButtonMenu* button_menu);
|
||||
|
||||
/**
|
||||
* @brief Clean button menu
|
||||
* @param button_menu - ButtonMenu instance
|
||||
/** Clean button menu
|
||||
*
|
||||
* @param button_menu ButtonMenu instance
|
||||
*/
|
||||
void button_menu_clean(ButtonMenu* button_menu);
|
||||
|
||||
/**
|
||||
* @brief Add item to button menu instance
|
||||
* @param button_menu - ButtonMenu instance
|
||||
* @param label - text inside new button
|
||||
* @param index - value to distinct between buttons inside ButtonMenuItemCallback
|
||||
* @param type - type of button to create. Differ by button drawing.
|
||||
* Control buttons have no frames, and have more squared borders.
|
||||
* @return pointer to just-created item
|
||||
/** Add item to button menu instance
|
||||
*
|
||||
* @param button_menu ButtonMenu instance
|
||||
* @param label text inside new button
|
||||
* @param index value to distinct between buttons inside
|
||||
* ButtonMenuItemCallback
|
||||
* @param callback The callback
|
||||
* @param type type of button to create. Differ by button
|
||||
* drawing. Control buttons have no frames, and
|
||||
* have more squared borders.
|
||||
* @param callback_context The callback context
|
||||
*
|
||||
* @return pointer to just-created item
|
||||
*/
|
||||
ButtonMenuItem* button_menu_add_item(
|
||||
ButtonMenu* button_menu,
|
||||
@@ -49,29 +63,29 @@ ButtonMenuItem* button_menu_add_item(
|
||||
ButtonMenuItemType type,
|
||||
void* callback_context);
|
||||
|
||||
/**
|
||||
* @brief Allocate and initialize new instance of ButtonMenu model
|
||||
* @return just-created ButtonMenu model
|
||||
/** Allocate and initialize new instance of ButtonMenu model
|
||||
*
|
||||
* @return just-created ButtonMenu model
|
||||
*/
|
||||
ButtonMenu* button_menu_alloc(void);
|
||||
|
||||
/**
|
||||
* @brief Free ButtonMenu element
|
||||
* @param button_menu - ButtonMenu instance
|
||||
/** Free ButtonMenu element
|
||||
*
|
||||
* @param button_menu ButtonMenu instance
|
||||
*/
|
||||
void button_menu_free(ButtonMenu* button_menu);
|
||||
|
||||
/**
|
||||
* @brief Set ButtonMenu header on top of canvas
|
||||
* @param button_menu - ButtonMenu instance
|
||||
* @param header - header on the top of button menu
|
||||
/** Set ButtonMenu header on top of canvas
|
||||
*
|
||||
* @param button_menu ButtonMenu instance
|
||||
* @param header header on the top of button menu
|
||||
*/
|
||||
void button_menu_set_header(ButtonMenu* button_menu, const char* header);
|
||||
|
||||
/**
|
||||
* @brief Set selected item
|
||||
* @param button_menu - ButtonMenu instance
|
||||
* @param index - index of ButtonMenu to be selected
|
||||
/** Set selected item
|
||||
*
|
||||
* @param button_menu ButtonMenu instance
|
||||
* @param index index of ButtonMenu to be selected
|
||||
*/
|
||||
void button_menu_set_selected_item(ButtonMenu* button_menu, uint32_t index);
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
/**
|
||||
* @file button_panel.h
|
||||
* GUI: ButtonPanel view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -10,37 +16,39 @@ typedef struct ButtonPanel ButtonPanel;
|
||||
|
||||
/** Callback type to call for handling selecting button_panel items */
|
||||
typedef void (*ButtonItemCallback)(void* context, uint32_t index);
|
||||
|
||||
/** Callback type for additional drawings above main button_panel screen */
|
||||
typedef void (*ButtonPanelDrawCallback)(Canvas* canvas, void* _model);
|
||||
|
||||
/** Callback type to intercept input events of button_panel */
|
||||
typedef bool (*ButtonPanelInputCallback)(InputEvent* event, void* context);
|
||||
|
||||
/** Allocate new button_panel module.
|
||||
*
|
||||
* @return just-created module
|
||||
* @return ButtonPanel instance
|
||||
*/
|
||||
ButtonPanel* button_panel_alloc(void);
|
||||
|
||||
/** Free button_panel module.
|
||||
*
|
||||
* @param button_panel - module to free
|
||||
* @param button_panel ButtonPanel instance
|
||||
*/
|
||||
void button_panel_free(ButtonPanel* button_panel);
|
||||
|
||||
/** Free items from button_panel module. Preallocated matrix stays unchanged.
|
||||
*
|
||||
* @param button_panel - module to clean
|
||||
* @param button_panel ButtonPanel instance
|
||||
*/
|
||||
void button_panel_clean(ButtonPanel* button_panel);
|
||||
|
||||
/** Reserve space for adding items.
|
||||
*
|
||||
* One does not simply use button_panel_add_item() without this function.
|
||||
* It should be allocated space for it first.
|
||||
* One does not simply use button_panel_add_item() without this function. It
|
||||
* should be allocated space for it first.
|
||||
*
|
||||
* @param button_panel - module to modify
|
||||
* @param reserve_x - number of columns in button_panel
|
||||
* @param reserve_y - number of rows in button_panel
|
||||
* @param button_panel ButtonPanel instance
|
||||
* @param reserve_x number of columns in button_panel
|
||||
* @param reserve_y number of rows in button_panel
|
||||
*/
|
||||
void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t reserve_y);
|
||||
|
||||
@@ -48,20 +56,20 @@ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t re
|
||||
*
|
||||
* Have to set element in bounds of allocated size by X and by Y.
|
||||
*
|
||||
* @param button_panel - module
|
||||
* @param index - value to pass to callback
|
||||
* @param matrix_place_x - coordinates by x-axis on virtual grid, it
|
||||
* is only used for naviagation
|
||||
* @param matrix_place_y - coordinates by y-axis on virtual grid, it
|
||||
* is only used for naviagation
|
||||
* @param x - x-coordinate to draw icon on
|
||||
* @param y - y-coordinate to draw icon on
|
||||
* @param icon_name - name of the icon to draw
|
||||
* @param icon_name_selected - name of the icon to draw when current
|
||||
* element is selected
|
||||
* @param callback - function to call when specific element is selected
|
||||
* (pressed Ok on selected item)
|
||||
* @param callback_context - context to pass to callback
|
||||
* @param button_panel ButtonPanel instance
|
||||
* @param index value to pass to callback
|
||||
* @param matrix_place_x coordinates by x-axis on virtual grid, it
|
||||
* is only used for naviagation
|
||||
* @param matrix_place_y coordinates by y-axis on virtual grid, it
|
||||
* is only used for naviagation
|
||||
* @param x x-coordinate to draw icon on
|
||||
* @param y y-coordinate to draw icon on
|
||||
* @param icon_name name of the icon to draw
|
||||
* @param icon_name_selected name of the icon to draw when current
|
||||
* element is selected
|
||||
* @param callback function to call when specific element is
|
||||
* selected (pressed Ok on selected item)
|
||||
* @param callback_context context to pass to callback
|
||||
*/
|
||||
void button_panel_add_item(
|
||||
ButtonPanel* button_panel,
|
||||
@@ -77,17 +85,19 @@ void button_panel_add_item(
|
||||
|
||||
/** Get button_panel view.
|
||||
*
|
||||
* @param button_panel - module to get view from
|
||||
* @return acquired view
|
||||
* @param button_panel ButtonPanel instance
|
||||
*
|
||||
* @return acquired view
|
||||
*/
|
||||
View* button_panel_get_view(ButtonPanel* button_panel);
|
||||
|
||||
/** Add label to button_panel module.
|
||||
*
|
||||
* @param x - x-coordinate to place label
|
||||
* @param y - y-coordinate to place label
|
||||
* @param font - font to write label with
|
||||
* @param label_str - string label to write
|
||||
* @param button_panel ButtonPanel instance
|
||||
* @param x x-coordinate to place label
|
||||
* @param y y-coordinate to place label
|
||||
* @param font font to write label with
|
||||
* @param label_str string label to write
|
||||
*/
|
||||
void button_panel_add_label(
|
||||
ButtonPanel* button_panel,
|
||||
@@ -101,9 +111,9 @@ void button_panel_add_label(
|
||||
*
|
||||
* Used to add popup drawings after main draw callback is done.
|
||||
*
|
||||
* @param button_panel - module to modify
|
||||
* @param callback - callback function to set for draw event
|
||||
* @param context - context to pass to callback
|
||||
* @param button_panel ButtonPanel instance
|
||||
* @param callback callback function to set for draw event
|
||||
* @param context context to pass to callback
|
||||
*/
|
||||
void button_panel_set_popup_draw_callback(
|
||||
ButtonPanel* button_panel,
|
||||
@@ -112,12 +122,12 @@ void button_panel_set_popup_draw_callback(
|
||||
|
||||
/** Set popup input callback for button_panel module.
|
||||
*
|
||||
* Used to add popup input callback. It will intercept all input
|
||||
* events for current view.
|
||||
* Used to add popup input callback. It will intercept all input events for
|
||||
* current view.
|
||||
*
|
||||
* @param button_panel - module to modify
|
||||
* @param callback - function to overwrite main input callbacks
|
||||
* @param context - context to pass to callback
|
||||
* @param button_panel ButtonPanel instance
|
||||
* @param callback function to overwrite main input callbacks
|
||||
* @param context context to pass to callback
|
||||
*/
|
||||
void button_panel_set_popup_input_callback(
|
||||
ButtonPanel* button_panel,
|
||||
|
||||
@@ -1,59 +1,53 @@
|
||||
/**
|
||||
* @file byte_input.h
|
||||
* GUI: ByteInput keyboard view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Byte input anonymous structure
|
||||
*
|
||||
*/
|
||||
/** Byte input anonymous structure */
|
||||
typedef struct ByteInput ByteInput;
|
||||
|
||||
/**
|
||||
* @brief callback that is executed on save button press
|
||||
*
|
||||
*/
|
||||
/** callback that is executed on save button press */
|
||||
typedef void (*ByteInputCallback)(void* context);
|
||||
|
||||
/**
|
||||
* @brief callback that is executed when byte buffer is changed
|
||||
*
|
||||
*/
|
||||
/** callback that is executed when byte buffer is changed */
|
||||
typedef void (*ByteChangedCallback)(void* context);
|
||||
|
||||
/**
|
||||
* @brief Allocate and initialize byte input. This byte input is used to enter bytes.
|
||||
*
|
||||
* @return ByteInput instance pointer
|
||||
/** Allocate and initialize byte input. This byte input is used to enter bytes.
|
||||
*
|
||||
* @return ByteInput instance pointer
|
||||
*/
|
||||
ByteInput* byte_input_alloc();
|
||||
|
||||
/**
|
||||
* @brief Deinitialize and free byte input
|
||||
*
|
||||
* @param byte_input Byte input instance
|
||||
/** Deinitialize and free byte input
|
||||
*
|
||||
* @param byte_input Byte input instance
|
||||
*/
|
||||
void byte_input_free(ByteInput* byte_input);
|
||||
|
||||
/**
|
||||
* @brief Get byte input view
|
||||
*
|
||||
* @param byte_input byte input instance
|
||||
* @return View instance that can be used for embedding
|
||||
/** Get byte input view
|
||||
*
|
||||
* @param byte_input byte input instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* byte_input_get_view(ByteInput* byte_input);
|
||||
|
||||
/**
|
||||
* @brief Set byte input result callback
|
||||
*
|
||||
* @param byte_input byte input instance
|
||||
* @param input_callback input callback fn
|
||||
* @param changed_callback changed callback fn
|
||||
* @param callback_context callback context
|
||||
* @param bytes buffer to use
|
||||
* @param bytes_count buffer length
|
||||
/** Set byte input result callback
|
||||
*
|
||||
* @param byte_input byte input instance
|
||||
* @param input_callback input callback fn
|
||||
* @param changed_callback changed callback fn
|
||||
* @param callback_context callback context
|
||||
* @param bytes buffer to use
|
||||
* @param bytes_count buffer length
|
||||
*/
|
||||
void byte_input_set_result_callback(
|
||||
ByteInput* byte_input,
|
||||
@@ -63,11 +57,10 @@ void byte_input_set_result_callback(
|
||||
uint8_t* bytes,
|
||||
uint8_t bytes_count);
|
||||
|
||||
/**
|
||||
* @brief Set byte input header text
|
||||
*
|
||||
* @param byte_input byte input instance
|
||||
* @param text text to be shown
|
||||
/** Set byte input header text
|
||||
*
|
||||
* @param byte_input byte input instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void byte_input_set_header_text(ByteInput* byte_input, const char* text);
|
||||
|
||||
|
||||
@@ -1,77 +1,95 @@
|
||||
/**
|
||||
* @file dialog.h
|
||||
* GUI: Dialog view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Dialog anonymous structure */
|
||||
/** Dialog anonymous structure */
|
||||
typedef struct Dialog Dialog;
|
||||
|
||||
/* Dialog result */
|
||||
/** Dialog result */
|
||||
typedef enum {
|
||||
DialogResultLeft,
|
||||
DialogResultRight,
|
||||
DialogResultBack,
|
||||
} DialogResult;
|
||||
|
||||
/* Dialog result callback type
|
||||
* @warning comes from GUI thread
|
||||
/** Dialog result callback type
|
||||
* @warning comes from GUI thread
|
||||
*/
|
||||
typedef void (*DialogResultCallback)(DialogResult result, void* context);
|
||||
|
||||
/* Allocate and initialize dialog
|
||||
/** Allocate and initialize dialog
|
||||
*
|
||||
* This dialog used to ask simple questions like Yes/
|
||||
*
|
||||
* @return Dialog instance
|
||||
*/
|
||||
Dialog* dialog_alloc();
|
||||
|
||||
/* Deinitialize and free dialog
|
||||
* @param dialog - Dialog instance
|
||||
/** Deinitialize and free dialog
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
*/
|
||||
void dialog_free(Dialog* dialog);
|
||||
|
||||
/* Get dialog view
|
||||
* @param dialog - Dialog instance
|
||||
* @return View instance that can be used for embedding
|
||||
/** Get dialog view
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* dialog_get_view(Dialog* dialog);
|
||||
|
||||
/* Set dialog result callback
|
||||
* @param dialog - Dialog instance
|
||||
* @param callback - result callback function
|
||||
/** Set dialog result callback
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
* @param callback result callback function
|
||||
*/
|
||||
void dialog_set_result_callback(Dialog* dialog, DialogResultCallback callback);
|
||||
|
||||
/* Set dialog context
|
||||
* @param dialog - Dialog instance
|
||||
* @param context - context pointer, will be passed to result callback
|
||||
/** Set dialog context
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
* @param context context pointer, will be passed to result callback
|
||||
*/
|
||||
void dialog_set_context(Dialog* dialog, void* context);
|
||||
|
||||
/* Set dialog header text
|
||||
* @param dialog - Dialog instance
|
||||
* @param text - text to be shown
|
||||
/** Set dialog header text
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_set_header_text(Dialog* dialog, const char* text);
|
||||
|
||||
/* Set dialog text
|
||||
* @param dialog - Dialog instance
|
||||
* @param text - text to be shown
|
||||
/** Set dialog text
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_set_text(Dialog* dialog, const char* text);
|
||||
|
||||
/* Set left button text
|
||||
* @param dialog - Dialog instance
|
||||
* @param text - text to be shown
|
||||
/** Set left button text
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_set_left_button_text(Dialog* dialog, const char* text);
|
||||
|
||||
/* Set right button text
|
||||
* @param dialog - Dialog instance
|
||||
* @param text - text to be shown
|
||||
/** Set right button text
|
||||
*
|
||||
* @param dialog Dialog instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_set_right_button_text(Dialog* dialog, const char* text);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
/**
|
||||
* @file dialog_ex.h
|
||||
* GUI: DialogEx view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -21,40 +27,51 @@ typedef enum {
|
||||
typedef void (*DialogExResultCallback)(DialogExResult result, void* context);
|
||||
|
||||
/** Allocate and initialize dialog
|
||||
*
|
||||
* This dialog used to ask simple questions
|
||||
* @return DialogEx instance
|
||||
*
|
||||
* @return DialogEx instance
|
||||
*/
|
||||
DialogEx* dialog_ex_alloc();
|
||||
|
||||
/** Deinitialize and free dialog
|
||||
* @param dialog - DialogEx instance
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
*/
|
||||
void dialog_ex_free(DialogEx* dialog_ex);
|
||||
|
||||
/** Get dialog view
|
||||
* @param dialog - DialogEx instance
|
||||
* @return View instance that can be used for embedding
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* dialog_ex_get_view(DialogEx* dialog_ex);
|
||||
|
||||
/** Set dialog result callback
|
||||
* @param dialog_ex - DialogEx instance
|
||||
* @param callback - result callback function
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param callback result callback function
|
||||
*/
|
||||
void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback);
|
||||
|
||||
/** Set dialog context
|
||||
* @param dialog_ex - DialogEx instance
|
||||
* @param context - context pointer, will be passed to result callback
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param context context pointer, will be passed to result callback
|
||||
*/
|
||||
void dialog_ex_set_context(DialogEx* dialog_ex, void* context);
|
||||
|
||||
/** Set dialog header text
|
||||
*
|
||||
* If text is null, dialog header will not be rendered
|
||||
* @param dialog - DialogEx instance
|
||||
* @param text - text to be shown, can be multiline
|
||||
* @param x, y - text position
|
||||
* @param horizontal, vertical - text aligment
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param text text to be shown, can be multiline
|
||||
* @param x x position
|
||||
* @param y y position
|
||||
* @param horizontal horizontal text aligment
|
||||
* @param vertical vertical text aligment
|
||||
*/
|
||||
void dialog_ex_set_header(
|
||||
DialogEx* dialog_ex,
|
||||
@@ -65,11 +82,15 @@ void dialog_ex_set_header(
|
||||
Align vertical);
|
||||
|
||||
/** Set dialog text
|
||||
*
|
||||
* If text is null, dialog text will not be rendered
|
||||
* @param dialog - DialogEx instance
|
||||
* @param text - text to be shown, can be multiline
|
||||
* @param x, y - text position
|
||||
* @param horizontal, vertical - text aligment
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param text text to be shown, can be multiline
|
||||
* @param x x position
|
||||
* @param y y position
|
||||
* @param horizontal horizontal text aligment
|
||||
* @param vertical vertical text aligment
|
||||
*/
|
||||
void dialog_ex_set_text(
|
||||
DialogEx* dialog_ex,
|
||||
@@ -80,36 +101,47 @@ void dialog_ex_set_text(
|
||||
Align vertical);
|
||||
|
||||
/** Set dialog icon
|
||||
*
|
||||
* If x or y is negative, dialog icon will not be rendered
|
||||
* @param dialog - DialogEx instance
|
||||
* @param x, y - icon position
|
||||
* @param name - icon to be shown
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param x x position
|
||||
* @param y y position
|
||||
* @param icon The icon
|
||||
* @param name icon to be shown
|
||||
*/
|
||||
void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon);
|
||||
|
||||
/** Set left button text
|
||||
*
|
||||
* If text is null, left button will not be rendered and processed
|
||||
* @param dialog - DialogEx instance
|
||||
* @param text - text to be shown
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text);
|
||||
|
||||
/** Set center button text
|
||||
*
|
||||
* If text is null, center button will not be rendered and processed
|
||||
* @param dialog - DialogEx instance
|
||||
* @param text - text to be shown
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text);
|
||||
|
||||
/** Set right button text
|
||||
*
|
||||
* If text is null, right button will not be rendered and processed
|
||||
* @param dialog - DialogEx instance
|
||||
* @param text - text to be shown
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text);
|
||||
|
||||
/** Clean dialog
|
||||
* @param dialog_ex DialogEx instance
|
||||
*
|
||||
* @param dialog_ex DialogEx instance
|
||||
*/
|
||||
void dialog_ex_clean(DialogEx* dialog_ex);
|
||||
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
/**
|
||||
* @file empty_screen.h
|
||||
* GUI: EmptyScreen view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Empty screen anonymous structure */
|
||||
/** Empty screen anonymous structure */
|
||||
typedef struct EmptyScreen EmptyScreen;
|
||||
|
||||
/* Allocate and initialize empty screen
|
||||
/** Allocate and initialize empty screen
|
||||
*
|
||||
* This empty screen used to ask simple questions like Yes/
|
||||
*
|
||||
* @return EmptyScreen instance
|
||||
*/
|
||||
EmptyScreen* empty_screen_alloc();
|
||||
|
||||
/* Deinitialize and free empty screen
|
||||
* @param empty_screen - Empty screen instance
|
||||
/** Deinitialize and free empty screen
|
||||
*
|
||||
* @param empty_screen Empty screen instance
|
||||
*/
|
||||
void empty_screen_free(EmptyScreen* empty_screen);
|
||||
|
||||
/* Get empty screen view
|
||||
* @param empty_screen - Empty screen instance
|
||||
* @return View instance that can be used for embedding
|
||||
/** Get empty screen view
|
||||
*
|
||||
* @param empty_screen Empty screen instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* empty_screen_get_view(EmptyScreen* empty_screen);
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
/**
|
||||
* @file file_select.h
|
||||
* GUI: FileSelect view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
/**
|
||||
* @file menu.h
|
||||
* GUI: Menu view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -7,31 +13,38 @@ extern "C" {
|
||||
|
||||
/** Menu anonymous structure */
|
||||
typedef struct Menu Menu;
|
||||
|
||||
/** Menu Item Callback */
|
||||
typedef void (*MenuItemCallback)(void* context, uint32_t index);
|
||||
|
||||
/** Menu allocation and initialization
|
||||
* @return Menu instance
|
||||
*
|
||||
* @return Menu instance
|
||||
*/
|
||||
Menu* menu_alloc();
|
||||
|
||||
/** Free menu
|
||||
* @param menu - Menu instance
|
||||
*
|
||||
* @param menu Menu instance
|
||||
*/
|
||||
void menu_free(Menu* menu);
|
||||
|
||||
/** Get Menu view
|
||||
* @param menu - Menu instance
|
||||
* @return View instance
|
||||
*
|
||||
* @param menu Menu instance
|
||||
*
|
||||
* @return View instance
|
||||
*/
|
||||
View* menu_get_view(Menu* menu);
|
||||
|
||||
/** Add item to menu
|
||||
* @param menu - Menu instance
|
||||
* @param label - menu item string label
|
||||
* @param icon - IconAnimation instance
|
||||
* @param index - menu item index
|
||||
* @param callback - MenuItemCallback instance
|
||||
* @param context - pointer to context
|
||||
*
|
||||
* @param menu Menu instance
|
||||
* @param label menu item string label
|
||||
* @param icon IconAnimation instance
|
||||
* @param index menu item index
|
||||
* @param callback MenuItemCallback instance
|
||||
* @param context pointer to context
|
||||
*/
|
||||
void menu_add_item(
|
||||
Menu* menu,
|
||||
@@ -42,14 +55,16 @@ void menu_add_item(
|
||||
void* context);
|
||||
|
||||
/** Clean menu
|
||||
* Note: this function does not free menu instance
|
||||
* @param menu - Menu instance
|
||||
* @note this function does not free menu instance
|
||||
*
|
||||
* @param menu Menu instance
|
||||
*/
|
||||
void menu_clean(Menu* menu);
|
||||
|
||||
/** Set current menu item
|
||||
* @param submenu
|
||||
* @param index
|
||||
*
|
||||
* @param menu Menu instance
|
||||
* @param index The index
|
||||
*/
|
||||
void menu_set_selected_item(Menu* menu, uint32_t index);
|
||||
|
||||
|
||||
@@ -1,52 +1,70 @@
|
||||
/**
|
||||
* @file popup.h
|
||||
* GUI: Popup view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Popup anonymous structure */
|
||||
/** Popup anonymous structure */
|
||||
typedef struct Popup Popup;
|
||||
|
||||
/* Popup result callback type
|
||||
* @warning comes from GUI thread
|
||||
/** Popup result callback type
|
||||
* @warning comes from GUI thread
|
||||
*/
|
||||
typedef void (*PopupCallback)(void* context);
|
||||
|
||||
/* Allocate and initialize popup
|
||||
/** Allocate and initialize popup
|
||||
*
|
||||
* This popup used to ask simple questions like Yes/
|
||||
*
|
||||
* @return Popup instance
|
||||
*/
|
||||
Popup* popup_alloc();
|
||||
|
||||
/* Deinitialize and free popup
|
||||
* @param popup - Popup instance
|
||||
/** Deinitialize and free popup
|
||||
*
|
||||
* @param popup Popup instance
|
||||
*/
|
||||
void popup_free(Popup* popup);
|
||||
|
||||
/* Get popup view
|
||||
* @param popup - Popup instance
|
||||
* @return View instance that can be used for embedding
|
||||
/** Get popup view
|
||||
*
|
||||
* @param popup Popup instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* popup_get_view(Popup* popup);
|
||||
|
||||
/* Set popup header text
|
||||
* @param popup - Popup instance
|
||||
* @param text - text to be shown
|
||||
/** Set popup header text
|
||||
*
|
||||
* @param popup Popup instance
|
||||
* @param callback PopupCallback
|
||||
*/
|
||||
void popup_set_callback(Popup* popup, PopupCallback callback);
|
||||
|
||||
/* Set popup context
|
||||
* @param popup - Popup instance
|
||||
* @param context - context pointer, will be passed to result callback
|
||||
/** Set popup context
|
||||
*
|
||||
* @param popup Popup instance
|
||||
* @param context context pointer, will be passed to result callback
|
||||
*/
|
||||
void popup_set_context(Popup* popup, void* context);
|
||||
|
||||
/* Set popup header text
|
||||
/** Set popup header text
|
||||
*
|
||||
* If text is null, popup header will not be rendered
|
||||
* @param popup - Popup instance
|
||||
* @param text - text to be shown, can be multiline
|
||||
* @param x, y - text position
|
||||
* @param horizontal, vertical - text aligment
|
||||
*
|
||||
* @param popup Popup instance
|
||||
* @param text text to be shown, can be multiline
|
||||
* @param x x position
|
||||
* @param y y position
|
||||
* @param horizontal horizontal alignment
|
||||
* @param vertical vertical aligment
|
||||
*/
|
||||
void popup_set_header(
|
||||
Popup* popup,
|
||||
@@ -56,12 +74,16 @@ void popup_set_header(
|
||||
Align horizontal,
|
||||
Align vertical);
|
||||
|
||||
/* Set popup text
|
||||
/** Set popup text
|
||||
*
|
||||
* If text is null, popup text will not be rendered
|
||||
* @param popup - Popup instance
|
||||
* @param text - text to be shown, can be multiline
|
||||
* @param x, y - text position
|
||||
* @param horizontal, vertical - text aligment
|
||||
*
|
||||
* @param popup Popup instance
|
||||
* @param text text to be shown, can be multiline
|
||||
* @param x x position
|
||||
* @param y y position
|
||||
* @param horizontal horizontal alignment
|
||||
* @param vertical vertical aligment
|
||||
*/
|
||||
void popup_set_text(
|
||||
Popup* popup,
|
||||
@@ -71,30 +93,36 @@ void popup_set_text(
|
||||
Align horizontal,
|
||||
Align vertical);
|
||||
|
||||
/* Set popup icon
|
||||
/** Set popup icon
|
||||
*
|
||||
* If icon position is negative, popup icon will not be rendered
|
||||
* @param popup - Popup instance
|
||||
* @param x, y - icon position
|
||||
* @param name - icon to be shown
|
||||
*
|
||||
* @param popup Popup instance
|
||||
* @param x x position
|
||||
* @param y y position
|
||||
* @param icon pointer to Icon data
|
||||
*/
|
||||
void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon);
|
||||
|
||||
/* Set popup timeout
|
||||
* @param popup - Popup instance
|
||||
* @param timeout_in_ms - popup timeout value in milliseconds
|
||||
/** Set popup timeout
|
||||
*
|
||||
* @param popup Popup instance
|
||||
* @param timeout_in_ms popup timeout value in milliseconds
|
||||
*/
|
||||
void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms);
|
||||
|
||||
/* Enable popup timeout
|
||||
* @param popup - Popup instance
|
||||
/** Enable popup timeout
|
||||
*
|
||||
* @param popup Popup instance
|
||||
*/
|
||||
void popup_enable_timeout(Popup* popup);
|
||||
|
||||
/* Disable popup timeout
|
||||
* @param popup - Popup instance
|
||||
/** Disable popup timeout
|
||||
*
|
||||
* @param popup Popup instance
|
||||
*/
|
||||
void popup_disable_timeout(Popup* popup);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,40 +1,50 @@
|
||||
/**
|
||||
* @file submenu.h
|
||||
* GUI: SubMenu view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Submenu anonymous structure */
|
||||
/** Submenu anonymous structure */
|
||||
typedef struct Submenu Submenu;
|
||||
typedef void (*SubmenuItemCallback)(void* context, uint32_t index);
|
||||
|
||||
/**
|
||||
* @brief Allocate and initialize submenu
|
||||
/** Allocate and initialize submenu
|
||||
*
|
||||
* This submenu is used to select one option
|
||||
*
|
||||
* @return Submenu instance
|
||||
*/
|
||||
Submenu* submenu_alloc();
|
||||
|
||||
/**
|
||||
* @brief Deinitialize and free submenu
|
||||
* @param submenu - Submenu instance
|
||||
/** Deinitialize and free submenu
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
*/
|
||||
void submenu_free(Submenu* submenu);
|
||||
|
||||
/**
|
||||
* @brief Get submenu view
|
||||
* @param submenu - Submenu instance
|
||||
* @return View instance that can be used for embedding
|
||||
/** Get submenu view
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* submenu_get_view(Submenu* submenu);
|
||||
|
||||
/**
|
||||
* @brief Add item to submenu
|
||||
* @param submenu - Submenu instance
|
||||
* @param label - menu item label
|
||||
* @param index - menu item index, used for callback, may be the same with other items
|
||||
* @param callback - menu item callback
|
||||
* @param callback_context - menu item callback context
|
||||
/** Add item to submenu
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
* @param label menu item label
|
||||
* @param index menu item index, used for callback, may be
|
||||
* the same with other items
|
||||
* @param callback menu item callback
|
||||
* @param callback_context menu item callback context
|
||||
*/
|
||||
void submenu_add_item(
|
||||
Submenu* submenu,
|
||||
@@ -43,23 +53,23 @@ void submenu_add_item(
|
||||
SubmenuItemCallback callback,
|
||||
void* callback_context);
|
||||
|
||||
/**
|
||||
* @brief Remove all items from submenu
|
||||
* @param submenu - Submenu instance
|
||||
/** Remove all items from submenu
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
*/
|
||||
void submenu_clean(Submenu* submenu);
|
||||
|
||||
/**
|
||||
* @brief Set submenu item selector
|
||||
* @param submenu
|
||||
* @param index
|
||||
/** Set submenu item selector
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
* @param index The index
|
||||
*/
|
||||
void submenu_set_selected_item(Submenu* submenu, uint32_t index);
|
||||
|
||||
/**
|
||||
* @brief Set optional header for submenu
|
||||
* @param submenu - submenu entity
|
||||
* @param header - header to set
|
||||
/** Set optional header for submenu
|
||||
*
|
||||
* @param submenu Submenu instance
|
||||
* @param header header to set
|
||||
*/
|
||||
void submenu_set_header(Submenu* submenu, const char* header);
|
||||
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
/**
|
||||
* @file text_box.h
|
||||
* GUI: TextBox view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* TextBox anonymous structure */
|
||||
/** TextBox anonymous structure */
|
||||
typedef struct TextBox TextBox;
|
||||
typedef void (*TextBoxExitCallback)(void* context);
|
||||
|
||||
@@ -15,46 +21,56 @@ typedef enum {
|
||||
} TextBoxFont;
|
||||
|
||||
/** Allocate and initialize text_box
|
||||
*
|
||||
* @return TextBox instance
|
||||
*/
|
||||
TextBox* text_box_alloc();
|
||||
|
||||
/** Deinitialize and free text_box
|
||||
* @param text_box text_box instance
|
||||
*
|
||||
* @param text_box text_box instance
|
||||
*/
|
||||
void text_box_free(TextBox* text_box);
|
||||
|
||||
/** Get text_box view
|
||||
* @param text_box TextBox instance
|
||||
* @return View instance that can be used for embedding
|
||||
*
|
||||
* @param text_box TextBox instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* text_box_get_view(TextBox* text_box);
|
||||
|
||||
/** Clean text_box
|
||||
* @param text_box TextBox instance
|
||||
*
|
||||
* @param text_box TextBox instance
|
||||
*/
|
||||
void text_box_clean(TextBox* text_box);
|
||||
|
||||
/** Set text for text_box
|
||||
* @param text_box TextBox instance
|
||||
* @param text text to set
|
||||
*
|
||||
* @param text_box TextBox instance
|
||||
* @param text text to set
|
||||
*/
|
||||
void text_box_set_text(TextBox* text_box, const char* text);
|
||||
|
||||
/** Set TextBox font
|
||||
* @param text_box TextBox instance
|
||||
* @param font TextBoxFont instance
|
||||
*
|
||||
* @param text_box TextBox instance
|
||||
* @param font TextBoxFont instance
|
||||
*/
|
||||
void text_box_set_font(TextBox* text_box, TextBoxFont font);
|
||||
|
||||
/** Set text_box context
|
||||
* @param text_box TextBox instance
|
||||
* @param context context pointer
|
||||
*
|
||||
* @param text_box TextBox instance
|
||||
* @param context context pointer
|
||||
*/
|
||||
void text_box_set_context(TextBox* text_box, void* context);
|
||||
|
||||
/** Set exit callback
|
||||
* @param text_box TextBox instance
|
||||
* @param callback TextBoxExitCallback callback pointer
|
||||
*
|
||||
* @param text_box TextBox instance
|
||||
* @param callback TextBoxExitCallback callback pointer
|
||||
*/
|
||||
void text_box_set_exit_callback(TextBox* text_box, TextBoxExitCallback callback);
|
||||
|
||||
|
||||
@@ -1,44 +1,59 @@
|
||||
/**
|
||||
* @file text_input.h
|
||||
* GUI: TextInput keybord view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Text input anonymous structure */
|
||||
/** Text input anonymous structure */
|
||||
typedef struct TextInput TextInput;
|
||||
typedef void (*TextInputCallback)(void* context);
|
||||
|
||||
/** Allocate and initialize text input
|
||||
/** Allocate and initialize text input
|
||||
*
|
||||
* This text input is used to enter string
|
||||
* @return TextInput instance
|
||||
*
|
||||
* @return TextInput instance
|
||||
*/
|
||||
TextInput* text_input_alloc();
|
||||
|
||||
/** Deinitialize and free text input
|
||||
* @param text_input - TextInput instance
|
||||
*
|
||||
* @param text_input TextInput instance
|
||||
*/
|
||||
void text_input_free(TextInput* text_input);
|
||||
|
||||
/** Clean text input view
|
||||
* Note: this function does not free memory
|
||||
* @param text_input - Text input instance
|
||||
/** Clean text input view Note: this function does not free memory
|
||||
*
|
||||
* @param text_input Text input instance
|
||||
*/
|
||||
void text_input_clean(TextInput* text_input);
|
||||
|
||||
/** Get text input view
|
||||
* @param text_input - TextInput instance
|
||||
* @return View instance that can be used for embedding
|
||||
*
|
||||
* @param text_input TextInput instance
|
||||
*
|
||||
* @return View instance that can be used for embedding
|
||||
*/
|
||||
View* text_input_get_view(TextInput* text_input);
|
||||
|
||||
/** Set text input result callback
|
||||
* @param text_input - TextInput instance
|
||||
* @param callback - callback fn
|
||||
* @param callback_context - callback context
|
||||
* @param text_buffer - pointer to YOUR text buffer, that we going to modify
|
||||
* @param text_buffer_size - YOUR text buffer size in bytes. Max string length will be text_buffer_size - 1.
|
||||
* @param clear_default_text - clear text from text_buffer on first OK event
|
||||
*
|
||||
* @param text_input TextInput instance
|
||||
* @param callback callback fn
|
||||
* @param callback_context callback context
|
||||
* @param text_buffer pointer to YOUR text buffer, that we going
|
||||
* to modify
|
||||
* @param text_buffer_size YOUR text buffer size in bytes. Max string
|
||||
* length will be text_buffer_size-1.
|
||||
* @param clear_default_text clear text from text_buffer on first OK
|
||||
* event
|
||||
*/
|
||||
void text_input_set_result_callback(
|
||||
TextInput* text_input,
|
||||
@@ -49,8 +64,9 @@ void text_input_set_result_callback(
|
||||
bool clear_default_text);
|
||||
|
||||
/** Set text input header text
|
||||
* @param text_input - TextInput instance
|
||||
* @param text - text to be shown
|
||||
*
|
||||
* @param text_input TextInput instance
|
||||
* @param text text to be shown
|
||||
*/
|
||||
void text_input_set_header_text(TextInput* text_input, const char* text);
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
/**
|
||||
* @file variable-item-list.h
|
||||
* GUI: VariableItemList view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gui/view.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -11,29 +17,40 @@ typedef void (*VariableItemChangeCallback)(VariableItem* item);
|
||||
typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index);
|
||||
|
||||
/** Allocate and initialize VariableItemList
|
||||
* @return VariableItemList*
|
||||
*
|
||||
* @return VariableItemList*
|
||||
*/
|
||||
VariableItemList* variable_item_list_alloc();
|
||||
|
||||
/** Deinitialize and free VariableItemList
|
||||
* @param variable_item_list VariableItemList instance
|
||||
*
|
||||
* @param variable_item_list VariableItemList instance
|
||||
*/
|
||||
void variable_item_list_free(VariableItemList* variable_item_list);
|
||||
|
||||
/** Clear all elements from list
|
||||
* @param variable_item_list VariableItemList instance
|
||||
*
|
||||
* @param variable_item_list VariableItemList instance
|
||||
*/
|
||||
void variable_item_list_clean(VariableItemList* variable_item_list);
|
||||
|
||||
/** Get VariableItemList View instance
|
||||
*
|
||||
* @param variable_item_list VariableItemList instance
|
||||
*
|
||||
* @return View instance
|
||||
*/
|
||||
View* variable_item_list_get_view(VariableItemList* variable_item_list);
|
||||
|
||||
/** Add item to VariableItemList
|
||||
* @param variable_item_list VariableItemList instance
|
||||
* @param label item name
|
||||
* @param values_count item values count
|
||||
* @param change_callback called on value change in gui
|
||||
* @param context item context
|
||||
* @return VariableItem* item instance
|
||||
*
|
||||
* @param variable_item_list VariableItemList instance
|
||||
* @param label item name
|
||||
* @param values_count item values count
|
||||
* @param change_callback called on value change in gui
|
||||
* @param context item context
|
||||
*
|
||||
* @return VariableItem* item instance
|
||||
*/
|
||||
VariableItem* variable_item_list_add(
|
||||
VariableItemList* variable_item_list,
|
||||
@@ -43,9 +60,10 @@ VariableItem* variable_item_list_add(
|
||||
void* context);
|
||||
|
||||
/** Set enter callback
|
||||
* @param variable_item_list VariableItemList instance
|
||||
* @param calback VariableItemListEnterCallback instance
|
||||
* @param context pointer to context
|
||||
*
|
||||
* @param variable_item_list VariableItemList instance
|
||||
* @param callback VariableItemListEnterCallback instance
|
||||
* @param context pointer to context
|
||||
*/
|
||||
void variable_item_list_set_enter_callback(
|
||||
VariableItemList* variable_item_list,
|
||||
@@ -53,29 +71,35 @@ void variable_item_list_set_enter_callback(
|
||||
void* context);
|
||||
|
||||
/** Set item current selected index
|
||||
* @param item VariableItem* instance
|
||||
* @param current_value_index
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
* @param current_value_index The current value index
|
||||
*/
|
||||
void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index);
|
||||
|
||||
/** Set item current selected text
|
||||
* @param item VariableItem* instance
|
||||
* @param current_value_text
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
* @param current_value_text The current value text
|
||||
*/
|
||||
void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text);
|
||||
|
||||
/** Get item current selected index
|
||||
* @param item VariableItem* instance
|
||||
* @return uint8_t current selected index
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
*
|
||||
* @return uint8_t current selected index
|
||||
*/
|
||||
uint8_t variable_item_get_current_value_index(VariableItem* item);
|
||||
|
||||
/** Get item context
|
||||
* @param item VariableItem* instance
|
||||
* @return void* item context
|
||||
*
|
||||
* @param item VariableItem* instance
|
||||
*
|
||||
* @return void* item context
|
||||
*/
|
||||
void* variable_item_get_context(VariableItem* item);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,38 +1,51 @@
|
||||
/**
|
||||
* @file widget.h
|
||||
* GUI: Widget view module API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "widget_elements/widget_element_i.h"
|
||||
|
||||
typedef struct Widget Widget;
|
||||
typedef struct WidgetElement WidgetElement;
|
||||
|
||||
/** Allocate Widget that holds Widget Elements
|
||||
* @return Widget instance
|
||||
*
|
||||
* @return Widget instance
|
||||
*/
|
||||
Widget* widget_alloc();
|
||||
|
||||
/** Free Widget
|
||||
* @note this function free allocated Widget Elements
|
||||
* @param widget Widget instance
|
||||
* @note this function free allocated Widget Elements
|
||||
*
|
||||
* @param widget Widget instance
|
||||
*/
|
||||
void widget_free(Widget* widget);
|
||||
|
||||
/** Clear Widget
|
||||
* @param widget Widget instance
|
||||
*
|
||||
* @param widget Widget instance
|
||||
*/
|
||||
void widget_clear(Widget* widget);
|
||||
|
||||
/** Get Widget view
|
||||
* @param widget Widget instance
|
||||
* @return View instance
|
||||
*
|
||||
* @param widget Widget instance
|
||||
*
|
||||
* @return View instance
|
||||
*/
|
||||
View* widget_get_view(Widget* widget);
|
||||
|
||||
/** Add Multi String Element
|
||||
* @param widget Widget instance
|
||||
* @param x - x coordinate
|
||||
* @param y - y coordinate
|
||||
* @param horizontal - Align instance
|
||||
* @param vertical - Align instance
|
||||
* @param font Font instance
|
||||
*
|
||||
* @param widget Widget instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param horizontal Align instance
|
||||
* @param vertical Align instance
|
||||
* @param font Font instance
|
||||
* @param[in] text The text
|
||||
*/
|
||||
void widget_add_string_multiline_element(
|
||||
Widget* widget,
|
||||
@@ -44,12 +57,14 @@ void widget_add_string_multiline_element(
|
||||
const char* text);
|
||||
|
||||
/** Add String Element
|
||||
* @param widget Widget instance
|
||||
* @param x - x coordinate
|
||||
* @param y - y coordinate
|
||||
* @param horizontal - Align instance
|
||||
* @param vertical - Align instance
|
||||
* @param font Font instance
|
||||
*
|
||||
* @param widget Widget instance
|
||||
* @param x x coordinate
|
||||
* @param y y coordinate
|
||||
* @param horizontal Align instance
|
||||
* @param vertical Align instance
|
||||
* @param font Font instance
|
||||
* @param[in] text The text
|
||||
*/
|
||||
void widget_add_string_element(
|
||||
Widget* widget,
|
||||
@@ -61,11 +76,12 @@ void widget_add_string_element(
|
||||
const char* text);
|
||||
|
||||
/** Add Button Element
|
||||
* @param widget Widget instance
|
||||
* @param button_type GuiButtonType instance
|
||||
* @param text text on allocated button
|
||||
* @param callback ButtonCallback instance
|
||||
* @param context pointer to context
|
||||
*
|
||||
* @param widget Widget instance
|
||||
* @param button_type GuiButtonType instance
|
||||
* @param text text on allocated button
|
||||
* @param callback ButtonCallback instance
|
||||
* @param context pointer to context
|
||||
*/
|
||||
void widget_add_button_element(
|
||||
Widget* widget,
|
||||
@@ -75,20 +91,22 @@ void widget_add_button_element(
|
||||
void* context);
|
||||
|
||||
/** Add Icon Element
|
||||
* @param widget Widget instance
|
||||
* @param x top left x coordinate
|
||||
* @param y top left y coordinate
|
||||
* @param icon Icon instance
|
||||
*
|
||||
* @param widget Widget instance
|
||||
* @param x top left x coordinate
|
||||
* @param y top left y coordinate
|
||||
* @param icon Icon instance
|
||||
*/
|
||||
void widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon);
|
||||
|
||||
/** Add Frame Element
|
||||
* @param widget Widget instance
|
||||
* @param x top left x coordinate
|
||||
* @param y top left y coordinate
|
||||
* @param width frame width
|
||||
* @param height frame height
|
||||
* @param radius frame radius
|
||||
*
|
||||
* @param widget Widget instance
|
||||
* @param x top left x coordinate
|
||||
* @param y top left y coordinate
|
||||
* @param width frame width
|
||||
* @param height frame height
|
||||
* @param radius frame radius
|
||||
*/
|
||||
void widget_add_frame_element(
|
||||
Widget* widget,
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file widget_element_i.h
|
||||
* GUI: internal Widget Element API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <furi.h>
|
||||
#include <gui/view.h>
|
||||
@@ -29,7 +34,7 @@ struct WidgetElement {
|
||||
Widget* parent;
|
||||
};
|
||||
|
||||
/* Create multi string element */
|
||||
/** Create multi string element */
|
||||
WidgetElement* widget_element_string_multiline_create(
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
@@ -38,7 +43,7 @@ WidgetElement* widget_element_string_multiline_create(
|
||||
Font font,
|
||||
const char* text);
|
||||
|
||||
/* Create string element */
|
||||
/** Create string element */
|
||||
WidgetElement* widget_element_string_create(
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
@@ -47,20 +52,20 @@ WidgetElement* widget_element_string_create(
|
||||
Font font,
|
||||
const char* text);
|
||||
|
||||
/* Create button element */
|
||||
/** Create button element */
|
||||
WidgetElement* widget_element_button_create(
|
||||
GuiButtonType button_type,
|
||||
const char* text,
|
||||
ButtonCallback callback,
|
||||
void* context);
|
||||
|
||||
/* Create icon element */
|
||||
/** Create icon element */
|
||||
WidgetElement* widget_element_icon_create(uint8_t x, uint8_t y, const Icon* icon);
|
||||
|
||||
/* Create frame element */
|
||||
/** Create frame element */
|
||||
WidgetElement* widget_element_frame_create(
|
||||
uint8_t x,
|
||||
uint8_t y,
|
||||
uint8_t width,
|
||||
uint8_t height,
|
||||
uint8_t radius);
|
||||
uint8_t radius);
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
/**
|
||||
* @file scene_manager.h
|
||||
* GUI: SceneManager API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/** Scene Manager events type
|
||||
*/
|
||||
/** Scene Manager events type */
|
||||
typedef enum {
|
||||
SceneManagerEventTypeCustom,
|
||||
SceneManagerEventTypeBack,
|
||||
@@ -44,86 +48,110 @@ typedef struct {
|
||||
typedef struct SceneManager SceneManager;
|
||||
|
||||
/** Set Scene state
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
* @param state Scene new state
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
* @param state Scene new state
|
||||
*/
|
||||
void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state);
|
||||
|
||||
/** Get Scene state
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
* @return Scene state
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
*
|
||||
* @return Scene state
|
||||
*/
|
||||
uint32_t scene_manager_get_scene_state(SceneManager* scene_manager, uint32_t scene_id);
|
||||
|
||||
/** Scene Manager allocation and configuration
|
||||
*
|
||||
* Scene Manager allocates all scenes internally
|
||||
* @param app_scene_handlers SceneManagerHandlers instance
|
||||
* @param context context to be set on Scene handlers calls
|
||||
* @return SceneManager instance
|
||||
*
|
||||
* @param app_scene_handlers SceneManagerHandlers instance
|
||||
* @param context context to be set on Scene handlers calls
|
||||
*
|
||||
* @return SceneManager instance
|
||||
*/
|
||||
SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context);
|
||||
|
||||
/** Free Scene Manager with allocated Scenes
|
||||
* @param scene_manager SceneManager instance
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
*/
|
||||
void scene_manager_free(SceneManager* scene_manager);
|
||||
|
||||
/** Custom event handler
|
||||
*
|
||||
* Calls Scene event handler with Custom event parameter
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param custom_event Custom event code
|
||||
* @return true if event was consumed, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param custom_event Custom event code
|
||||
*
|
||||
* @return true if event was consumed, false otherwise
|
||||
*/
|
||||
bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event);
|
||||
|
||||
/** Back event handler
|
||||
*
|
||||
* Calls Scene event handler with Back event parameter
|
||||
* @param scene_manager SceneManager instance
|
||||
* @return true if event was consumed, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
*
|
||||
* @return true if event was consumed, false otherwise
|
||||
*/
|
||||
bool scene_manager_handle_back_event(SceneManager* scene_manager);
|
||||
|
||||
/** Tick event handler
|
||||
*
|
||||
* Calls Scene event handler with Tick event parameter
|
||||
* @param scene_manager SceneManager instance
|
||||
* @return true if event was consumed, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @return true if event was consumed, false otherwise
|
||||
*/
|
||||
void scene_manager_handle_tick_event(SceneManager* scene_manager);
|
||||
|
||||
/** Add and run next Scene
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param next_scene_id next Scene ID
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param next_scene_id next Scene ID
|
||||
*/
|
||||
void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id);
|
||||
|
||||
/** Run previous Scene
|
||||
* @param scene_manager SceneManager instance
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
*
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*/
|
||||
bool scene_manager_previous_scene(SceneManager* scene_manager);
|
||||
|
||||
/** Search previous Scene
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
*
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*/
|
||||
bool scene_manager_has_previous_scene(SceneManager* scene_manager, uint32_t scene_id);
|
||||
|
||||
/** Search and switch to previous Scene
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
*
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*/
|
||||
bool scene_manager_search_and_switch_to_previous_scene(
|
||||
SceneManager* scene_manager,
|
||||
uint32_t scene_id);
|
||||
|
||||
/** Clear Scene stack and switch to another Scene
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*
|
||||
* @param scene_manager SceneManager instance
|
||||
* @param scene_id Scene ID
|
||||
*
|
||||
* @return true if previous scene was found, false otherwise
|
||||
*/
|
||||
bool scene_manager_search_and_switch_to_another_scene(
|
||||
SceneManager* scene_manager,
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file scene_manager_i.h
|
||||
* GUI: internal SceneManager API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "scene_manager.h"
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file view.h
|
||||
* GUI: View API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <input/input.h>
|
||||
@@ -27,57 +32,57 @@ typedef enum {
|
||||
typedef struct View View;
|
||||
|
||||
/** View Draw callback
|
||||
* @param canvas, pointer to canvas
|
||||
* @param view_model, pointer to context
|
||||
* @warning called from GUI thread
|
||||
* @param canvas, pointer to canvas
|
||||
* @param view_model, pointer to context
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewDrawCallback)(Canvas* canvas, void* model);
|
||||
|
||||
/** View Input callback
|
||||
* @param event, pointer to input event data
|
||||
* @param context, pointer to context
|
||||
* @return true if event handled, false if event ignored
|
||||
* @warning called from GUI thread
|
||||
* @param event, pointer to input event data
|
||||
* @param context, pointer to context
|
||||
* @return true if event handled, false if event ignored
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef bool (*ViewInputCallback)(InputEvent* event, void* context);
|
||||
|
||||
/** View Custom callback
|
||||
* @param event, number of custom event
|
||||
* @param context, pointer to context
|
||||
* @return true if event handled, false if event ignored
|
||||
* @param event, number of custom event
|
||||
* @param context, pointer to context
|
||||
* @return true if event handled, false if event ignored
|
||||
*/
|
||||
typedef bool (*ViewCustomCallback)(uint32_t event, void* context);
|
||||
|
||||
/** View navigation callback
|
||||
* @param context, pointer to context
|
||||
* @return next view id
|
||||
* @warning called from GUI thread
|
||||
* @param context, pointer to context
|
||||
* @return next view id
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef uint32_t (*ViewNavigationCallback)(void* context);
|
||||
|
||||
/** View callback
|
||||
* @param context, pointer to context
|
||||
* @warning called from GUI thread
|
||||
* @param context, pointer to context
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewCallback)(void* context);
|
||||
|
||||
/** View Update Callback
|
||||
* Called upon model change, need to be propagated to GUI throw ViewPort update
|
||||
* @param view, pointer to view
|
||||
* @param context, pointer to context
|
||||
* @warning called from GUI thread
|
||||
/** View Update Callback Called upon model change, need to be propagated to GUI
|
||||
* throw ViewPort update
|
||||
* @param view, pointer to view
|
||||
* @param context, pointer to context
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewUpdateCallback)(View* view, void* context);
|
||||
|
||||
/** View model types */
|
||||
typedef enum {
|
||||
/* Model is not allocated */
|
||||
/** Model is not allocated */
|
||||
ViewModelTypeNone,
|
||||
/* Model consist of atomic types and/or partial update is not critical for rendering.
|
||||
/** Model consist of atomic types and/or partial update is not critical for rendering.
|
||||
* Lock free.
|
||||
*/
|
||||
ViewModelTypeLockFree,
|
||||
/* Model access is guarded with mutex.
|
||||
/** Model access is guarded with mutex.
|
||||
* Locking gui thread.
|
||||
*/
|
||||
ViewModelTypeLocking,
|
||||
@@ -89,98 +94,115 @@ typedef enum {
|
||||
View* view_alloc();
|
||||
|
||||
/** Free View
|
||||
* @param View instance
|
||||
*
|
||||
* @param view instance
|
||||
*/
|
||||
void view_free(View* view);
|
||||
|
||||
/** Tie IconAnimation with View
|
||||
* @param view, View instance
|
||||
* @param icon_animation, IconAnimation instance
|
||||
*
|
||||
* @param view View instance
|
||||
* @param icon_animation IconAnimation instance
|
||||
*/
|
||||
void view_tie_icon_animation(View* view, IconAnimation* icon_animation);
|
||||
|
||||
/** Set View Draw callback
|
||||
* @param view, View instance
|
||||
* @param callback, draw callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback draw callback
|
||||
*/
|
||||
void view_set_draw_callback(View* view, ViewDrawCallback callback);
|
||||
|
||||
/** Set View Input callback
|
||||
* @param view, View instance
|
||||
* @param callback, input callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback input callback
|
||||
*/
|
||||
void view_set_input_callback(View* view, ViewInputCallback callback);
|
||||
|
||||
/** Set View Custom callback
|
||||
* @param view, View instance
|
||||
* @param callback, input callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback input callback
|
||||
*/
|
||||
void view_set_custom_callback(View* view, ViewCustomCallback callback);
|
||||
|
||||
/** Set Navigation Previous callback
|
||||
* @param view, View instance
|
||||
* @param callback, input callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback input callback
|
||||
*/
|
||||
void view_set_previous_callback(View* view, ViewNavigationCallback callback);
|
||||
|
||||
/** Set Enter callback
|
||||
* @param view, View instance
|
||||
* @param callback, callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback callback
|
||||
*/
|
||||
void view_set_enter_callback(View* view, ViewCallback callback);
|
||||
|
||||
/** Set Exit callback
|
||||
* @param view, View instance
|
||||
* @param callback, callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback callback
|
||||
*/
|
||||
void view_set_exit_callback(View* view, ViewCallback callback);
|
||||
|
||||
/** Set Update callback
|
||||
* @param view, View instance
|
||||
* @param callback, callback
|
||||
*
|
||||
* @param view View instance
|
||||
* @param callback callback
|
||||
*/
|
||||
void view_set_update_callback(View* view, ViewUpdateCallback callback);
|
||||
|
||||
/** Set View Draw callback
|
||||
* @param view, View instance
|
||||
* @param context, context for callbacks
|
||||
*
|
||||
* @param view View instance
|
||||
* @param context context for callbacks
|
||||
*/
|
||||
void view_set_update_callback_context(View* view, void* context);
|
||||
|
||||
/** Set View Draw callback
|
||||
* @param view, View instance
|
||||
* @param context, context for callbacks
|
||||
*
|
||||
* @param view View instance
|
||||
* @param context context for callbacks
|
||||
*/
|
||||
void view_set_context(View* view, void* context);
|
||||
|
||||
/** Set View Orientation
|
||||
* @param view, View instance
|
||||
* @param orientation, either vertical or horizontal
|
||||
*
|
||||
* @param view View instance
|
||||
* @param orientation either vertical or horizontal
|
||||
*/
|
||||
void view_set_orientation(View* view, ViewOrientation orientation);
|
||||
|
||||
/** Allocate view model.
|
||||
* @param view, View instance
|
||||
* @param type, View Model Type
|
||||
* @param size, size
|
||||
*
|
||||
* @param view View instance
|
||||
* @param type View Model Type
|
||||
* @param size size
|
||||
*/
|
||||
void view_allocate_model(View* view, ViewModelType type, size_t size);
|
||||
|
||||
/** Free view model data memory.
|
||||
* @param view, View instance
|
||||
*
|
||||
* @param view View instance
|
||||
*/
|
||||
void view_free_model(View* view);
|
||||
|
||||
/** Get view model data
|
||||
* @param view, View instance
|
||||
* @return pointer to model data
|
||||
* @warning Don't forget to commit model changes
|
||||
*
|
||||
* @param view View instance
|
||||
*
|
||||
* @return pointer to model data
|
||||
* @warning Don't forget to commit model changes
|
||||
*/
|
||||
void* view_get_model(View* view);
|
||||
|
||||
/** Commit view model
|
||||
* @param view, View instance
|
||||
* @param update, true if you want to emit view update, false otherwise
|
||||
*
|
||||
* @param view View instance
|
||||
* @param update true if you want to emit view update, false otherwise
|
||||
*/
|
||||
void view_commit_model(View* view, bool update);
|
||||
|
||||
@@ -196,11 +218,13 @@ void view_commit_model(View* view, bool update);
|
||||
view_commit_model(view, update); \
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* With clause for view model
|
||||
* @param view, View instance pointer
|
||||
* @param function_body a (){} lambda declaration, executed within you parent function context
|
||||
* @return true if you want to emit view update, false otherwise
|
||||
/** With clause for view model
|
||||
*
|
||||
* @param view View instance pointer
|
||||
* @param function_body a (){} lambda declaration, executed within you
|
||||
* parent function context
|
||||
*
|
||||
* @return true if you want to emit view update, false otherwise
|
||||
*/
|
||||
#define with_view_model(view, function_body) \
|
||||
{ \
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file view_dispatcher.h
|
||||
* GUI: ViewDispatcher API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "view.h"
|
||||
@@ -8,8 +13,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** ViewDispatcher view_port placement
|
||||
*/
|
||||
/** ViewDispatcher view_port placement */
|
||||
typedef enum {
|
||||
ViewDispatcherTypeNone, /**< Special layer for internal use only */
|
||||
ViewDispatcherTypeWindow, /**< Main view_port layer, status bar is shown */
|
||||
@@ -18,61 +22,70 @@ typedef enum {
|
||||
|
||||
typedef struct ViewDispatcher ViewDispatcher;
|
||||
|
||||
/** Prototype for custom event callback
|
||||
*/
|
||||
/** Prototype for custom event callback */
|
||||
typedef bool (*ViewDispatcherCustomEventCallback)(void* context, uint32_t event);
|
||||
|
||||
/** Prototype for navigation event callback
|
||||
*/
|
||||
/** Prototype for navigation event callback */
|
||||
typedef bool (*ViewDispatcherNavigationEventCallback)(void* context);
|
||||
|
||||
/** Prototype for tick event callback
|
||||
*/
|
||||
/** Prototype for tick event callback */
|
||||
typedef void (*ViewDispatcherTickEventCallback)(void* context);
|
||||
|
||||
/** Allocate ViewDispatcher instance
|
||||
* @return pointer to ViewDispatcher instance
|
||||
*
|
||||
* @return pointer to ViewDispatcher instance
|
||||
*/
|
||||
ViewDispatcher* view_dispatcher_alloc();
|
||||
|
||||
/** Free ViewDispatcher instance
|
||||
* @param view_dispatcher pointer to ViewDispatcher
|
||||
*
|
||||
* @param view_dispatcher pointer to ViewDispatcher
|
||||
*/
|
||||
void view_dispatcher_free(ViewDispatcher* view_dispatcher);
|
||||
|
||||
/** Enable queue support
|
||||
* If queue enabled all input and custom events will be dispatched throw internal queue
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*
|
||||
* If queue enabled all input and custom events will be dispatched throw
|
||||
* internal queue
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*/
|
||||
void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher);
|
||||
|
||||
/** Send custom event
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param[in] event The event
|
||||
*/
|
||||
void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
|
||||
|
||||
/** Set custom event handler
|
||||
*
|
||||
* Called on Custom Event, if it is not consumed by view
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param callback ViewDispatcherCustomEventCallback instance
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param callback ViewDispatcherCustomEventCallback instance
|
||||
*/
|
||||
void view_dispatcher_set_custom_event_callback(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
ViewDispatcherCustomEventCallback callback);
|
||||
|
||||
/** Set navigation event handler
|
||||
*
|
||||
* Called on Input Short Back Event, if it is not consumed by view
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param callback ViewDispatcherNavigationEventCallback instance
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param callback ViewDispatcherNavigationEventCallback instance
|
||||
*/
|
||||
void view_dispatcher_set_navigation_event_callback(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
ViewDispatcherNavigationEventCallback callback);
|
||||
|
||||
/** Set tick event handler
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param callback ViewDispatcherTickEventCallback
|
||||
* @param tick_period callback call period
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param callback ViewDispatcherTickEventCallback
|
||||
* @param tick_period callback call period
|
||||
*/
|
||||
void view_dispatcher_set_tick_event_callback(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
@@ -80,46 +93,57 @@ void view_dispatcher_set_tick_event_callback(
|
||||
uint32_t tick_period);
|
||||
|
||||
/** Set event callback context
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param context pointer to context
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param context pointer to context
|
||||
*/
|
||||
void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context);
|
||||
|
||||
/** Run ViewDispatcher
|
||||
*
|
||||
* Use only after queue enabled
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*/
|
||||
void view_dispatcher_run(ViewDispatcher* view_dispatcher);
|
||||
|
||||
/** Stop ViewDispatcher
|
||||
*
|
||||
* Use only after queue enabled
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
*/
|
||||
void view_dispatcher_stop(ViewDispatcher* view_dispatcher);
|
||||
|
||||
/** Add view to ViewDispatcher
|
||||
* @param view_dispatcher, ViewDispatcher instance
|
||||
* @param view_id View id to register
|
||||
* @param view View instance
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param view_id View id to register
|
||||
* @param view View instance
|
||||
*/
|
||||
void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view);
|
||||
|
||||
/** Remove view from ViewDispatcher
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param view_id View id to remove
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param view_id View id to remove
|
||||
*/
|
||||
void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_id);
|
||||
|
||||
/** Switch to View
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param view_id View id to register
|
||||
* @warning switching may be delayed till input events complementarity reached
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param view_id View id to register
|
||||
* @warning switching may be delayed till input events complementarity
|
||||
* reached
|
||||
*/
|
||||
void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t view_id);
|
||||
|
||||
/** Attach ViewDispatcher to GUI
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param gui GUI instance to attach to
|
||||
*
|
||||
* @param view_dispatcher ViewDispatcher instance
|
||||
* @param gui GUI instance to attach to
|
||||
* @param[in] type The type
|
||||
*/
|
||||
void view_dispatcher_attach_to_gui(
|
||||
ViewDispatcher* view_dispatcher,
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file view_dispatcher_i.h
|
||||
* GUI: ViewDispatcher API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <furi.h>
|
||||
@@ -41,23 +46,23 @@ typedef struct {
|
||||
};
|
||||
} ViewDispatcherMessage;
|
||||
|
||||
/* ViewPort Draw Callback */
|
||||
/** ViewPort Draw Callback */
|
||||
void view_dispatcher_draw_callback(Canvas* canvas, void* context);
|
||||
|
||||
/* ViewPort Input Callback */
|
||||
/** ViewPort Input Callback */
|
||||
void view_dispatcher_input_callback(InputEvent* event, void* context);
|
||||
|
||||
/* Input handler */
|
||||
/** Input handler */
|
||||
void view_dispatcher_handle_input(ViewDispatcher* view_dispatcher, InputEvent* event);
|
||||
|
||||
/* Tick handler */
|
||||
/** Tick handler */
|
||||
void view_dispatcher_handle_tick_event(ViewDispatcher* view_dispatcher);
|
||||
|
||||
/* Custom event handler */
|
||||
/** Custom event handler */
|
||||
void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32_t event);
|
||||
|
||||
/* Set current view, dispatches view enter and exit */
|
||||
/** Set current view, dispatches view enter and exit */
|
||||
void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view);
|
||||
|
||||
/* ViewDispatcher update event */
|
||||
/** ViewDispatcher update event */
|
||||
void view_dispatcher_update(View* view, void* context);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file view_i.h
|
||||
* GUI: internal View API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "view.h"
|
||||
@@ -26,26 +31,26 @@ struct View {
|
||||
void* context;
|
||||
};
|
||||
|
||||
/* IconAnimation tie callback */
|
||||
/** IconAnimation tie callback */
|
||||
void view_icon_animation_callback(IconAnimation* instance, void* context);
|
||||
|
||||
/* Unlock model */
|
||||
/** Unlock model */
|
||||
void view_unlock_model(View* view);
|
||||
|
||||
/* Draw Callback for View dispatcher */
|
||||
/** Draw Callback for View dispatcher */
|
||||
void view_draw(View* view, Canvas* canvas);
|
||||
|
||||
/* Input Callback for View dispatcher */
|
||||
/** Input Callback for View dispatcher */
|
||||
bool view_input(View* view, InputEvent* event);
|
||||
|
||||
/* Custom Callback for View dispatcher */
|
||||
/** Custom Callback for View dispatcher */
|
||||
bool view_custom(View* view, uint32_t event);
|
||||
|
||||
/* Previous Callback for View dispatcher */
|
||||
/** Previous Callback for View dispatcher */
|
||||
uint32_t view_previous(View* view);
|
||||
|
||||
/* Enter Callback for View dispatcher */
|
||||
/** Enter Callback for View dispatcher */
|
||||
void view_enter(View* view);
|
||||
|
||||
/* Exit Callback for View dispatcher */
|
||||
/** Exit Callback for View dispatcher */
|
||||
void view_exit(View* view);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file view_port.h
|
||||
* GUI: ViewPort API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <input/input.h>
|
||||
@@ -15,50 +20,65 @@ typedef enum {
|
||||
} ViewPortOrientation;
|
||||
|
||||
/** ViewPort Draw callback
|
||||
* @warning called from GUI thread
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewPortDrawCallback)(Canvas* canvas, void* context);
|
||||
|
||||
/** ViewPort Input callback
|
||||
* @warning called from GUI thread
|
||||
* @warning called from GUI thread
|
||||
*/
|
||||
typedef void (*ViewPortInputCallback)(InputEvent* event, void* context);
|
||||
|
||||
/** ViewPort allocator
|
||||
*
|
||||
* always returns view_port or stops system if not enough memory.
|
||||
*
|
||||
* @return ViewPort instance
|
||||
*/
|
||||
ViewPort* view_port_alloc();
|
||||
|
||||
/** ViewPort deallocator
|
||||
*
|
||||
* Ensure that view_port was unregistered in GUI system before use.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void view_port_free(ViewPort* view_port);
|
||||
|
||||
/** Set view_port width.
|
||||
*
|
||||
* Will be used to limit canvas drawing area and autolayout feature.
|
||||
* @param width - wanted width, 0 - auto.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param width wanted width, 0 - auto.
|
||||
*/
|
||||
void view_port_set_width(ViewPort* view_port, uint8_t width);
|
||||
uint8_t view_port_get_width(ViewPort* view_port);
|
||||
|
||||
/** Set view_port height.
|
||||
*
|
||||
* Will be used to limit canvas drawing area and autolayout feature.
|
||||
* @param height - wanted height, 0 - auto.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param height wanted height, 0 - auto.
|
||||
*/
|
||||
void view_port_set_height(ViewPort* view_port, uint8_t height);
|
||||
uint8_t view_port_get_height(ViewPort* view_port);
|
||||
|
||||
/** Enable or disable view_port rendering.
|
||||
* @param view_port - ViewPort instance
|
||||
* @param enabled
|
||||
* @warning automatically dispatches update event
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param enabled Indicates if enabled
|
||||
* @warning automatically dispatches update event
|
||||
*/
|
||||
void view_port_enabled_set(ViewPort* view_port, bool enabled);
|
||||
bool view_port_is_enabled(ViewPort* view_port);
|
||||
|
||||
/** ViewPort event callbacks
|
||||
* @param callback - appropriate callback function
|
||||
* @param context - context to pass to callback
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param callback appropriate callback function
|
||||
* @param context context to pass to callback
|
||||
*/
|
||||
void view_port_draw_callback_set(ViewPort* view_port, ViewPortDrawCallback callback, void* context);
|
||||
void view_port_input_callback_set(
|
||||
@@ -67,12 +87,17 @@ void view_port_input_callback_set(
|
||||
void* context);
|
||||
|
||||
/** Emit update signal to GUI system.
|
||||
*
|
||||
* Rendering will happen later after GUI system process signal.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
*/
|
||||
void view_port_update(ViewPort* view_port);
|
||||
|
||||
/** Set ViewPort orientation.
|
||||
* @param orientation, display orientation, horizontal or vertical.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param orientation display orientation, horizontal or vertical.
|
||||
*/
|
||||
void view_port_set_orientation(ViewPort* view_port, ViewPortOrientation orientation);
|
||||
ViewPortOrientation view_port_get_orientation(const ViewPort* view_port);
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @file view_port_i.h
|
||||
* GUI: internal ViewPort API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gui_i.h"
|
||||
@@ -18,23 +23,29 @@ struct ViewPort {
|
||||
void* input_callback_context;
|
||||
};
|
||||
|
||||
/*
|
||||
* Set GUI reference.
|
||||
/** Set GUI reference.
|
||||
*
|
||||
* To be used by GUI, called upon view_port tree insert
|
||||
* @param gui - gui instance pointer.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param gui gui instance pointer
|
||||
*/
|
||||
void view_port_gui_set(ViewPort* view_port, Gui* gui);
|
||||
|
||||
/*
|
||||
* Process draw call. Calls draw callback.
|
||||
/** Process draw call. Calls draw callback.
|
||||
*
|
||||
* To be used by GUI, called on tree redraw.
|
||||
* @param canvas - canvas to draw at.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param canvas canvas to draw at
|
||||
*/
|
||||
void view_port_draw(ViewPort* view_port, Canvas* canvas);
|
||||
|
||||
/*
|
||||
* Process input. Calls input callbac
|
||||
/** Process input. Calls input callback.
|
||||
*
|
||||
* To be used by GUI, called on input dispatch.
|
||||
* @param event - pointer to input event.
|
||||
*
|
||||
* @param view_port ViewPort instance
|
||||
* @param event pointer to input event
|
||||
*/
|
||||
void view_port_input(ViewPort* view_port, InputEvent* event);
|
||||
|
||||
Reference in New Issue
Block a user