* grub-core/gfxmenu/gui_list.c: New options for scrollbar padding:

scrollbar_left_pad, scrollbar_right_pad, scrollbar_top_pad,
       scrollbar_bottom_pad
       * docs/grub.texi: Likewise.
This commit is contained in:
Vladimir Testov 2013-10-09 16:55:16 +04:00
parent 6e9e5dc98b
commit ad297ec734
3 changed files with 54 additions and 8 deletions

View file

@ -1,3 +1,10 @@
2013-10-09 Vladimir Testov <vladimir.testov@rosalab.ru>
* grub-core/gfxmenu/gui_list.c: New options for scrollbar padding:
scrollbar_left_pad, scrollbar_right_pad, scrollbar_top_pad,
scrollbar_bottom_pad
* docs/grub.texi: Likewise.
2013-10-09 Vladimir Testov <vladimir.testov@rosalab.ru> 2013-10-09 Vladimir Testov <vladimir.testov@rosalab.ru>
* grub-core/gfxmenu/gui_list.c (list_destroy): Fixed memory leak. * grub-core/gfxmenu/gui_list.c (list_destroy): Fixed memory leak.

View file

@ -2092,6 +2092,16 @@ The following is a list of the components and the properties they support.
b) If the scrollbar won't be drawn then the boot menu entry's width b) If the scrollbar won't be drawn then the boot menu entry's width
is the width of the center slice. is the width of the center slice.
c) We don't necessary need the menu pixmap box to display the scrollbar. c) We don't necessary need the menu pixmap box to display the scrollbar.
@item scrollbar_left_pad
@tab The left scrollbar padding in pixels.
Unused if ``scrollbar_slice`` is ``west``.
@item scrollbar_right_pad
@tab The right scrollbar padding in pixels.
Unused if ``scrollbar_slice`` is ``east``.
@item scrollbar_top_pad
@tab The top scrollbar padding in pixels.
@item scrollbar_bottom_pad
@tab The bottom scrollbar padding in pixels.
@item max_items_shown @item max_items_shown
@tab The maximum number of items to show on the menu. If there are more than @tab The maximum number of items to show on the menu. If there are more than
*max_items_shown* items in the menu, the list will scroll to make all *max_items_shown* items in the menu, the list will scroll to make all

View file

@ -61,6 +61,10 @@ struct grub_gui_list_impl
grub_gfxmenu_box_t scrollbar_thumb; grub_gfxmenu_box_t scrollbar_thumb;
int scrollbar_width; int scrollbar_width;
enum scrollbar_slice_mode scrollbar_slice; enum scrollbar_slice_mode scrollbar_slice;
int scrollbar_left_pad;
int scrollbar_right_pad;
int scrollbar_top_pad;
int scrollbar_bottom_pad;
int first_shown_index; int first_shown_index;
@ -384,15 +388,16 @@ list_paint (void *vself, const grub_video_rect_t *region)
switch (self->scrollbar_slice) switch (self->scrollbar_slice)
{ {
case SCROLLBAR_SLICE_WEST: case SCROLLBAR_SLICE_WEST:
content_rect.x += 2; content_rect.x += self->scrollbar_right_pad;
content_rect.width -= 2; content_rect.width -= self->scrollbar_right_pad;
break; break;
case SCROLLBAR_SLICE_CENTER: case SCROLLBAR_SLICE_CENTER:
if (drawing_scrollbar) if (drawing_scrollbar)
content_rect.width -= scrollbar_width + 2; content_rect.width -= scrollbar_width + self->scrollbar_left_pad
+ self->scrollbar_right_pad;
break; break;
case SCROLLBAR_SLICE_EAST: case SCROLLBAR_SLICE_EAST:
content_rect.width -= 2; content_rect.width -= self->scrollbar_left_pad;
break; break;
} }
@ -402,6 +407,9 @@ list_paint (void *vself, const grub_video_rect_t *region)
if (drawing_scrollbar) if (drawing_scrollbar)
{ {
content_rect.y += self->scrollbar_top_pad;
content_rect.height -= self->scrollbar_top_pad
+ self->scrollbar_bottom_pad;
content_rect.width = scrollbar_width; content_rect.width = scrollbar_width;
switch (self->scrollbar_slice) switch (self->scrollbar_slice)
{ {
@ -419,7 +427,7 @@ list_paint (void *vself, const grub_video_rect_t *region)
break; break;
case SCROLLBAR_SLICE_CENTER: case SCROLLBAR_SLICE_CENTER:
content_rect.x = self->bounds.width - box_right_pad content_rect.x = self->bounds.width - box_right_pad
- scrollbar_width; - scrollbar_width - self->scrollbar_right_pad;
content_rect.width = scrollbar_width; content_rect.width = scrollbar_width;
break; break;
case SCROLLBAR_SLICE_EAST: case SCROLLBAR_SLICE_EAST:
@ -507,13 +515,14 @@ list_get_minimal_size (void *vself, unsigned *width, unsigned *height)
switch (self->scrollbar_slice) switch (self->scrollbar_slice)
{ {
case SCROLLBAR_SLICE_WEST: case SCROLLBAR_SLICE_WEST:
*width += 2; *width += self->scrollbar_right_pad;
break; break;
case SCROLLBAR_SLICE_CENTER: case SCROLLBAR_SLICE_CENTER:
*width += self->scrollbar_width + 2; *width += self->scrollbar_width + self->scrollbar_left_pad
+ self->scrollbar_right_pad;
break; break;
case SCROLLBAR_SLICE_EAST: case SCROLLBAR_SLICE_EAST:
*width += 2; *width += self->scrollbar_left_pad;
break; break;
} }
@ -653,6 +662,22 @@ list_set_property (void *vself, const char *name, const char *value)
else if (grub_strcmp (value, "east") == 0) else if (grub_strcmp (value, "east") == 0)
self->scrollbar_slice = SCROLLBAR_SLICE_EAST; self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
} }
else if (grub_strcmp (name, "scrollbar_left_pad") == 0)
{
self->scrollbar_left_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_right_pad") == 0)
{
self->scrollbar_right_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_top_pad") == 0)
{
self->scrollbar_top_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar_bottom_pad") == 0)
{
self->scrollbar_bottom_pad = grub_strtol (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar") == 0) else if (grub_strcmp (name, "scrollbar") == 0)
{ {
self->draw_scrollbar = grub_strcmp (value, "false") != 0; self->draw_scrollbar = grub_strcmp (value, "false") != 0;
@ -755,6 +780,10 @@ grub_gui_list_new (void)
self->scrollbar_thumb_pattern = 0; self->scrollbar_thumb_pattern = 0;
self->scrollbar_width = 16; self->scrollbar_width = 16;
self->scrollbar_slice = SCROLLBAR_SLICE_EAST; self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
self->scrollbar_left_pad = 2;
self->scrollbar_right_pad = 0;
self->scrollbar_top_pad = 0;
self->scrollbar_bottom_pad = 0;
self->first_shown_index = 0; self->first_shown_index = 0;