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

@ -27,13 +27,11 @@
struct grub_gui_progress_bar
{
struct grub_gui_component_ops *progress_bar;
struct grub_gui_component component;
grub_gui_container_t parent;
grub_video_rect_t bounds;
char *id;
int preferred_width;
int preferred_height;
int visible;
int start;
int end;
@ -221,18 +219,11 @@ progress_bar_get_bounds (void *vself, grub_video_rect_t *bounds)
}
static void
progress_bar_get_preferred_size (void *vself, int *width, int *height)
progress_bar_get_minimal_size (void *vself __attribute__ ((unused)),
unsigned *width, unsigned *height)
{
grub_gui_progress_bar_t self = vself;
*width = 200;
*height = 28;
/* Allow preferred dimensions to override the progress_bar dimensions. */
if (self->preferred_width >= 0)
*width = self->preferred_width;
if (self->preferred_height >= 0)
*height = self->preferred_height;
}
static grub_err_t
@ -296,15 +287,6 @@ progress_bar_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, "visible") == 0)
{
self->visible = grub_strcmp (value, "false") != 0;
@ -334,7 +316,7 @@ static struct grub_gui_component_ops progress_bar_ops =
.get_parent = progress_bar_get_parent,
.set_bounds = progress_bar_set_bounds,
.get_bounds = progress_bar_get_bounds,
.get_preferred_size = progress_bar_get_preferred_size,
.get_minimal_size = progress_bar_get_minimal_size,
.set_property = progress_bar_set_property
};
@ -342,22 +324,11 @@ grub_gui_component_t
grub_gui_progress_bar_new (void)
{
grub_gui_progress_bar_t self;
self = grub_malloc (sizeof (*self));
self = grub_zalloc (sizeof (*self));
if (! self)
return 0;
self->progress_bar = &progress_bar_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->component.ops = &progress_bar_ops;
self->visible = 1;
self->start = 0;
self->end = 0;
self->value = 0;
self->show_text = 1;
self->text = grub_strdup ("");
self->font = grub_font_get ("Helvetica 10");
@ -369,12 +340,5 @@ grub_gui_progress_bar_new (void)
self->bg_color = gray;
self->fg_color = lightgray;
self->theme_dir = 0;
self->need_to_recreate_pixmaps = 0;
self->bar_pattern = 0;
self->highlight_pattern = 0;
self->bar_box = 0;
self->highlight_box = 0;
return (grub_gui_component_t) self;
}