Flipper Zero Firmware
Loading...
Searching...
No Matches
elements.h File Reference

GUI: Elements API. More...

#include <stdint.h>
#include <furi.h>
#include "canvas.h"

Go to the source code of this file.

Macros

#define ELEMENTS_MAX_LINES_NUM   (7)
 
#define ELEMENTS_BOLD_MARKER   '#'
 
#define ELEMENTS_MONO_MARKER   '*'
 
#define ELEMENTS_INVERSE_MARKER   '!'
 

Functions

void elements_progress_bar (Canvas *canvas, int32_t x, int32_t y, size_t width, float progress)
 Draw progress bar.
 
void elements_progress_bar_with_text (Canvas *canvas, int32_t x, int32_t y, size_t width, float progress, const char *text)
 Draw progress bar with text.
 
void elements_scrollbar_pos (Canvas *canvas, int32_t x, int32_t y, size_t height, size_t pos, size_t total)
 Draw scrollbar on canvas at specific position.
 
void elements_scrollbar (Canvas *canvas, size_t pos, size_t total)
 Draw scrollbar on canvas.
 
void elements_frame (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw rounded frame.
 
void elements_button_left (Canvas *canvas, const char *str)
 Draw button in left corner.
 
void elements_button_right (Canvas *canvas, const char *str)
 Draw button in right corner.
 
void elements_button_center (Canvas *canvas, const char *str)
 Draw button in center.
 
void elements_multiline_text_aligned (Canvas *canvas, int32_t x, int32_t y, Align horizontal, Align vertical, const char *text)
 Draw aligned multiline text.
 
void elements_multiline_text (Canvas *canvas, int32_t x, int32_t y, const char *text)
 Draw multiline text.
 
void elements_multiline_text_framed (Canvas *canvas, int32_t x, int32_t y, const char *text)
 Draw framed multiline text.
 
void elements_slightly_rounded_frame (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw slightly rounded frame.
 
void elements_slightly_rounded_box (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw slightly rounded box.
 
void elements_bold_rounded_frame (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw bold rounded frame.
 
void elements_bubble (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height)
 Draw bubble frame for text.
 
void elements_bubble_str (Canvas *canvas, int32_t x, int32_t y, const char *text, Align horizontal, Align vertical)
 Draw bubble frame for text with corner.
 
void elements_string_fit_width (Canvas *canvas, FuriString *string, size_t width)
 Trim string buffer to fit width in pixels.
 
void elements_scrollable_text_line (Canvas *canvas, int32_t x, int32_t y, size_t width, FuriString *string, size_t scroll, bool ellipsis)
 Draw scrollable text line.
 
void elements_text_box (Canvas *canvas, int32_t x, int32_t y, size_t width, size_t height, Align horizontal, Align vertical, const char *text, bool strip_to_dots)
 Draw text box element.
 

Detailed Description

GUI: Elements API.

Canvas helpers and UI building blocks.

Function Documentation

◆ elements_bold_rounded_frame()

void elements_bold_rounded_frame ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw bold rounded frame.

Parameters
canvasCanvas instance
xtop left corner coordinates
ytop left corner coordinates
widthwidth of frame
heightheight of frame

◆ elements_bubble()

void elements_bubble ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw bubble frame for text.

Parameters
canvasCanvas instance
xleft x coordinates
ytop y coordinate
widthbubble width
heightbubble height

◆ elements_bubble_str()

void elements_bubble_str ( Canvas * canvas,
int32_t x,
int32_t y,
const char * text,
Align horizontal,
Align vertical )

Draw bubble frame for text with corner.

Parameters
canvasCanvas instance
xleft x coordinates
ytop y coordinate
texttext to display
horizontalhorizontal aligning
verticalaligning

◆ elements_button_center()

void elements_button_center ( Canvas * canvas,
const char * str )

Draw button in center.

Parameters
canvasCanvas instance
strbutton text

◆ elements_button_left()

void elements_button_left ( Canvas * canvas,
const char * str )

Draw button in left corner.

Parameters
canvasCanvas instance
strbutton text

◆ elements_button_right()

void elements_button_right ( Canvas * canvas,
const char * str )

Draw button in right corner.

Parameters
canvasCanvas instance
strbutton text

◆ elements_frame()

void elements_frame ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw rounded frame.

Parameters
canvasCanvas instance
x,ytop left corner coordinates
width,heightframe width and height

◆ elements_multiline_text()

void elements_multiline_text ( Canvas * canvas,
int32_t x,
int32_t y,
const char * text )

Draw multiline text.

Parameters
canvasCanvas instance
xtop left corner coordinates
ytop left corner coordinates
textstring (possible multiline)

◆ elements_multiline_text_aligned()

void elements_multiline_text_aligned ( Canvas * canvas,
int32_t x,
int32_t y,
Align horizontal,
Align vertical,
const char * text )

Draw aligned multiline text.

Parameters
canvasCanvas instance
x,ycoordinates based on align param
horizontal,verticalalignment of multiline text
textstring (possible multiline)

◆ elements_multiline_text_framed()

void elements_multiline_text_framed ( Canvas * canvas,
int32_t x,
int32_t y,
const char * text )

Draw framed multiline text.

Parameters
canvasCanvas instance
xtop left corner coordinates
ytop left corner coordinates
textstring (possible multiline)

◆ elements_progress_bar()

void elements_progress_bar ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
float progress )

Draw progress bar.

Parameters
canvasCanvas instance
xprogress bar position on X axis
yprogress bar position on Y axis
widthprogress bar width
progressprogress (0.0 - 1.0)

◆ elements_progress_bar_with_text()

void elements_progress_bar_with_text ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
float progress,
const char * text )

Draw progress bar with text.

Parameters
canvasCanvas instance
xprogress bar position on X axis
yprogress bar position on Y axis
widthprogress bar width
progressprogress (0.0 - 1.0)
texttext to draw

◆ elements_scrollable_text_line()

void elements_scrollable_text_line ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
FuriString * string,
size_t scroll,
bool ellipsis )

Draw scrollable text line.

Parameters
canvasThe canvas
[in]xX coordinate
[in]yY coordinate
[in]widthThe width
stringThe string
[in]scrollThe scroll counter: 0 - no scroll, any other number - scroll. Just count up, everything else will be calculated on the inside.
[in]ellipsisThe ellipsis flag: true to add ellipse

◆ elements_scrollbar()

void elements_scrollbar ( Canvas * canvas,
size_t pos,
size_t total )

Draw scrollbar on canvas.

Note
width 3px, height equal to canvas height
Parameters
canvasCanvas instance
poscurrent element of total elements
totaltotal elements

◆ elements_scrollbar_pos()

void elements_scrollbar_pos ( Canvas * canvas,
int32_t x,
int32_t y,
size_t height,
size_t pos,
size_t total )

Draw scrollbar on canvas at specific position.

Parameters
canvasCanvas instance
xscrollbar position on X axis
yscrollbar position on Y axis
heightscrollbar height
poscurrent element
totaltotal elements

◆ elements_slightly_rounded_box()

void elements_slightly_rounded_box ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw slightly rounded box.

Parameters
canvasCanvas instance
xtop left corner coordinates
ytop left corner coordinates
widthheight of box
heightheight of box

◆ elements_slightly_rounded_frame()

void elements_slightly_rounded_frame ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height )

Draw slightly rounded frame.

Parameters
canvasCanvas instance
xtop left corner coordinates
ytop left corner coordinates
widthwidth of frame
heightheight of frame

◆ elements_string_fit_width()

void elements_string_fit_width ( Canvas * canvas,
FuriString * string,
size_t width )

Trim string buffer to fit width in pixels.

Parameters
canvasCanvas instance
stringstring to trim
widthmax width

◆ elements_text_box()

void elements_text_box ( Canvas * canvas,
int32_t x,
int32_t y,
size_t width,
size_t height,
Align horizontal,
Align vertical,
const char * text,
bool strip_to_dots )

Draw text box element.

Parameters
canvasCanvas instance
xx coordinate
yy coordinate
widthwidth to fit text
heightheight to fit text
horizontalAlign instance
verticalAlign instance
[in]textFormatted text. The following formats are available: "\e#Bold text\e#" - bold font is used "\e*Monospaced text\e*" - monospaced font is used "\e!Inverted text\e!" - white text on black background
strip_to_dotsStrip text to ... if does not fit to width