From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1V0EKJ-0006z6-NQ for mharc-grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0EKH-0006vh-3c for grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0EKF-0008Sh-P7 for grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:41 -0400 Received: from collab.rosalab.ru ([195.19.76.181]:40279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0EKF-0008SI-74 for grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:39 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by collab.rosalab.ru (Postfix) with ESMTP id 82AEE78E8002 for ; Fri, 19 Jul 2013 21:18:38 +0400 (MSK) X-Virus-Scanned: amavisd-new at rosalab.ru Received: from collab.rosalab.ru ([127.0.0.1]) by localhost (collab.rosalab.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id c5-bc8ITvBCX for ; Fri, 19 Jul 2013 21:18:37 +0400 (MSK) Received: from icedphoenix.localnet (unknown [217.199.216.178]) by collab.rosalab.ru (Postfix) with ESMTPSA id A8B3F29C231 for ; Fri, 19 Jul 2013 21:18:37 +0400 (MSK) From: Vladimir Testov To: grub-devel@gnu.org Subject: Re: [PATCH] [8/11] grub-core/gfxmenu/gui_list.c - new option: scrollbar_slice Date: Fri, 19 Jul 2013 21:18:36 +0400 Message-ID: <2262375.6buk8PcfYQ@icedphoenix> User-Agent: KMail/4.10.4 (Linux/3.8.0-26-generic; KDE/4.10.4; x86_64; ; ) In-Reply-To: <2002440.cKTnSvmPFE@icedphoenix> References: <2002440.cKTnSvmPFE@icedphoenix> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1523965.HQMsKxpB1E" Content-Transfer-Encoding: 7Bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 195.19.76.181 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Jul 2013 17:18:42 -0000 This is a multi-part message in MIME format. --nextPart1523965.HQMsKxpB1E Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 --nextPart1523965.HQMsKxpB1E Content-Disposition: attachment; filename="grub-list-scrollbar-slice.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="grub-list-scrollbar-slice.patch" 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 #include +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; --nextPart1523965.HQMsKxpB1E--