* [PATCH] [6/?] grub-core/gfxmenu/gui_list.c - sanity checks for the scrollbar
@ 2013-07-17 18:10 Vladimir Testov
0 siblings, 0 replies; only message in thread
From: Vladimir Testov @ 2013-07-17 18:10 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 568 bytes --]
some needed checks so we won't see error messages during the boot process
also the patch handles rare cases: when we have too many menu entries and / or
too small scrollbar height, the scrollbar thumb's height could be less than
it's vertical padding (height of north slice + height of south slice). So the
scrollbar thumb will be drawn incorrectly.
In this case we set the height of the thumb to it's vertical padding and
recount the position of the thumb.
--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
[-- Attachment #2: grub-list-scrollbar-thumb-sanity-checks.patch --]
[-- Type: text/x-patch, Size: 2866 bytes --]
diff -Naur grub-new5/grub-core/gfxmenu/gui_list.c grub-new6/grub-core/gfxmenu/gui_list.c
--- grub-new5/grub-core/gfxmenu/gui_list.c 2013-07-17 18:57:56.597740755 +0400
+++ grub-new6/grub-core/gfxmenu/gui_list.c 2013-07-17 20:07:37.664064169 +0400
@@ -148,6 +148,33 @@
self->theme_dir);
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 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_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
+ + thumb_horizontal_pad
+ || scrollbar_height < frame_vertical_pad + thumb_vertical_pad)
+ {
+ self->draw_scrollbar = 0;
+ return 0;
+ }
+ }
}
return (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0);
@@ -228,8 +255,18 @@
frame->set_content_size (frame,
scrollbar_width - frame_horizontal_pad,
tracklen);
- int thumby = tracktop + tracklen * (value - min) / (max - min);
+ int thumby;
int thumbheight = tracklen * extent / (max - min) + 1;
+ if (thumbheight >= thumb_vertical_pad)
+ {
+ thumby = tracktop + tracklen * (value - min) / (max - min);
+ }
+ else /* Rare occasion. Thumb height is too low. */
+ {
+ thumbheight = thumb_vertical_pad;
+ thumby = tracktop + ((tracklen - thumb_vertical_pad) * (value - min)
+ / (max - extent));
+ }
thumb->set_content_size (thumb,
scrollbar_width - frame_horizontal_pad
- thumb_horizontal_pad,
@@ -584,7 +621,7 @@
}
else if (grub_strcmp (name, "scrollbar_width") == 0)
{
- self->scrollbar_width = grub_strtol (value, 0, 10);
+ self->scrollbar_width = grub_strtoul (value, 0, 10);
}
else if (grub_strcmp (name, "scrollbar") == 0)
{
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2013-07-17 18:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-17 18:10 [PATCH] [6/?] grub-core/gfxmenu/gui_list.c - sanity checks for the scrollbar Vladimir Testov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.