Skip to content

Commit

Permalink
Recalculate animation end position if layout changes after start.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltanvb committed Jul 25, 2023
1 parent 1805484 commit 83cef37
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions gfx/widgets/gfx_widget_load_content_animation.c
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,42 @@ static void gfx_widget_load_content_animation_layout(
(float)font_regular->line_centre_offset;
/* > Note: cannot determine state->text_x_end
* until text strings are set */

/* Recalculate end positions if layout changes after start */
if (state->status > GFX_WIDGET_LOAD_CONTENT_BEGIN)
{
int content_name_width;
int system_name_width;
int text_width;

/* Get overall text width */
content_name_width = font_driver_get_message_width(
font_bold->font, state->content_name,
strlen(state->content_name), 1.0f);
system_name_width = font_driver_get_message_width(
font_regular->font, state->system_name,
state->system_name_len, 1.0f);

state->content_name_width = (content_name_width > 0) ?
(unsigned)content_name_width : 0;
state->system_name_width = (system_name_width > 0) ?
(unsigned)system_name_width : 0;

text_width = (state->content_name_width > state->system_name_width) ?
(int)state->content_name_width : (int)state->system_name_width;

/* Now we have the text width, can determine
* final icon/text x draw positions */
state->icon_x_end = ((int)last_video_width - text_width -
(int)state->icon_size - (3 * (int)widget_padding)) >> 1;
if (state->icon_x_end < (int)widget_padding)
state->icon_x_end = widget_padding;

state->text_x_end = state->icon_x_end +
(float)(state->icon_size + widget_padding);

}

}

/* Widget iterate() */
Expand Down

0 comments on commit 83cef37

Please sign in to comment.