Skip to contentSkip to conversation

[PATCH] [2/11] [gfxmenu/list]

PATCH In review Vladimir Testov 1 participant 1 message Apr 11, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 2/11 [PATCH] [2/11] [gfxmenu/list]

If the line is too long then text will be drawn on the east slice of selected item pixmap and even two pixel to the right from the east slice.

see screenshots
list-string-before - before the patch
list-string-after - after the patch

Signature · 4 lines
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
grub-core/gfxmenu/gui_list.c +35 -14
diff -Naur grub-new2/grub-core/gfxmenu/gui_list.c grub-new3/grub-core/gfxmenu/gui_list.c
@@ -253,6 +253,22 @@
 			   oviewport.width - 2 * boxpad,
 			   oviewport.height - 2 * boxpad);
 
+  int cwidth = oviewport.width - 2 * boxpad - 2;
+  if (selbox->get_border_width)
+    cwidth -= selbox->get_border_width (selbox);
+  if (self->list_version == 0)
+    selbox->set_content_size (selbox, cwidth, item_height - 1);
+  else
+    selbox->set_content_size (selbox, cwidth, item_height);
+
+  int string_left_offset = sel_leftpad + self->icon_width + icon_text_space;
+  int string_top_offset = (item_height - (ascent + descent)) / 2 + ascent;
+
+  grub_video_rect_t svpsave, sviewport;
+  sviewport.x = string_left_offset;
+  sviewport.width = cwidth + sel_leftpad - string_left_offset;
+  sviewport.height = item_height;
+
   for (visible_index = 0, menu_index = self->first_shown_index;
        visible_index < num_shown_items && menu_index < self->view->menu->size;
        visible_index++, menu_index++)
@@ -262,13 +278,6 @@
 
       if (is_selected)
         {
-	  int cwidth = oviewport.width - 2 * boxpad - 2;
-	  if (selbox->get_border_width)
-	    cwidth -= selbox->get_border_width (selbox);
-	  if (self->list_version == 0)
-	    selbox->set_content_size (selbox, cwidth, item_height - 1);
-	  else
-	    selbox->set_content_size (selbox, cwidth, item_height);
           selbox->draw (selbox, 0,
                         item_top - sel_toppad);
         }
@@ -290,13 +299,25 @@
         ((is_selected && self->selected_item_color_set)
          ? self->selected_item_color
          : self->item_color);
-      grub_font_draw_string (item_title,
-                             font,
-                             grub_video_map_rgba_color (text_color),
-                             sel_leftpad + self->icon_width + icon_text_space,
-                             (item_top + (item_height - (ascent + descent))
-                              / 2 + ascent));
-
+      sviewport.y = item_top;
+      if (self->list_version == 0)
+        {
+          grub_font_draw_string (item_title,
+                                 font,
+                                 grub_video_map_rgba_color (text_color),
+                                 string_left_offset,
+                                 (item_top + string_top_offset));
+        }
+      else
+        {
+          grub_gui_set_viewport (&sviewport, &svpsave);
+          grub_font_draw_string (item_title,
+                                 font,
+                                 grub_video_map_rgba_color (text_color),
+                                 0,
+                                 string_top_offset);
+          grub_gui_restore_viewport (&svpsave);
+        }
       item_top += item_height + item_vspace;
     }
   grub_video_set_viewport (oviewport.x,