From 5f94d52516f72d6d34179d3f9bbcf17c1fbefeaf Mon Sep 17 00:00:00 2001 From: 956MB Date: Sun, 16 Mar 2025 17:38:05 -0500 Subject: [PATCH] Merge remote-tracking branch '956MB:fix/custom-font-bubble-acsent' into 956/prs #385 --- .../animations/views/bubble_animation_view.c | 6 +++++- .../services/desktop/views/desktop_view_locked.c | 15 +++++++++++++-- applications/services/gui/canvas.h | 2 ++ applications/services/gui/elements.c | 3 ++- applications/services/gui/elements.h | 2 ++ targets/f7/api_symbols.csv | 2 +- 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/applications/services/desktop/animations/views/bubble_animation_view.c b/applications/services/desktop/animations/views/bubble_animation_view.c index 16f68975d..a54774205 100644 --- a/applications/services/desktop/animations/views/bubble_animation_view.c +++ b/applications/services/desktop/animations/views/bubble_animation_view.c @@ -84,7 +84,11 @@ static void bubble_animation_draw_callback(Canvas* canvas, void* model_) { if((model->current_frame >= bubble->start_frame) && (model->current_frame <= bubble->end_frame)) { const Bubble* b = &bubble->bubble; - elements_bubble_str(canvas, b->x, b->y, b->text, b->align_h, b->align_v); + const CanvasFontParameters* font_params = + canvas_get_font_params(canvas, FontSecondary); + int32_t y_offset = + font_params != &canvas_font_params[FontSecondary] ? (font_params->height / 2) : 0; + elements_bubble_str(canvas, b->x, b->y, y_offset, b->text, b->align_h, b->align_v); } } } diff --git a/applications/services/desktop/views/desktop_view_locked.c b/applications/services/desktop/views/desktop_view_locked.c index f21934485..858e73798 100644 --- a/applications/services/desktop/views/desktop_view_locked.c +++ b/applications/services/desktop/views/desktop_view_locked.c @@ -117,13 +117,24 @@ void desktop_view_locked_draw_lockscreen(Canvas* canvas, void* m) { if(model->view_state == DesktopViewLockedStateLockedHintShown && momentum_settings.lockscreen_prompt) { canvas_set_font(canvas, FontSecondary); + + const CanvasFontParameters* font_params = canvas_get_font_params(canvas, FontSecondary); + int32_t y_offset = + font_params != &canvas_font_params[FontSecondary] ? (font_params->height / 2) : 0; + if(model->pin_locked) { elements_bubble_str( - canvas, 12, 14 + y, " Press \nto unlock!", AlignRight, AlignBottom); + canvas, 12, 14 + y, y_offset, " Press \nto unlock!", AlignRight, AlignBottom); canvas_draw_icon(canvas, 45, 16 + y, &I_Pin_arrow_up_7x9); } else { elements_bubble_str( - canvas, 2, 14 + y, "Press 3x \n to unlock!", AlignRight, AlignBottom); + canvas, + 2, + 14 + y, + y_offset, + "Press 3x \n to unlock!", + AlignRight, + AlignBottom); canvas_draw_icon(canvas, 43, 17 + y, &I_Pin_back_arrow_10x8); } } diff --git a/applications/services/gui/canvas.h b/applications/services/gui/canvas.h index e1b8f1881..f568be7eb 100644 --- a/applications/services/gui/canvas.h +++ b/applications/services/gui/canvas.h @@ -82,6 +82,8 @@ typedef enum { IconRotation270, } IconRotation; +extern const CanvasFontParameters canvas_font_params[FontTotalNumber]; + /** Canvas anonymous structure */ typedef struct Canvas Canvas; diff --git a/applications/services/gui/elements.c b/applications/services/gui/elements.c index 0f6cbbc57..ad0c373a6 100644 --- a/applications/services/gui/elements.c +++ b/applications/services/gui/elements.c @@ -528,6 +528,7 @@ void elements_bubble_str( Canvas* canvas, int32_t x, int32_t y, + int32_t y_offset, const char* text, Align horizontal, Align vertical) { @@ -558,7 +559,7 @@ void elements_bubble_str( canvas_draw_box(canvas, frame_x + 1, frame_y + 1, frame_width - 2, frame_height - 2); canvas_set_color(canvas, ColorBlack); canvas_draw_rframe(canvas, frame_x, frame_y, frame_width, frame_height, 1); - elements_multiline_text(canvas, x + 4, y - 1 + font_height, text); + elements_multiline_text(canvas, x + 4, y - 1 + font_height + y_offset, text); int32_t x1 = 0; int32_t x2 = 0; diff --git a/applications/services/gui/elements.h b/applications/services/gui/elements.h index 565d9c053..9397add18 100644 --- a/applications/services/gui/elements.h +++ b/applications/services/gui/elements.h @@ -230,6 +230,7 @@ void elements_bubble(Canvas* canvas, int32_t x, int32_t y, size_t width, size_t * @param canvas Canvas instance * @param x left x coordinates * @param y top y coordinate + * @param y_offset y offset used for custom font ascent * @param text text to display * @param horizontal horizontal aligning * @param vertical aligning @@ -238,6 +239,7 @@ void elements_bubble_str( Canvas* canvas, int32_t x, int32_t y, + int32_t y_offset, const char* text, Align horizontal, Align vertical); diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index c7743e061..d2bd87306 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1041,7 +1041,7 @@ Function,-,drem,double,"double, double" Function,-,dremf,float,"float, float" Function,+,elements_bold_rounded_frame,void,"Canvas*, int32_t, int32_t, size_t, size_t" Function,+,elements_bubble,void,"Canvas*, int32_t, int32_t, size_t, size_t" -Function,+,elements_bubble_str,void,"Canvas*, int32_t, int32_t, const char*, Align, Align" +Function,+,elements_bubble_str,void,"Canvas*, int32_t, int32_t, int32_t, const char*, Align, Align" Function,+,elements_button_center,void,"Canvas*, const char*" Function,+,elements_button_down,void,"Canvas*, const char*" Function,+,elements_button_left,void,"Canvas*, const char*"