diff -Naur grub-new6/grub-core/gfxmenu/gui_list.c grub-new7/grub-core/gfxmenu/gui_list.c --- grub-new6/grub-core/gfxmenu/gui_list.c 2013-07-17 20:07:37.664064169 +0400 +++ grub-new7/grub-core/gfxmenu/gui_list.c 2013-07-18 17:50:44.251123544 +0400 @@ -56,6 +56,8 @@ char *scrollbar_thumb_pattern; grub_gfxmenu_box_t scrollbar_frame; grub_gfxmenu_box_t scrollbar_thumb; + int scrollbar_thumb_top_offset; + int scrollbar_thumb_bottom_offset; int scrollbar_width; int first_shown_index; @@ -149,22 +151,26 @@ self->need_to_recreate_scrollbar = 0; + /* Sanity checks. */ if (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0) { grub_gfxmenu_box_t box = self->menu_box; grub_gfxmenu_box_t frame = self->scrollbar_frame; grub_gfxmenu_box_t thumb = self->scrollbar_thumb; - int box_vertical_pad = (box->get_top_pad (box) - + box->get_bottom_pad (box)); + + int box_top_pad = box->get_top_pad (box); + int box_bottom_pad = box->get_bottom_pad (box); + int box_vertical_pad = box_top_pad + box_bottom_pad; + int frame_top_pad = frame->get_top_pad (frame); + int frame_bottom_pad = frame->get_bottom_pad (frame); + int frame_vertical_pad = frame_top_pad + frame_bottom_pad; int frame_horizontal_pad = (frame->get_left_pad (frame) + frame->get_right_pad (frame)); - int frame_vertical_pad = (frame->get_top_pad (frame) - + frame->get_bottom_pad (frame)); + int thumb_vertical_pad = (thumb->get_top_pad (thumb) + + thumb->get_bottom_pad (thumb)); int thumb_horizontal_pad = (thumb->get_left_pad (thumb) + thumb->get_right_pad (thumb)); - int thumb_vertical_pad = (thumb->get_top_pad (thumb) - + thumb->get_bottom_pad (thumb)); int scrollbar_height = self->bounds.height - box_vertical_pad; if (self->scrollbar_width < frame_horizontal_pad @@ -174,6 +180,22 @@ self->draw_scrollbar = 0; return 0; } + + /* Check offsets. */ + /* Offset from the top of the scrollbar viewport. */ + int thumb_top = frame_top_pad + + self->scrollbar_thumb_top_offset; + /* Offset from the bottom of the scrollbar viewport. */ + int thumb_bottom = - frame_bottom_pad + + self->scrollbar_thumb_bottom_offset; + + int real_height = scrollbar_height - thumb_top + thumb_bottom; + if (thumb_top < 0 || thumb_bottom > 0 + || real_height < thumb_vertical_pad) + { + self->scrollbar_thumb_top_offset = 0; + self->scrollbar_thumb_bottom_offset = 0; + } } } @@ -250,11 +272,13 @@ + thumb->get_bottom_pad (thumb)); int thumb_horizontal_pad = (thumb->get_left_pad (thumb) + thumb->get_right_pad (thumb)); - int tracktop = frame->get_top_pad (frame); + int tracktop = frame->get_top_pad (frame) + self->scrollbar_thumb_top_offset; int tracklen = scrollbar_height - frame_vertical_pad; frame->set_content_size (frame, scrollbar_width - frame_horizontal_pad, tracklen); + tracklen += - self->scrollbar_thumb_top_offset + + self->scrollbar_thumb_bottom_offset; int thumby; int thumbheight = tracklen * extent / (max - min) + 1; if (thumbheight >= thumb_vertical_pad) @@ -619,6 +643,16 @@ grub_free (self->scrollbar_thumb_pattern); self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0; } + else if (grub_strcmp (name, "scrollbar_thumb_top_offset") == 0) + { + self->need_to_recreate_scrollbar = 1; + self->scrollbar_thumb_top_offset = grub_strtol (value, 0, 10); + } + else if (grub_strcmp (name, "scrollbar_thumb_bottom_offset") == 0) + { + self->need_to_recreate_scrollbar = 1; + self->scrollbar_thumb_bottom_offset = grub_strtol (value, 0, 10); + } else if (grub_strcmp (name, "scrollbar_width") == 0) { self->scrollbar_width = grub_strtoul (value, 0, 10); @@ -727,6 +761,8 @@ self->scrollbar_thumb = 0; self->scrollbar_frame_pattern = 0; self->scrollbar_thumb_pattern = 0; + self->scrollbar_thumb_top_offset = 0; + self->scrollbar_thumb_bottom_offset = 0; self->scrollbar_width = 16; self->first_shown_index = 0;