* [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice
@ 2013-07-19 13:41 Vladimir Testov
2013-07-19 17:18 ` Vladimir Testov
0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Testov @ 2013-07-19 13:41 UTC (permalink / raw)
To: grub-devel
[-- 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 --]
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice
2013-07-19 13:41 [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice Vladimir Testov
@ 2013-07-19 17:18 ` Vladimir Testov
0 siblings, 0 replies; 2+ messages in thread
From: Vladimir Testov @ 2013-07-19 17:18 UTC (permalink / raw)
To: grub-devel
[-- Attachment #1: Type: text/plain, Size: 1132 bytes --]
Updated because [7/11] patch has been updated.
On Friday, July 19, 2013 05:41:38 PM Vladimir Testov wrote:
> 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
--
With best regards,
_______________________________
Vladimir Testov, ROSA Laboratory.
www.rosalab.ru
[-- Attachment #2: grub-list-scrollbar-slice.patch --]
[-- Type: text/x-patch, Size: 5270 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-19 19:49:41.875854896 +0400
+++ grub-new8/grub-core/gfxmenu/gui_list.c 2013-07-19 19:52:28.168444172 +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)
{
@@ -198,6 +208,18 @@
self->draw_scrollbar = 0;
return 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;
+ }
+ }
}
}
@@ -333,7 +355,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);
@@ -435,11 +457,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;
@@ -448,6 +471,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);
@@ -456,16 +509,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);
}
}
@@ -659,6 +708,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;
@@ -766,6 +824,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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-07-19 17:18 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-19 13:41 [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice Vladimir Testov
2013-07-19 17:18 ` Vladimir Testov
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).