grub-core/gfxmenu/gui_list.c - new options: scrollbar padding
PATCH 9/11 grub-core/gfxmenu/gui_list.c - new options: scrollbar padding
scrollbar_left_padscrollbar_right_padscrollbar_top_padscrollbar_bottom_pad
only non-negative values
sizes of the scrollbar's padding
horizontal padding behaving depends on the selected scrollbar slice
EAST:scrollbar_right_pad is ignoredscrollbar_left_pad is additional spacing on the right side of the menu item list.
Scrollbar is drawn on the left side of the menu's east slice (as it was before)
WEST:
Similar to east.scrollbar_right_pad is additional spacing on the left side of the menu item list.scrollbar_left_pad is ignored.
CENTER:
That's the point of this patch.
scrollbar is drawn in the center slice.
left and right padding - is a distance to the right side of the menu item list and to the right side of the center slice correspondingly. note, that option item_padding can be set and it affects padding of the menu item list. So if this option is set then real spacing between the list and the scrollbar will be item_padding + scrollbar_left_pad. That way the usual behaviour of item_padding is saved.
Signature · 4 lines
With best regards, _______________________________ Vladimir Testov, ROSA Laboratory. www.rosalab.ru
grub-core/gfxmenu/gui_list.c +78 -21
@@ -66,6 +66,10 @@int scrollbar_thumb_bottom_offset;int scrollbar_width;int scrollbar_slice; +int scrollbar_left_pad; +int scrollbar_right_pad; +int scrollbar_top_pad; +int scrollbar_bottom_pad;int first_shown_index;
@@ -190,17 +194,27 @@int thumb_bottom = - frame_bottom_pad + self->scrollbar_thumb_bottom_offset; -/* Check offset sanity. */ +/* The height of the space for the scrollbar thumb. */ int real_height = scrollbar_height - thumb_top + thumb_bottom; + +/* Check vertical composition sanity. */ if (thumb_top <0 || thumb_bottom >0 - || real_height < thumb_vertical_pad) + || real_height - self->scrollbar_top_pad + - self->scrollbar_bottom_pad < thumb_vertical_pad) { + self->scrollbar_top_pad =0 ; + self->scrollbar_bottom_pad =0 ; self->scrollbar_thumb_top_offset =0 ; self->scrollbar_thumb_bottom_offset =0 ; real_height = scrollbar_height - frame_vertical_pad; } +else + { + real_height -= self->scrollbar_top_pad + + self->scrollbar_bottom_pad; + } -/* Sanity checks themselves. */ +/* Sanity check. */ if (self->scrollbar_width < frame_horizontal_pad + thumb_horizontal_pad || real_height < thumb_vertical_pad)
@@ -209,16 +223,37 @@return 0 ; } -/* Checks for scrollbar_slice option. */ -if (self->scrollbar_slice ==SCROLLBAR_SLICE_CENTER ) +/* Count the width of the menu. */ +unsigned min_menu_width, min_menu_height; +list_get_minimal_size (self, &min_menu_width, &min_menu_height); +int min_total_width = (int ) min_menu_width + self->scrollbar_width; +int scrollbar_space =0 ; +switch (self->scrollbar_slice) + { +case SCROLLBAR_SLICE_WEST : + scrollbar_space = self->scrollbar_right_pad; +break ; +case SCROLLBAR_SLICE_CENTER : + scrollbar_space = self->scrollbar_left_pad + + self->scrollbar_right_pad; +break ; +case SCROLLBAR_SLICE_EAST : + scrollbar_space = self->scrollbar_left_pad; +break ; + } + +/* Check horizontal composition sanity. */ +if (min_total_width + scrollbar_space > (int ) self->bounds.width) + { + self->scrollbar_left_pad =0 ; + self->scrollbar_right_pad =0 ; + } + +/* Sanity check. */ +if (min_total_width > (int ) self->bounds.width) { -unsigned min_menu_width, min_menu_height; -list_get_minimal_size (self, &min_menu_width, &min_menu_height); -if ((int ) min_menu_width + self->scrollbar_width > (int ) self->bounds.width) - { - self->draw_scrollbar =0 ; -return 0 ; - } + self->draw_scrollbar =0 ; +return 0 ; } } }
@@ -302,7 +337,7 @@ scrollbar_width - frame_horizontal_pad, tracklen); tracklen += - self->scrollbar_thumb_top_offset - + self->scrollbar_thumb_bottom_offset; + + self->scrollbar_thumb_bottom_offset;int thumby;int thumbheight = tracklen * extent / (max - min) +1 ;if (thumbheight >= thumb_vertical_pad)
@@ -472,13 +507,14 @@ box->set_content_size (box, content_rect.width, content_rect.height); scrollbar_rect.width = scrollbar_width; - scrollbar_rect.y = content_rect.y; - scrollbar_rect.height = content_rect.height; + scrollbar_rect.y = content_rect.y + self->scrollbar_top_pad; + scrollbar_rect.height = content_rect.height - self->scrollbar_top_pad + - self->scrollbar_bottom_pad;switch (self->scrollbar_slice) {case SCROLLBAR_SLICE_WEST : - content_rect.x +=2 ; - content_rect.width -=2 ; + content_rect.x += self->scrollbar_right_pad; + content_rect.width -= self->scrollbar_right_pad; scrollbar_rect.x = box_left_pad - scrollbar_width;if (scrollbar_width > box_left_pad) {
@@ -487,14 +523,15 @@ }break ;case SCROLLBAR_SLICE_CENTER : - content_rect.width -=2 ;if (drawing_scrollbar) - content_rect.width -= scrollbar_width; + content_rect.width -= scrollbar_width + + self->scrollbar_left_pad + + self->scrollbar_right_pad; scrollbar_rect.x = self->bounds.width - box_right_pad - - scrollbar_width; + - scrollbar_width - self->scrollbar_right_pad;break ;case SCROLLBAR_SLICE_EAST : - content_rect.width -=2 ; + content_rect.width -= self->scrollbar_left_pad; scrollbar_rect.x = self->bounds.width - box_right_pad;if (scrollbar_width > box_right_pad) scrollbar_rect.width = box_right_pad;
@@ -717,6 +754,22 @@else if (grub_strcmp (value,"east" ) ==0 ) self->scrollbar_slice =SCROLLBAR_SLICE_EAST ; } +else if (grub_strcmp (name,"scrollbar_left_pad" ) ==0 ) + { + self->scrollbar_left_pad =grub_strtoul (value,0 ,10 ); + } +else if (grub_strcmp (name,"scrollbar_right_pad" ) ==0 ) + { + self->scrollbar_right_pad =grub_strtoul (value,0 ,10 ); + } +else if (grub_strcmp (name,"scrollbar_top_pad" ) ==0 ) + { + self->scrollbar_top_pad =grub_strtoul (value,0 ,10 ); + } +else if (grub_strcmp (name,"scrollbar_bottom_pad" ) ==0 ) + { + self->scrollbar_bottom_pad =grub_strtoul (value,0 ,10 ); + }else if (grub_strcmp (name,"scrollbar" ) ==0 ) { self->draw_scrollbar =grub_strcmp (value,"false" ) !=0 ;
@@ -825,6 +878,10 @@ self->scrollbar_thumb_bottom_offset =0 ; self->scrollbar_width =16 ; 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 ;