2021-10-03 10:36:05 +00:00
|
|
|
/**
|
|
|
|
* @file widget.h
|
|
|
|
* GUI: Widget view module API
|
|
|
|
*/
|
|
|
|
|
2021-07-23 13:09:34 +00:00
|
|
|
#pragma once
|
2021-10-03 10:36:05 +00:00
|
|
|
|
2021-07-23 13:09:34 +00:00
|
|
|
#include "widget_elements/widget_element_i.h"
|
|
|
|
|
2022-01-03 00:01:54 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2021-07-23 13:09:34 +00:00
|
|
|
typedef struct Widget Widget;
|
|
|
|
typedef struct WidgetElement WidgetElement;
|
|
|
|
|
|
|
|
/** Allocate Widget that holds Widget Elements
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @return Widget instance
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
|
|
|
Widget* widget_alloc();
|
|
|
|
|
|
|
|
/** Free Widget
|
2021-10-03 10:36:05 +00:00
|
|
|
* @note this function free allocated Widget Elements
|
|
|
|
*
|
|
|
|
* @param widget Widget instance
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
|
|
|
void widget_free(Widget* widget);
|
|
|
|
|
2022-02-02 19:59:28 +00:00
|
|
|
/** Reset Widget
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param widget Widget instance
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
2022-02-02 19:59:28 +00:00
|
|
|
void widget_reset(Widget* widget);
|
2021-07-23 13:09:34 +00:00
|
|
|
|
|
|
|
/** Get Widget view
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param widget Widget instance
|
|
|
|
*
|
|
|
|
* @return View instance
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
|
|
|
View* widget_get_view(Widget* widget);
|
|
|
|
|
2021-09-10 00:29:57 +00:00
|
|
|
/** Add Multi String Element
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @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
|
2021-09-10 00:29:57 +00:00
|
|
|
*/
|
2021-09-15 15:24:19 +00:00
|
|
|
void widget_add_string_multiline_element(
|
2021-09-10 00:29:57 +00:00
|
|
|
Widget* widget,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
Align horizontal,
|
|
|
|
Align vertical,
|
|
|
|
Font font,
|
|
|
|
const char* text);
|
|
|
|
|
2021-07-23 13:09:34 +00:00
|
|
|
/** Add String Element
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @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
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
|
|
|
void widget_add_string_element(
|
|
|
|
Widget* widget,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
Align horizontal,
|
|
|
|
Align vertical,
|
|
|
|
Font font,
|
|
|
|
const char* text);
|
|
|
|
|
2021-10-27 18:55:03 +00:00
|
|
|
/** Add Text Box Element
|
|
|
|
*
|
2022-04-19 19:23:50 +00:00
|
|
|
* @param widget Widget instance
|
|
|
|
* @param x x coordinate
|
|
|
|
* @param y y coordinate
|
|
|
|
* @param width width to fit text
|
|
|
|
* @param height height to fit text
|
|
|
|
* @param horizontal Align instance
|
|
|
|
* @param vertical Align instance
|
|
|
|
* @param[in] text Formatted text. The following formats are available:
|
|
|
|
* "\e#Bold text\e#" - bold font is used
|
|
|
|
* "\e*Monospaced text\e*" - monospaced font is used
|
|
|
|
* "\e#Inversed text\e#" - white text on black background
|
|
|
|
* @param strip_to_dots Strip text to ... if does not fit to width
|
2021-10-27 18:55:03 +00:00
|
|
|
*/
|
|
|
|
void widget_add_text_box_element(
|
|
|
|
Widget* widget,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
uint8_t width,
|
|
|
|
uint8_t height,
|
|
|
|
Align horizontal,
|
|
|
|
Align vertical,
|
2022-04-19 19:23:50 +00:00
|
|
|
const char* text,
|
|
|
|
bool strip_to_dots);
|
2021-10-27 18:55:03 +00:00
|
|
|
|
2022-08-17 15:08:13 +00:00
|
|
|
/** Add Text Scroll Element
|
|
|
|
*
|
|
|
|
* @param widget Widget instance
|
|
|
|
* @param x x coordinate
|
|
|
|
* @param y y coordinate
|
|
|
|
* @param width width to fit text
|
|
|
|
* @param height height to fit text
|
|
|
|
* @param[in] text Formatted text. Default format: align left, Secondary font.
|
|
|
|
* The following formats are available:
|
|
|
|
* "\e#Bold text" - sets bold font before until next '\n' symbol
|
2022-08-18 12:43:28 +00:00
|
|
|
* "\ecCenter-aligned text" - sets center horizontal align until the next '\n' symbol
|
|
|
|
* "\erRight-aligned text" - sets right horizontal align until the next '\n' symbol
|
2022-08-17 15:08:13 +00:00
|
|
|
*/
|
|
|
|
void widget_add_text_scroll_element(
|
|
|
|
Widget* widget,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
uint8_t width,
|
|
|
|
uint8_t height,
|
|
|
|
const char* text);
|
|
|
|
|
2021-07-23 13:09:34 +00:00
|
|
|
/** Add Button Element
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param widget Widget instance
|
|
|
|
* @param button_type GuiButtonType instance
|
|
|
|
* @param text text on allocated button
|
|
|
|
* @param callback ButtonCallback instance
|
|
|
|
* @param context pointer to context
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
|
|
|
void widget_add_button_element(
|
|
|
|
Widget* widget,
|
|
|
|
GuiButtonType button_type,
|
|
|
|
const char* text,
|
|
|
|
ButtonCallback callback,
|
|
|
|
void* context);
|
|
|
|
|
|
|
|
/** Add Icon Element
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @param widget Widget instance
|
|
|
|
* @param x top left x coordinate
|
|
|
|
* @param y top left y coordinate
|
|
|
|
* @param icon Icon instance
|
2021-07-23 13:09:34 +00:00
|
|
|
*/
|
|
|
|
void widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon);
|
2021-08-20 19:56:43 +00:00
|
|
|
|
|
|
|
/** Add Frame Element
|
2021-10-03 10:36:05 +00:00
|
|
|
*
|
|
|
|
* @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
|
2021-08-20 19:56:43 +00:00
|
|
|
*/
|
|
|
|
void widget_add_frame_element(
|
|
|
|
Widget* widget,
|
|
|
|
uint8_t x,
|
|
|
|
uint8_t y,
|
|
|
|
uint8_t width,
|
|
|
|
uint8_t height,
|
|
|
|
uint8_t radius);
|
2022-01-03 00:01:54 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|