Received: from list by lists.gnu.org with archive (Exim 4.71) id 1V0EK8-0006lp-K5 for mharc-grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37849) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0EK6-0006l7-F0 for grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V0EK4-0008QC-TT for grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:30 -0400 Received: from collab.rosalab.ru ([195.19.76.181]:40256) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V0EK4-0008Pp-D0 for grub-devel@gnu.org; Fri, 19 Jul 2013 13:18:28 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by collab.rosalab.ru (Postfix) with ESMTP id 80E4378E8002 for ; Fri, 19 Jul 2013 21:18:26 +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 7QaegysP350J for ; Fri, 19 Jul 2013 21:18:25 +0400 (MSK) Received: from icedphoenix.localnet (unknown [217.199.216.178]) by collab.rosalab.ru (Postfix) with ESMTPSA id 527D629C231 for ; Fri, 19 Jul 2013 21:18:25 +0400 (MSK) From: Vladimir Testov To: grub-devel@gnu.org Subject: Re: [PATCH] [7/?] grub-core/gfxmenu/gui_list.c - scrollbar thumb offsets Date: Fri, 19 Jul 2013 21:18:24 +0400 Message-ID: <18084382.gW1TdWkS78@icedphoenix> User-Agent: KMail/4.10.4 (Linux/3.8.0-26-generic; KDE/4.10.4; x86_64; ; ) In-Reply-To: <29239602.0j2IXQlNj4@icedphoenix> References: <29239602.0j2IXQlNj4@icedphoenix> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart2146011.EJZSLTKWQu" 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:31 -0000 This is a multi-part message in MIME format. --nextPart2146011.EJZSLTKWQu Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sanity checks fixed. Rare case with too big scrollbar frame was incorrectly handled. On Thursday, July 18, 2013 07:57:14 PM Vladimir Testov wrote: > New options > scrollbar_thumb_top_offset > scrollbar_thumb_bottom_offset > > With these two options we can make scrollbar thumb with round edges so it > will fit to the scrollbar frame. See screenshots. > > offset is a number of pixels to indent from the edge of the center slice of > the scrollbar's frame. > positive value means we move to the bottom > negative value means we move to the top > > in the example given (see screenshots) > scrollbar_thumb_top_offset = -5 > scrollbar_thumb_bottom_offset = 5 > > Sanity checks are present. > > -- > With best regards, > _______________________________ > Vladimir Testov, ROSA Laboratory. > www.rosalab.ru -- With best regards, _______________________________ Vladimir Testov, ROSA Laboratory. www.rosalab.ru --nextPart2146011.EJZSLTKWQu Content-Disposition: attachment; filename="grub-list-scrollbar-thumb-offset.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="grub-list-scrollbar-thumb-offset.patch" diff -Naur grub-new6/grub-core/gfxmenu/gui_list.c grub-new7/grub-core/gfxmenu/gui_list.c --- grub-new6/grub-core/gfxmenu/gui_list.c 2013-07-17 20:07:37.664064169 +0400 +++ grub-new7/grub-core/gfxmenu/gui_list.c 2013-07-19 19:49:41.875854896 +0400 @@ -56,6 +56,8 @@ char *scrollbar_thumb_pattern; grub_gfxmenu_box_t scrollbar_frame; grub_gfxmenu_box_t scrollbar_thumb; + int scrollbar_thumb_top_offset; + int scrollbar_thumb_bottom_offset; int scrollbar_width; int first_shown_index; @@ -149,27 +151,49 @@ self->need_to_recreate_scrollbar = 0; + /* Sanity checks. */ if (self->scrollbar_frame != 0 && self->scrollbar_thumb != 0) { grub_gfxmenu_box_t box = self->menu_box; grub_gfxmenu_box_t frame = self->scrollbar_frame; grub_gfxmenu_box_t thumb = self->scrollbar_thumb; - int box_vertical_pad = (box->get_top_pad (box) - + box->get_bottom_pad (box)); + + int box_top_pad = box->get_top_pad (box); + int box_bottom_pad = box->get_bottom_pad (box); + int box_vertical_pad = box_top_pad + box_bottom_pad; + int frame_top_pad = frame->get_top_pad (frame); + int frame_bottom_pad = frame->get_bottom_pad (frame); + int frame_vertical_pad = frame_top_pad + frame_bottom_pad; int frame_horizontal_pad = (frame->get_left_pad (frame) + frame->get_right_pad (frame)); - int frame_vertical_pad = (frame->get_top_pad (frame) - + frame->get_bottom_pad (frame)); + int thumb_vertical_pad = (thumb->get_top_pad (thumb) + + thumb->get_bottom_pad (thumb)); int thumb_horizontal_pad = (thumb->get_left_pad (thumb) + thumb->get_right_pad (thumb)); - int thumb_vertical_pad = (thumb->get_top_pad (thumb) - + thumb->get_bottom_pad (thumb)); int scrollbar_height = self->bounds.height - box_vertical_pad; + /* Offset from the top of the scrollbar viewport. */ + int thumb_top = frame_top_pad + + self->scrollbar_thumb_top_offset; + /* Offset from the bottom of the scrollbar viewport. */ + int thumb_bottom = - frame_bottom_pad + + self->scrollbar_thumb_bottom_offset; + + /* Check offset sanity. */ + int real_height = scrollbar_height - thumb_top + thumb_bottom; + if (thumb_top < 0 || thumb_bottom > 0 + || real_height < thumb_vertical_pad) + { + self->scrollbar_thumb_top_offset = 0; + self->scrollbar_thumb_bottom_offset = 0; + real_height = scrollbar_height - frame_vertical_pad; + } + + /* Sanity checks themselves. */ if (self->scrollbar_width < frame_horizontal_pad + thumb_horizontal_pad - || scrollbar_height < frame_vertical_pad + thumb_vertical_pad) + || real_height < thumb_vertical_pad) { self->draw_scrollbar = 0; return 0; @@ -250,11 +274,13 @@ + thumb->get_bottom_pad (thumb)); int thumb_horizontal_pad = (thumb->get_left_pad (thumb) + thumb->get_right_pad (thumb)); - int tracktop = frame->get_top_pad (frame); + int tracktop = frame->get_top_pad (frame) + self->scrollbar_thumb_top_offset; int tracklen = scrollbar_height - frame_vertical_pad; frame->set_content_size (frame, scrollbar_width - frame_horizontal_pad, tracklen); + tracklen += - self->scrollbar_thumb_top_offset + + self->scrollbar_thumb_bottom_offset; int thumby; int thumbheight = tracklen * extent / (max - min) + 1; if (thumbheight >= thumb_vertical_pad) @@ -619,6 +645,16 @@ grub_free (self->scrollbar_thumb_pattern); self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0; } + else if (grub_strcmp (name, "scrollbar_thumb_top_offset") == 0) + { + self->need_to_recreate_scrollbar = 1; + self->scrollbar_thumb_top_offset = grub_strtol (value, 0, 10); + } + else if (grub_strcmp (name, "scrollbar_thumb_bottom_offset") == 0) + { + self->need_to_recreate_scrollbar = 1; + self->scrollbar_thumb_bottom_offset = grub_strtol (value, 0, 10); + } else if (grub_strcmp (name, "scrollbar_width") == 0) { self->scrollbar_width = grub_strtoul (value, 0, 10); @@ -727,6 +763,8 @@ self->scrollbar_thumb = 0; self->scrollbar_frame_pattern = 0; self->scrollbar_thumb_pattern = 0; + self->scrollbar_thumb_top_offset = 0; + self->scrollbar_thumb_bottom_offset = 0; self->scrollbar_width = 16; self->first_shown_index = 0; --nextPart2146011.EJZSLTKWQu--