From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1V0FXe-0001Ep-Us for mharc-grub-devel@gnu.org; Fri, 19 Jul 2013 14:36:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33474) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0FXb-0001Eg-Tx for grub-devel@gnu.org; Fri, 19 Jul 2013 14:36:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0FXa-0007Hb-HG for grub-devel@gnu.org; Fri, 19 Jul 2013 14:36:31 -0400 Received: from collab.rosalab.ru ([195.19.76.181]:44649) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0FXa-0007Gs-1R for grub-devel@gnu.org; Fri, 19 Jul 2013 14:36:30 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by collab.rosalab.ru (Postfix) with ESMTP id 4B8C078E8002 for ; Fri, 19 Jul 2013 22:36:28 +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 WbO0PMNG99N0 for ; Fri, 19 Jul 2013 22:36:27 +0400 (MSK) Received: from icedphoenix.localnet (unknown [217.199.216.178]) by collab.rosalab.ru (Postfix) with ESMTPSA id 5359429C1AB for ; Fri, 19 Jul 2013 22:36:27 +0400 (MSK) From: Vladimir Testov 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 Message-ID: <1622677.CGEa7UfXCP@icedphoenix> User-Agent: KMail/4.10.4 (Linux/3.8.0-26-generic; KDE/4.10.4; x86_64; ; ) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart1705012.s2gdy1nqHt" 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 18:36:33 -0000 This is a multi-part message in MIME format. --nextPart1705012.s2gdy1nqHt Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" 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 --nextPart1705012.s2gdy1nqHt Content-Disposition: attachment; filename="grub-list-scrollbar-padding.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="grub-list-scrollbar-padding.patch" 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; --nextPart1705012.s2gdy1nqHt--