Take into account the decorations the computing menu entry width.

* grub-core/gfxmenu/widget-box.c (get_border_width): New function.
	(grub_gfxmenu_create_box): Register get_border_width.
	* grub-core/gfxmenu/gui_list.c (draw_menu): Use get_border_width
	if available.
	* include/grub/gfxwidgets.h (grub_gfxmenu_box): New member
	get_border_width.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2011-04-19 00:44:53 +02:00
parent e74b3947af
commit abc474ef4b
4 changed files with 25 additions and 2 deletions

View file

@ -1,3 +1,14 @@
2011-04-19 Vladimir Serbinenko <phcoder@gmail.com>
Take into account the decorations the computing menu entry width.
* grub-core/gfxmenu/widget-box.c (get_border_width): New function.
(grub_gfxmenu_create_box): Register get_border_width.
* grub-core/gfxmenu/gui_list.c (draw_menu): Use get_border_width
if available.
* include/grub/gfxwidgets.h (grub_gfxmenu_box): New member
get_border_width.
2011-04-18 Endres Puschner <code@e7p.de> 2011-04-18 Endres Puschner <code@e7p.de>
* grub-core/gfxmenu/icon_manager.c (grub_gfxmenu_icon_manager_get_icon): * grub-core/gfxmenu/icon_manager.c (grub_gfxmenu_icon_manager_get_icon):

View file

@ -248,8 +248,10 @@ draw_menu (list_impl_t self, int num_shown_items)
if (is_selected) if (is_selected)
{ {
selbox->set_content_size (selbox, oviewport.width - 2 * boxpad - 2, int cwidth = oviewport.width - 2 * boxpad - 2;
item_height - 1); if (selbox->get_border_width)
cwidth -= selbox->get_border_width (selbox);
selbox->set_content_size (selbox, cwidth, item_height - 1);
selbox->draw (selbox, 0, selbox->draw (selbox, 0,
item_top - sel_toppad); item_top - sel_toppad);
} }

View file

@ -178,6 +178,13 @@ set_content_size (grub_gfxmenu_box_t self,
return; return;
} }
static int
get_border_width (grub_gfxmenu_box_t self)
{
return (get_width (self->raw_pixmaps[BOX_PIXMAP_E])
+ get_width (self->raw_pixmaps[BOX_PIXMAP_W]));
}
static int static int
get_left_pad (grub_gfxmenu_box_t self) get_left_pad (grub_gfxmenu_box_t self)
{ {
@ -288,6 +295,8 @@ grub_gfxmenu_create_box (const char *pixmaps_prefix,
box->draw = draw; box->draw = draw;
box->set_content_size = set_content_size; box->set_content_size = set_content_size;
box->get_border_width = get_border_width;
box->get_left_pad = get_left_pad; box->get_left_pad = get_left_pad;
box->get_top_pad = get_top_pad; box->get_top_pad = get_top_pad;
box->get_right_pad = get_right_pad; box->get_right_pad = get_right_pad;

View file

@ -36,6 +36,7 @@ struct grub_gfxmenu_box
void (*draw) (grub_gfxmenu_box_t self, int x, int y); void (*draw) (grub_gfxmenu_box_t self, int x, int y);
void (*set_content_size) (grub_gfxmenu_box_t self, void (*set_content_size) (grub_gfxmenu_box_t self,
int width, int height); int width, int height);
int (*get_border_width) (grub_gfxmenu_box_t self);
int (*get_left_pad) (grub_gfxmenu_box_t self); int (*get_left_pad) (grub_gfxmenu_box_t self);
int (*get_top_pad) (grub_gfxmenu_box_t self); int (*get_top_pad) (grub_gfxmenu_box_t self);
int (*get_right_pad) (grub_gfxmenu_box_t self); int (*get_right_pad) (grub_gfxmenu_box_t self);