From: Vladimir Testov <vladimir.testov@rosalab.ru>
To: grub-devel@gnu.org
Subject: [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice
Date: Fri, 19 Jul 2013 17:41:38 +0400 [thread overview]
Message-ID: <2002440.cKTnSvmPFE@icedphoenix> (raw)
[-- Attachment #1: Type: text/plain, Size: 879 bytes --]
scrollbar_slice = "east" \ "center" \ "west"
Typically, the scrollbar is drawn in the east slice.
Now we can decide where we would like it to be drawn.
"east", default value, works the same way as it was before.
"west" scrollbar is drawn to the left from the entry list, in the west slice.
"center" scrollbar is drawn in the center slice of the boot menu. That way we
don't need to make special east slice of the menu decoration box
(menu_pixmap_style). moreover, we no longer need to use menu_pixmap_style if
we would like to see the scrollbar in the theme we are making. If there is no
need to draw the scrollbar then item's width is maximal. If we need to draw
the scrollbar then item's width will be decreased so the scrollbar will be
drawn on the free space.
--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
[-- Attachment #2: grub-list-scrollbar-slice.patch --]
[-- Type: text/x-patch, Size: 5313 bytes --]
diff -Naur grub-new7/grub-core/gfxmenu/gui_list.c grub-new8/grub-core/gfxmenu/gui_list.c
--- grub-new7/grub-core/gfxmenu/gui_list.c 2013-07-18 17:50:44.251123544 +0400
+++ grub-new8/grub-core/gfxmenu/gui_list.c 2013-07-19 16:34:43.385698385 +0400
@@ -25,6 +25,12 @@
#include <grub/gfxwidgets.h>
#include <grub/color.h>
+enum scrollbar_slices {
+ SCROLLBAR_SLICE_WEST,
+ SCROLLBAR_SLICE_CENTER,
+ SCROLLBAR_SLICE_EAST
+};
+
struct grub_gui_list_impl
{
struct grub_gui_list list;
@@ -59,6 +65,7 @@
int scrollbar_thumb_top_offset;
int scrollbar_thumb_bottom_offset;
int scrollbar_width;
+ int scrollbar_slice;
int first_shown_index;
@@ -136,6 +143,9 @@
return (self->menu_box != 0 && self->selected_item_box != 0);
}
+static void
+list_get_minimal_size (void *vself, unsigned *width, unsigned *height);
+
static int
check_scrollbar (list_impl_t self)
{
@@ -196,6 +206,18 @@
self->scrollbar_thumb_top_offset = 0;
self->scrollbar_thumb_bottom_offset = 0;
}
+
+ /* Checks for scrollbar_slice option. */
+ if (self->scrollbar_slice == SCROLLBAR_SLICE_CENTER)
+ {
+ 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;
+ }
+ }
}
}
@@ -331,7 +353,7 @@
oviewport.width - 2 * boxpad,
oviewport.height - 2 * boxpad);
- int cwidth = oviewport.width - 2 * boxpad - 2;
+ int cwidth = oviewport.width - 2 * boxpad;
if (selbox->get_border_width)
cwidth -= selbox->get_border_width (selbox);
selbox->set_content_size (selbox, cwidth, item_height);
@@ -433,11 +455,12 @@
int box_top_pad = box->get_top_pad (box);
int box_right_pad = box->get_right_pad (box);
int box_bottom_pad = box->get_bottom_pad (box);
- grub_video_rect_t vpsave2, content_rect;
+ grub_video_rect_t vpsave2, content_rect, scrollbar_rect;
int num_shown_items = get_num_shown_items (self);
int drawing_scrollbar = (self->draw_scrollbar
&& (num_shown_items < self->view->menu->size)
&& check_scrollbar (self));
+ int scrollbar_width = self->scrollbar_width;
content_rect.x = box_left_pad;
content_rect.y = box_top_pad;
@@ -446,6 +469,36 @@
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;
+ switch (self->scrollbar_slice)
+ {
+ case SCROLLBAR_SLICE_WEST:
+ content_rect.x += 2;
+ content_rect.width -= 2;
+ scrollbar_rect.x = box_left_pad - scrollbar_width;
+ if (scrollbar_width > box_left_pad)
+ {
+ scrollbar_rect.x = 0;
+ scrollbar_rect.width = box_left_pad;
+ }
+ break;
+ case SCROLLBAR_SLICE_CENTER:
+ content_rect.width -= 2;
+ if (drawing_scrollbar)
+ content_rect.width -= scrollbar_width;
+ scrollbar_rect.x = self->bounds.width - box_right_pad
+ - scrollbar_width;
+ break;
+ case SCROLLBAR_SLICE_EAST:
+ content_rect.width -= 2;
+ scrollbar_rect.x = self->bounds.width - box_right_pad;
+ if (scrollbar_width > box_right_pad)
+ scrollbar_rect.width = box_right_pad;
+ break;
+ }
+
box->draw (box, 0, 0);
grub_gui_set_viewport (&content_rect, &vpsave2);
@@ -454,16 +507,12 @@
if (drawing_scrollbar)
{
- /* Draw the scrollbar in the east slice. */
- content_rect.x = self->bounds.width - box_right_pad;
- content_rect.width = box_right_pad;
-
- grub_gui_set_viewport (&content_rect, &vpsave2);
+ grub_gui_set_viewport (&scrollbar_rect, &vpsave2);
draw_scrollbar (self,
self->first_shown_index, num_shown_items,
0, self->view->menu->size,
- self->scrollbar_width,
- content_rect.height);
+ scrollbar_width,
+ scrollbar_rect.height);
grub_gui_restore_viewport (&vpsave2);
}
}
@@ -657,6 +706,15 @@
{
self->scrollbar_width = grub_strtoul (value, 0, 10);
}
+ else if (grub_strcmp (name, "scrollbar_slice") == 0)
+ {
+ if (grub_strcmp (value, "west") == 0)
+ self->scrollbar_slice = SCROLLBAR_SLICE_WEST;
+ else if (grub_strcmp (value, "center") == 0)
+ self->scrollbar_slice = SCROLLBAR_SLICE_CENTER;
+ else if (grub_strcmp (value, "east") == 0)
+ self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
+ }
else if (grub_strcmp (name, "scrollbar") == 0)
{
self->draw_scrollbar = grub_strcmp (value, "false") != 0;
@@ -764,6 +822,7 @@
self->scrollbar_thumb_top_offset = 0;
self->scrollbar_thumb_bottom_offset = 0;
self->scrollbar_width = 16;
+ self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
self->first_shown_index = 0;
[-- Attachment #3: west.png --]
[-- Type: image/png, Size: 4203 bytes --]
[-- Attachment #4: center.png --]
[-- Type: image/png, Size: 23989 bytes --]
[-- Attachment #5: center2.png --]
[-- Type: image/png, Size: 23855 bytes --]
[-- Attachment #6: east.png --]
[-- Type: image/png, Size: 4403 bytes --]
next reply other threads:[~2013-07-19 13:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-19 13:41 Vladimir Testov [this message]
2013-07-19 17:18 ` [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice Vladimir Testov
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=2002440.cKTnSvmPFE@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).