[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:
parent
33a461e97b
commit
5cd73ac97b
@ -12,48 +12,46 @@ void dolphin_view_first_start_draw(Canvas* canvas, void* model) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
uint8_t font_height = canvas_current_font_height(canvas);
|
||||
uint8_t width = canvas_width(canvas);
|
||||
uint8_t height = canvas_height(canvas);
|
||||
if(m->page == 0) {
|
||||
canvas_draw_icon_name(canvas, 0, height - 53, I_DolphinFirstStart0_70x53);
|
||||
elements_multiline_text(canvas, 75, 20, "Hey m8,\npress > to\ncontinue");
|
||||
elements_frame(canvas, 72, 20 - font_height, width - 70 - 4, font_height * 3 + 4);
|
||||
canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart0_70x53);
|
||||
elements_multiline_text_framed(canvas, 75, 20, "Hey m8,\npress > to\ncontinue");
|
||||
} else if(m->page == 1) {
|
||||
canvas_draw_icon_name(canvas, 0, height - 53, I_DolphinFirstStart1_59x53);
|
||||
elements_multiline_text(canvas, 64, 20, "First Of All,\n... >");
|
||||
elements_frame(canvas, 61, 20 - font_height, width - 59 - 4, font_height * 2 + 4);
|
||||
canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart1_59x53);
|
||||
elements_multiline_text_framed(canvas, 64, 20, "First Of All,\n... >");
|
||||
} else if(m->page == 2) {
|
||||
canvas_draw_icon_name(canvas, 0, height - 51, I_DolphinFirstStart2_59x51);
|
||||
elements_multiline_text(canvas, 64, 20, "Thank you\nfor your\nsupport! >");
|
||||
elements_frame(canvas, 61, 20 - font_height, width - 59 - 4, font_height * 3 + 4);
|
||||
canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart2_59x51);
|
||||
elements_multiline_text_framed(canvas, 64, 20, "Thank you\nfor your\nsupport! >");
|
||||
} else if(m->page == 3) {
|
||||
canvas_draw_icon_name(canvas, width - 57, height - 48, I_DolphinFirstStart3_57x48);
|
||||
elements_multiline_text(canvas, 5, 20, "Kickstarter\ncampaign\nwas INSANE! >");
|
||||
elements_frame(canvas, 2, 20 - font_height, width - 57 - 4, font_height * 3 + 4);
|
||||
elements_multiline_text_framed(canvas, 0, 20, "Kickstarter\ncampaign\nwas INSANE! >");
|
||||
} else if(m->page == 4) {
|
||||
canvas_draw_icon_name(canvas, width - 67, height - 53, I_DolphinFirstStart4_67x53);
|
||||
elements_multiline_text(canvas, 5, 10, "Now\nallow me\nto introduce\nmyself >");
|
||||
elements_frame(canvas, 2, 10 - font_height, width - 67 - 4, font_height * 4 + 4);
|
||||
canvas_draw_icon_name(canvas, width - 67, height - 50, I_DolphinFirstStart4_67x53);
|
||||
elements_multiline_text_framed(canvas, 0, 17, "Now\nallow me\nto introduce\nmyself >");
|
||||
} else if(m->page == 5) {
|
||||
canvas_draw_icon_name(canvas, 0, height - 53, I_DolphinFirstStart5_45x53);
|
||||
elements_multiline_text(
|
||||
canvas, 50, 20, "I am Flipper,\ncyberdolphin\nliving in your\npocket >");
|
||||
elements_frame(canvas, 47, 20 - font_height, width - 45 - 4, font_height * 4 + 4);
|
||||
char buf[64];
|
||||
snprintf(
|
||||
buf,
|
||||
64,
|
||||
"%s %s%s",
|
||||
"I am",
|
||||
api_hal_version_get_name_ptr(),
|
||||
",\ncyberdolphin\nliving in your\npocket >");
|
||||
canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart5_45x53);
|
||||
elements_multiline_text_framed(canvas, 60, 17, buf);
|
||||
} else if(m->page == 6) {
|
||||
canvas_draw_icon_name(canvas, 0, height - 54, I_DolphinFirstStart6_58x54);
|
||||
elements_multiline_text(
|
||||
canvas, 63, 20, "I can grow\n smart'n'cool\nif you use me\noften >");
|
||||
elements_frame(canvas, 60, 20 - font_height, width - 58 - 4, font_height * 4 + 4);
|
||||
canvas_draw_icon_name(canvas, 0, height - 48, I_DolphinFirstStart6_58x54);
|
||||
elements_multiline_text_framed(
|
||||
canvas, 63, 17, "I can grow\nsmart'n'cool\nif you use me\noften >");
|
||||
} else if(m->page == 7) {
|
||||
canvas_draw_icon_name(canvas, width - 61, height - 51, I_DolphinFirstStart7_61x51);
|
||||
elements_multiline_text(canvas, 5, 10, "As long as\nyou read, write\nand emulate >");
|
||||
elements_frame(canvas, 2, 10 - font_height, width - 54 - 4, font_height * 3 + 4);
|
||||
canvas_draw_icon_name(canvas, width - 61, height - 48, I_DolphinFirstStart7_61x51);
|
||||
elements_multiline_text_framed(
|
||||
canvas, 0, 17, "As long as\nyou read, write\nand emulate >");
|
||||
} else if(m->page == 8) {
|
||||
canvas_draw_icon_name(canvas, width - 56, height - 51, I_DolphinFirstStart8_56x51);
|
||||
elements_multiline_text(
|
||||
canvas, 5, 10, "You can check\nmy level and\nmood in the\nPassport menu");
|
||||
elements_frame(canvas, 2, 10 - font_height, width - 56 - 4, font_height * 4 + 4);
|
||||
canvas_draw_icon_name(canvas, width - 56, height - 48, I_DolphinFirstStart8_56x51);
|
||||
elements_multiline_text_framed(
|
||||
canvas, 0, 17, "You can check\nmy level and\nmood in the\nPassport menu");
|
||||
}
|
||||
}
|
||||
|
||||
@ -143,13 +141,13 @@ void dolphin_view_hw_mismatch_draw(Canvas* canvas, void* model) {
|
||||
canvas_clear(canvas);
|
||||
canvas_set_color(canvas, ColorBlack);
|
||||
canvas_set_font(canvas, FontPrimary);
|
||||
canvas_draw_str(canvas, 2, 10, "!!!! HW Mismatch !!!!");
|
||||
canvas_draw_str(canvas, 2, 15, "!!!! HW Mismatch !!!!");
|
||||
|
||||
char buffer[64];
|
||||
canvas_set_font(canvas, FontSecondary);
|
||||
snprintf(buffer, 64, "HW target: F%d", api_hal_version_get_hw_target());
|
||||
canvas_draw_str(canvas, 5, 22, buffer);
|
||||
canvas_draw_str(canvas, 5, 32, "FW target: " TARGET);
|
||||
canvas_draw_str(canvas, 5, 27, buffer);
|
||||
canvas_draw_str(canvas, 5, 37, "FW target: " TARGET);
|
||||
}
|
||||
|
||||
uint32_t dolphin_view_idle_back(void* context) {
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user