fixed info screen text width if scrollbar required
authorHolger Schemel <holger.schemel@virtion.de>
Fri, 1 Nov 2024 19:50:30 +0000 (20:50 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Fri, 1 Nov 2024 19:50:30 +0000 (20:50 +0100)
src/screens.c

index 372bb24bd3d85e9a9c1a6e718acd652f0d5bce49..39b748da134e0342e8ec89c19a9ad2078d520a6d 100644 (file)
@@ -4173,6 +4173,23 @@ static void DrawInfoScreen_GenericScreen(int screen_nr, int num_screens, int use
 
   if (wrapped_text->total_height > wrapped_text->max_height)
   {
+    // re-wrap text with text width reduced by scroll bar width
+    tmi->width -= SC_SCROLL_VERTICAL_XSIZE;
+
+    // adjust left border and text width if text should be centered
+    if (wrapped_text->line[0].centered &&
+        MENU_SCREEN_INFO_SPACE_LEFT == MENU_SCREEN_INFO_SPACE_RIGHT)
+    {
+      tmi->x += SC_SCROLL_VERTICAL_XSIZE;
+      tmi->width -= SC_SCROLL_VERTICAL_XSIZE;
+    }
+
+    FreeWrappedText(wrapped_text);
+
+    wrapped_text = GetWrappedTextFile(filename, font_text, -1, -1, -1, tmi->width, -1, tmi->height,
+                                      line_spacing, -1,
+                                      tmi->autowrap, tmi->centered, tmi->parse_comments);
+
     int start_pos = 0;
 
     while (wrapped_text->line_visible_last < wrapped_text->num_lines - 1)