Gui: Update elements API

This commit is contained in:
Willy-JL
2024-05-03 10:55:14 +01:00
parent dbdb33f078
commit a1b62fd9f3
3 changed files with 28 additions and 38 deletions

View File

@@ -101,14 +101,17 @@ void elements_scrollbar_horizontal(
size_t pos,
size_t total) {
furi_check(canvas);
// prevent overflows
canvas_set_color(canvas, ColorWhite);
canvas_draw_box(canvas, x, y - 3, width, 3);
// dot line
canvas_set_color(canvas, ColorBlack);
for(size_t i = x; i < width + x; i += 2) {
canvas_draw_dot(canvas, i, y - 2);
}
// Position block
if(total) {
float block_w = ((float)width) / total;
@@ -606,12 +609,23 @@ void elements_string_fit_width(Canvas* canvas, FuriString* string, size_t width)
}
}
void elements_scrollable_text_line_str(
void elements_scrollable_text_line(
Canvas* canvas,
int32_t x,
int32_t y,
size_t width,
const char* string,
FuriString* string,
size_t scroll,
bool ellipsis) {
elements_scrollable_text_line_centered(canvas, x, y, width, string, scroll, ellipsis, false);
}
void elements_scrollable_text_line_centered(
Canvas* canvas,
int32_t x,
int32_t y,
size_t width,
FuriString* string,
size_t scroll,
bool ellipsis,
bool centered) {
@@ -667,31 +681,6 @@ void elements_scrollable_text_line_str(
furi_string_free(line);
}
void elements_scrollable_text_line(
Canvas* canvas,
int32_t x,
int32_t y,
size_t width,
FuriString* string,
size_t scroll,
bool ellipsis) {
elements_scrollable_text_line_str(
canvas, x, y, width, furi_string_get_cstr(string), scroll, ellipsis, false);
}
void elements_scrollable_text_line_centered(
Canvas* canvas,
int32_t x,
int32_t y,
size_t width,
FuriString* string,
size_t scroll,
bool ellipsis,
bool centered) {
elements_scrollable_text_line_str(
canvas, x, y, width, furi_string_get_cstr(string), scroll, ellipsis, centered);
}
void elements_text_box(
Canvas* canvas,
int32_t x,

View File

@@ -229,17 +229,7 @@ void elements_string_fit_width(Canvas* canvas, FuriString* string, size_t width)
* @param string The string
* @param[in] scroll The scroll counter: 0 - no scroll, any other number - scroll. Just count up, everything else will be calculated on the inside.
* @param[in] ellipsis The ellipsis flag: true to add ellipse
* @param[in] centered The centered flag: true to center text on x and y
*/
void elements_scrollable_text_line_str(
Canvas* canvas,
int32_t x,
int32_t y,
size_t width,
const char* string,
size_t scroll,
bool ellipsis,
bool centered);
void elements_scrollable_text_line(
Canvas* canvas,
int32_t x,
@@ -248,6 +238,18 @@ void elements_scrollable_text_line(
FuriString* string,
size_t scroll,
bool ellipsis);
/** Draw scrollable text line, optionally centered
*
* @param canvas The canvas
* @param[in] x X coordinate
* @param[in] y Y coordinate
* @param[in] width The width
* @param string The string
* @param[in] scroll The scroll counter: 0 - no scroll, any other number - scroll. Just count up, everything else will be calculated on the inside.
* @param[in] ellipsis The ellipsis flag: true to add ellipse
* @param[in] centered The centered flag: true to center text horizontally, x coordinate will indicate the middle
*/
void elements_scrollable_text_line_centered(
Canvas* canvas,
int32_t x,