Skip to contentSkip to conversation

fixed item-height, item-spacing, max-elements-shown etc

PATCH Vladimir Testov 2 participants 2 messages Feb 5, 2013 – Feb 6, 2013 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive

I'm going to write some patches for GRUB2 - mainly for theme handling.

First one - I've faced some bug: maximum number of displayed boot elements is counted in presumption that element's height is item_height and distance between elements is item_spacing. Nevertheless, this conceptions does not work during menu drawing if we have bitmap box of the selected element. Real height of the element will be (item_height + box_pad_top + box_pad_bottom - 1), where box_pad_top and box_pad_bottom are top and bottom dimensions of bitmap box. So we will have strange difficulties with understanding of what will be really drawn and what menu height we should use.

The patch fixes these problemes. We will have item_height in every case. So, there will be no troubles with item_height, item_spacing and menu height. These three variables now mean what they suppose to mean.

Would be glad if this patch will be accepted. I also have many ideas how to improve GRUB theming functionality. Some of them are completed and I can send them as patches as soon as this patch is accepted.

Should I create update-request in bugzilla?

If something in the patch is not clear - you can ask me.

Also, some time ago I've sent a patch which adds new option - item_pixmap_style for bitmap box of unselected elements. It was not accepted but I didn't received any feedback. With whom should I discuss this patch (now I want to modify it, if the current patch will be accepted).

Thanks for your attention.

grub-core/gfxmenu/gui_list.c +15 -11
diff -Naur grub-2.00/grub-core/gfxmenu/gui_list.c grub-new/grub-core/gfxmenu/gui_list.c
@@ -227,8 +227,10 @@
 
   grub_gfxmenu_box_t selbox = self->selected_item_box;
   int sel_leftpad = selbox->get_left_pad (selbox);
+  int sel_vertical_pad = sel_leftpad
+                        + selbox->get_right_pad (selbox);
   int sel_toppad = selbox->get_top_pad (selbox);
-  int item_top = sel_toppad;
+  int item_top = 0;
   int menu_index;
   int visible_index;
   struct grub_video_rect oviewport;
@@ -247,14 +249,19 @@
       int is_selected = (menu_index == self->view->selected);
       struct grub_video_bitmap *icon;
 
+
       if (is_selected)
         {
-	  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->draw (selbox, 0,
-                        item_top - sel_toppad);
+          int cwidth = oviewport.width - 2 * boxpad - 2;
+          if (selbox->get_border_width)
+            cwidth -= selbox->get_border_width (selbox);
+          int cheight = item_height - sel_vertical_pad;
+          if (cwidth < 1)
+            cwidth = 1;
+          if (cheight < 1)
+            cheight = 1;
+          selbox->set_content_size (selbox, cwidth, cheight);
+          selbox->draw (selbox, 0, item_top);
         }
 
       icon = get_item_icon (self, menu_index);
@@ -391,9 +398,6 @@
       int box_bottom_pad = box->get_bottom_pad (box);
       unsigned width_s;
 
-      grub_gfxmenu_box_t selbox = self->selected_item_box;
-      int sel_toppad = selbox->get_top_pad (selbox);
-      
       *width = grub_font_get_string_width (self->item_font, "Typical OS");
       width_s = grub_font_get_string_width (self->selected_item_font,
 					    "Typical OS");
@@ -406,7 +410,7 @@
       *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);
     }
   else
     {
#2 lore raw

В Tue, 5 Feb 2013 19:44:14 +0300 (MSK) Vladimir Testov <[email protected]> пишет:

Quoted 6 lines

I'm going to write some patches for GRUB2 - mainly for theme handling.

First one - I've faced some bug: maximum number of displayed boot elements is counted in presumption that element's height is item_height and distance between elements is item_spacing. Nevertheless, this conceptions does not work during menu drawing if we have bitmap box of the selected element. Real height of the element will be (item_height + box_pad_top + box_pad_bottom - 1), where box_pad_top and box_pad_bottom are top and bottom dimensions of bitmap box. So we will have strange difficulties with understanding of what will be really drawn and what menu height we should use.

The patch fixes these problemes. We will have item_height in every case. So, there will be no troubles with item_height, item_spacing and menu height. These three variables now mean what they suppose to mean.

I am not sure whether it is appropriate fix. After your patch "box effect" on selected item is effectively lost (it makes selected_item_box the same height as selected item itself).

The actual fix looks much simpler - get_num_shown_items() should additionally account for self->selected_item_box->get_op_pad().

Could you make available theme that demonstrates this problem?

Quoted 9 lines

Would be glad if this patch will be accepted. I also have many ideas how to improve GRUB theming functionality. Some of them are completed and I can send them as patches as soon as this patch is accepted.

Should I create update-request in bugzilla?

If something in the patch is not clear - you can ask me.

Also, some time ago I've sent a patch which adds new option - item_pixmap_style for bitmap box of unselected elements. It was not accepted but I didn't received any feedback. With whom should I discuss this patch (now I want to modify it, if the current patch will be accepted).

Thanks for your attention.