mirror of
https://github.com/libretro/RetroArch
synced 2025-03-01 07:13:35 +00:00
Fix word wrapped widget length (#15905)
This commit is contained in:
parent
f091b5a9e9
commit
b341d90c2e
@ -293,6 +293,8 @@ void gfx_widgets_msg_queue_push(
|
||||
/* Text is too wide, split it into two lines */
|
||||
if (text_width > width)
|
||||
{
|
||||
size_t wrap_length = 0;
|
||||
|
||||
/* If the second line is too short, the widget may
|
||||
* look unappealing - ensure that second line is at
|
||||
* least 25% of the total width */
|
||||
@ -303,6 +305,24 @@ void gfx_widgets_msg_queue_push(
|
||||
(int)((title_length * width) / text_width),
|
||||
100, 2);
|
||||
|
||||
/* Recalculate widget width with longest wrapped line */
|
||||
wrap_length = string_index_last_occurance(msg, '\n');
|
||||
if (wrap_length)
|
||||
{
|
||||
title_length -= wrap_length;
|
||||
|
||||
if (title_length < wrap_length)
|
||||
title_length = wrap_length;
|
||||
|
||||
text_width = font_driver_get_message_width(
|
||||
p_dispwidget->gfx_widget_fonts.msg_queue.font,
|
||||
title,
|
||||
title_length,
|
||||
1.0f);
|
||||
|
||||
width = text_width;
|
||||
}
|
||||
|
||||
msg_widget->text_height *= 2;
|
||||
msg_widget->msg_len = strlen(msg);
|
||||
}
|
||||
@ -313,8 +333,7 @@ void gfx_widgets_msg_queue_push(
|
||||
}
|
||||
|
||||
msg_widget->msg = msg;
|
||||
msg_widget->width = width
|
||||
+ p_dispwidget->simple_widget_padding / 2;
|
||||
msg_widget->width = width + (p_dispwidget->simple_widget_padding / 2);
|
||||
}
|
||||
|
||||
fifo_write(&p_dispwidget->msg_queue,
|
||||
|
Loading…
x
Reference in New Issue
Block a user