Skip to contentSkip to conversation

[1/?] grub-core/gfxmenu/gui_list.c - troubles with heights

PATCH New Vladimir Testov 1 participant 1 message Jul 9, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [1/?] grub-core/gfxmenu/gui_list.c - troubles with heights

item_padding = 20
item_height = 30
item_spacing = 20
selected_item_pixmap_style = "inbox_*.png"
menu_pixmap_style = "menu_*.png"

heights of inbox_n.png, inbox_s.png, menu_n.png, menu_s.png equal 5

height option will be mentioned for each example

a) selected item's height is item_height - 1, not item_height (see before-list-4-up.png attached)
b) get_num_shown_items can behave incorrectly height = 235
(see before-list-4-down.png attached)
and
height = 230
(see before-list-4-down2.png attached)
c) get_minimal_size can behave incorrectly
height = 39
(see before-list-3-down.png attached)

After applying this patch:
item's height is item_height

height = 240 - everything is O.K.
(see after-list-4-up.png and after-list-4-down.png attached)

height = 239 - not enough for 4 entries - everything is O.K. (see after-list-239.png attached)

height =39 - everything is O.K.
(see after-list-minimal-down.png and after-list-minimal-up.png attached)

Signature · 4 lines
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
grub-core/gfxmenu/gui_list.c +10 -4
diff -Naur grub-2.01/grub-core/gfxmenu/gui_list.c grub-new/grub-core/gfxmenu/gui_list.c
@@ -102,9 +102,13 @@
   grub_gfxmenu_box_t box = self->menu_box;
   int box_top_pad = box->get_top_pad (box);
   int box_bottom_pad = box->get_bottom_pad (box);
+  grub_gfxmenu_box_t selbox = self->selected_item_box;
+  int sel_top_pad = selbox->get_top_pad (selbox);
+  int sel_bottom_pad = selbox->get_bottom_pad (selbox);
       
   return (self->bounds.height + item_vspace - 2 * boxpad
-	  - box_top_pad - box_bottom_pad) / (item_height + item_vspace);
+          - sel_top_pad - sel_bottom_pad
+          - box_top_pad - box_bottom_pad) / (item_height + item_vspace);
 }
 
 static int
@@ -257,7 +261,7 @@
 	  int cwidth = oviewport.width - 2 * boxpad - 2;
 	  if (selbox->get_border_width)
 	    cwidth -= selbox->get_border_width (selbox);
-	  selbox->set_content_size (selbox, cwidth, item_height - 1);
+	  selbox->set_content_size (selbox, cwidth, item_height);
           selbox->draw (selbox, 0,
                         item_top - sel_toppad);
         }
@@ -397,7 +401,8 @@
       unsigned width_s;
 
       grub_gfxmenu_box_t selbox = self->selected_item_box;
-      int sel_toppad = selbox->get_top_pad (selbox);
+      int sel_top_pad = selbox->get_top_pad (selbox);
+      int sel_bottom_pad = selbox->get_bottom_pad (selbox);
       
       *width = grub_font_get_string_width (self->item_font, "Typical OS");
       width_s = grub_font_get_string_width (self->selected_item_font,
@@ -411,7 +416,8 @@
       *height = (item_height * num_items
                  + item_vspace * (num_items - 1)
                  + 2 * boxpad
-                 + box_top_pad + box_bottom_pad + sel_toppad);
+                 + box_top_pad + box_bottom_pad
+                 + sel_top_pad + sel_bottom_pad);
     }
   else
     {