[FL-1110] Status bar height fix (#403)
* fix statusbar height and main screen views, added multiline text framed func * replace char* arguments with const char* * small prettify * move pointer increment to end of loop
This commit is contained in:
@@ -171,14 +171,14 @@ void elements_multiline_text_aligned(
|
||||
string_clear(str);
|
||||
}
|
||||
|
||||
void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, char* text) {
|
||||
void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* text) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(text);
|
||||
|
||||
uint8_t font_height = canvas_current_font_height(canvas);
|
||||
string_t str;
|
||||
string_init(str);
|
||||
char* start = text;
|
||||
const char* start = text;
|
||||
char* end;
|
||||
do {
|
||||
end = strchr(start, '\n');
|
||||
@@ -194,6 +194,31 @@ void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, char* text) {
|
||||
string_clear(str);
|
||||
}
|
||||
|
||||
void elements_multiline_text_framed(Canvas* canvas, uint8_t x, uint8_t y, const char* text) {
|
||||
furi_assert(canvas);
|
||||
furi_assert(text);
|
||||
|
||||
uint8_t font_y = canvas_current_font_height(canvas);
|
||||
uint16_t str_width = canvas_string_width(canvas, text);
|
||||
// count \n's
|
||||
uint8_t lines = 1;
|
||||
const char* t = text;
|
||||
while(*t != '\0') {
|
||||
if(*t == '\n') {
|
||||
lines++;
|
||||
uint16_t temp_width = canvas_string_width(canvas, t + 1);
|
||||
str_width = temp_width > str_width ? temp_width : str_width;
|
||||
}
|
||||
t++;
|
||||
}
|
||||
|
||||
canvas_set_color(canvas, ColorWhite);
|
||||
canvas_draw_box(canvas, x, y - font_y, str_width + 8, font_y * lines + 6);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
elements_multiline_text(canvas, x + 4, y + 1, text);
|
||||
elements_frame(canvas, x, y - font_y, str_width + 8, font_y * lines + 6);
|
||||
}
|
||||
|
||||
void elements_slightly_rounded_frame(
|
||||
Canvas* canvas,
|
||||
uint8_t x,
|
||||
|
@@ -59,7 +59,14 @@ void elements_multiline_text_aligned(
|
||||
* @param x, y - top left corner coordinates
|
||||
* @param text - string (possible multiline)
|
||||
*/
|
||||
void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, char* text);
|
||||
void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* text);
|
||||
|
||||
/*
|
||||
* Draw framed multiline text
|
||||
* @param x, y - top left corner coordinates
|
||||
* @param text - string (possible multiline)
|
||||
*/
|
||||
void elements_multiline_text_framed(Canvas* canvas, uint8_t x, uint8_t y, const char* text);
|
||||
|
||||
/*
|
||||
* Draw slightly rounded frame
|
||||
|
@@ -18,7 +18,7 @@
|
||||
#define GUI_STATUS_BAR_X 0
|
||||
#define GUI_STATUS_BAR_Y 0
|
||||
#define GUI_STATUS_BAR_WIDTH GUI_DISPLAY_WIDTH
|
||||
#define GUI_STATUS_BAR_HEIGHT 8
|
||||
#define GUI_STATUS_BAR_HEIGHT 13
|
||||
|
||||
#define GUI_MAIN_X 0
|
||||
#define GUI_MAIN_Y 9
|
||||
|
Reference in New Issue
Block a user