From: Vladimir Testov <vladimir.testov@rosalab.ru>
To: grub-devel@gnu.org
Subject: [PATCH] [9/11] grub-core/gfxmenu/gui_list.c - new options: scrollbar padding
Date: Fri, 19 Jul 2013 22:36:26 +0400 [thread overview]
Message-ID: <1622677.CGEa7UfXCP@icedphoenix> (raw)
[-- Attachment #1: Type: text/plain, Size: 1139 bytes --]
scrollbar_left_pad
scrollbar_right_pad
scrollbar_top_pad
scrollbar_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 ignored
scrollbar_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.
--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
[-- Attachment #2: grub-list-scrollbar-padding.patch --]
[-- Type: text/x-patch, Size: 6840 bytes --]
diff -Naur grub-new8/grub-core/gfxmenu/gui_list.c grub-new9/grub-core/gfxmenu/gui_list.c
--- grub-new8/grub-core/gfxmenu/gui_list.c 2013-07-19 19:52:28.168444172 +0400
+++ grub-new9/grub-core/gfxmenu/gui_list.c 2013-07-19 21:51:11.718382023 +0400
@@ -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;
reply other threads:[~2013-07-19 18:36 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1622677.CGEa7UfXCP@icedphoenix \
--to=vladimir.testov@rosalab.ru \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.