Initial support for scalable gfxmenu

This commit is contained in:
Vladimir 'phcoder' Serbinenko 2009-12-29 17:31:02 +01:00
parent a2b4c09b1c
commit 9a17588459
13 changed files with 368 additions and 437 deletions

View file

@ -26,13 +26,11 @@
struct grub_gui_list_impl
{
struct grub_gui_list_ops *list_ops;
struct grub_gui_list list;
grub_gui_container_t parent;
grub_video_rect_t bounds;
char *id;
int preferred_width;
int preferred_height;
int visible;
int icon_width;
@ -357,7 +355,7 @@ list_get_bounds (void *vself, grub_video_rect_t *bounds)
}
static void
list_get_preferred_size (void *vself, int *width, int *height)
list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
{
list_impl_t self = vself;
@ -387,12 +385,6 @@ list_get_preferred_size (void *vself, int *width, int *height)
*width = 0;
*height = 0;
}
/* Allow preferred dimensions to override the computed dimensions. */
if (self->preferred_width >= 0)
*width = self->preferred_width;
if (self->preferred_height >= 0)
*height = self->preferred_height;
}
static grub_err_t
@ -507,15 +499,6 @@ list_set_property (void *vself, const char *name, const char *value)
grub_free (self->theme_dir);
self->theme_dir = value ? grub_strdup (value) : 0;
}
else if (grub_strcmp (name, "preferred_size") == 0)
{
int w;
int h;
if (grub_gui_parse_2_tuple (value, &w, &h) != GRUB_ERR_NONE)
return grub_errno;
self->preferred_width = w;
self->preferred_height = h;
}
else if (grub_strcmp (name, "id") == 0)
{
grub_free (self->id);
@ -538,21 +521,22 @@ list_set_view_info (void *vself,
self->menu = menu;
}
static struct grub_gui_component_ops list_comp_ops =
{
.destroy = list_destroy,
.get_id = list_get_id,
.is_instance = list_is_instance,
.paint = list_paint,
.set_parent = list_set_parent,
.get_parent = list_get_parent,
.set_bounds = list_set_bounds,
.get_bounds = list_get_bounds,
.get_minimal_size = list_get_minimal_size,
.set_property = list_set_property
};
static struct grub_gui_list_ops list_ops =
{
.component_ops =
{
.destroy = list_destroy,
.get_id = list_get_id,
.is_instance = list_is_instance,
.paint = list_paint,
.set_parent = list_set_parent,
.get_parent = list_get_parent,
.set_bounds = list_set_bounds,
.get_bounds = list_get_bounds,
.get_preferred_size = list_get_preferred_size,
.set_property = list_set_property
},
.set_view_info = list_set_view_info
};
@ -564,19 +548,13 @@ grub_gui_list_new (void)
grub_gui_color_t default_fg_color;
grub_gui_color_t default_bg_color;
self = grub_malloc (sizeof (*self));
self = grub_zalloc (sizeof (*self));
if (! self)
return 0;
self->list_ops = &list_ops;
self->parent = 0;
self->bounds.x = 0;
self->bounds.y = 0;
self->bounds.width = 0;
self->bounds.height = 0;
self->id = 0;
self->preferred_width = -1;
self->preferred_height = -1;
self->list.ops = &list_ops;
self->list.component.ops = &list_comp_ops;
self->visible = 1;
default_font = grub_font_get ("Helvetica 12");
@ -617,7 +595,7 @@ grub_gui_list_new (void)
self->icon_manager = grub_gfxmenu_icon_manager_new ();
if (! self->icon_manager)
{
self->list_ops->component_ops.destroy (self);
self->list.component.ops->destroy (self);
return 0;
}
grub_gfxmenu_icon_manager_set_icon_size (self->icon_manager,