]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
* grub-core/gfxmenu/gui_list.c: New option `scrollbar_thumb_overlay`.
authorVladimir Testov <vladimir.testov@rosalab.ru>
Thu, 10 Oct 2013 10:37:19 +0000 (14:37 +0400)
committerVladimir Testov <vladimir.testov@rosalab.ru>
Thu, 10 Oct 2013 10:37:19 +0000 (14:37 +0400)
       * docs/grub.texi: Likewise.

ChangeLog
docs/grub.texi
grub-core/gfxmenu/gui_list.c

index 398061998f29dd6fb9202a5c6975cda9ffabde8d..2facfea62fe478e569d57004fab0f90bb4118463 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-10-10  Vladimir Testov  <vladimir.testov@rosalab.ru>
+
+       * grub-core/gfxmenu/gui_list.c: New option `scrollbar_thumb_overlay`.
+       * docs/grub.texi: Likewise.
+
 2013-10-10  Vladimir Serbinenko  <phcoder@gmail.com>
 
        * util/getroot.c (make_device_name): Remove dos_part and bsd_part as
index 7a66314df37b362cc2b724c97df597cfa14e7cf2..c1c45ada605703643139566c9d914949998e3da3 100644 (file)
@@ -2151,6 +2151,14 @@ The following is a list of the components and the properties they support.
       @tab The image file pattern for the scroll bar thumb (the part of the scroll
       bar that moves as scrolling occurs).
       Example:  ``scrollbar_thumb_*.png``
+   @item scrollbar_thumb_overlay
+      @tab If this option is set to ``true`` then the scrollbar thumb
+      side slices (every slice except the center slice) will overlay the
+      scrollbar frame side slices. And the center slice of the scrollbar_thumb
+      can move all the way (from top to bottom), being drawn on the center
+      slice of the scrollbar frame. That way we can make a scrollbar with
+      round-shaped edges so there won't be a free space from the thumb to
+      the frame in top and bottom scrollbar positions. Default is ``false``.
    @item scrollbar_slice
       @tab The menu frame styled box's slice in which the scrollbar will be
       drawn. Possible values are ``west``, ``center``, ``east`` (default).
index 10c670d49ca776c22f7bd6ca01adaeb39a9eecdd..660d0156a3eaa768435e3b616d775e4d717bf08a 100644 (file)
@@ -59,6 +59,7 @@ struct grub_gui_list_impl
   char *scrollbar_thumb_pattern;
   grub_gfxmenu_box_t scrollbar_frame;
   grub_gfxmenu_box_t scrollbar_thumb;
+  int scrollbar_thumb_overlay;
   int scrollbar_width;
   enum scrollbar_slice_mode scrollbar_slice;
   int scrollbar_left_pad;
@@ -222,6 +223,11 @@ draw_scrollbar (list_impl_t self,
   frame->set_content_size (frame,
                            scrollbar_width - frame_horizontal_pad,
                            tracklen);
+  if (self->scrollbar_thumb_overlay)
+    {
+      tracklen += thumb_vertical_pad;
+      tracktop -= thumb->get_top_pad (thumb);
+    }
   int thumby = tracktop + tracklen * (value - min) / (max - min);
   int thumbheight = tracklen * extent / (max - min) + 1;
   /* Rare occasion: too many entries or too low height. */
@@ -231,12 +237,16 @@ draw_scrollbar (list_impl_t self,
       thumby = tracktop + ((tracklen - thumb_vertical_pad) * (value - min)
                            / (max - extent));
     }
-  thumb->set_content_size (thumb,
-                           scrollbar_width - frame_horizontal_pad
-                           - thumb_horizontal_pad,
+  int thumbx = frame->get_left_pad (frame);
+  int thumbwidth = scrollbar_width - frame_horizontal_pad;
+  if (!self->scrollbar_thumb_overlay)
+    thumbwidth -= thumb_horizontal_pad;
+  else
+    thumbx -= thumb->get_left_pad (thumb);
+  thumb->set_content_size (thumb, thumbwidth,
                            thumbheight - thumb_vertical_pad);
   frame->draw (frame, 0, 0);
-  thumb->draw (thumb, frame->get_left_pad (frame), thumby);
+  thumb->draw (thumb, thumbx, thumby);
 }
 
 /* Draw the list of items.  */
@@ -649,6 +659,10 @@ list_set_property (void *vself, const char *name, const char *value)
       grub_free (self->scrollbar_thumb_pattern);
       self->scrollbar_thumb_pattern = value ? grub_strdup (value) : 0;
     }
+  else if (grub_strcmp (name, "scrollbar_thumb_overlay") == 0)
+    {
+      self->scrollbar_thumb_overlay = grub_strcmp (value, "true") == 0;
+    }
   else if (grub_strcmp (name, "scrollbar_width") == 0)
     {
       self->scrollbar_width = grub_strtol (value, 0, 10);
@@ -778,6 +792,7 @@ grub_gui_list_new (void)
   self->scrollbar_thumb = 0;
   self->scrollbar_frame_pattern = 0;
   self->scrollbar_thumb_pattern = 0;
+  self->scrollbar_thumb_overlay = 0;
   self->scrollbar_width = 16;
   self->scrollbar_slice = SCROLLBAR_SLICE_EAST;
   self->scrollbar_left_pad = 2;