grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] [1/?] grub-core/gfxmenu/gui_list.c - troubles with heights
@ 2013-07-09 15:53 Vladimir Testov
  0 siblings, 0 replies; only message in thread
From: Vladimir Testov @ 2013-07-09 15:53 UTC (permalink / raw)
  To: grub-devel

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

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)

-- 
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru

[-- Attachment #2: before-list-4-up.png --]
[-- Type: image/png, Size: 6112 bytes --]

[-- Attachment #3: before-list-4-down.png --]
[-- Type: image/png, Size: 7979 bytes --]

[-- Attachment #4: before-list-4-down2.png --]
[-- Type: image/png, Size: 7932 bytes --]

[-- Attachment #5: before-list-3-down.png --]
[-- Type: image/png, Size: 7791 bytes --]

[-- Attachment #6: after-list-4-up.png --]
[-- Type: image/png, Size: 4014 bytes --]

[-- Attachment #7: after-list-4-down.png --]
[-- Type: image/png, Size: 5331 bytes --]

[-- Attachment #8: after-list-239.png --]
[-- Type: image/png, Size: 5181 bytes --]

[-- Attachment #9: after-list-minimal-down.png --]
[-- Type: image/png, Size: 5114 bytes --]

[-- Attachment #10: after-list-minimal-up.png --]
[-- Type: image/png, Size: 3717 bytes --]

[-- Attachment #11: grub-list-height-fix.patch --]
[-- Type: text/x-patch, Size: 1973 bytes --]

diff -Naur grub-2.01/grub-core/gfxmenu/gui_list.c grub-new/grub-core/gfxmenu/gui_list.c
--- grub-2.01/grub-core/gfxmenu/gui_list.c	2013-06-25 15:21:25.000000000 +0400
+++ grub-new/grub-core/gfxmenu/gui_list.c	2013-07-09 15:27:35.337936761 +0400
@@ -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
     {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-07-09 15:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-09 15:53 [PATCH] [1/?] grub-core/gfxmenu/gui_list.c - troubles with heights Vladimir Testov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).