Sanity checks fixed. Rare case with too big scrollbar frame was incorrectly
handled.
On Thursday, July 18, 2013 07:57:14 PM Vladimir Testov wrote:
> New options
> scrollbar_thumb_top_offset
> scrollbar_thumb_bottom_offset
>
> With these two options we can make scrollbar thumb with round edges so it
> will fit to the scrollbar frame. See screenshots.
>
> offset is a number of pixels to indent from the edge of the center slice of
> the scrollbar's frame.
> positive value means we move to the bottom
> negative value means we move to the top
>
> in the example given (see screenshots)
> scrollbar_thumb_top_offset = -5
> scrollbar_thumb_bottom_offset = 5
>
> Sanity checks are present.
>
> --
> With best regards,
> _______________________________
> Vladimir Testov, ROSA Laboratory.
> www.rosalab.ru
--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
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-19 19:49:41.875854896 +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,27 +151,49 @@
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;
+ /* 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;
+
+ /* Check offset sanity. */
+ 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;
+ real_height = scrollbar_height - frame_vertical_pad;
+ }
+
+ /* Sanity checks themselves. */
if (self->scrollbar_width < frame_horizontal_pad
+ thumb_horizontal_pad
- || scrollbar_height < frame_vertical_pad + thumb_vertical_pad)
+ || real_height < thumb_vertical_pad)
{
self->draw_scrollbar = 0;
return 0;
@@ -250,11 +274,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 +645,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 +763,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;
_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel