Merge lp:~cimi/overlay-scrollbar/add-grip into lp:overlay-scrollbar

Proposed by Andrea Cimitan
Status: Merged
Merged at revision: 315
Proposed branch: lp:~cimi/overlay-scrollbar/add-grip
Merge into: lp:overlay-scrollbar
Diff against target: 126 lines (+75/-11)
2 files modified
os/os-private.h (+1/-1)
os/os-thumb.c (+74/-10)
To merge this branch: bzr merge lp:~cimi/overlay-scrollbar/add-grip
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+79995@code.launchpad.net

Description of the change

Add grip as design requested

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'os/os-private.h'
--- os/os-private.h 2011-10-08 12:24:13 +0000
+++ os/os-private.h 2011-10-20 20:07:26 +0000
@@ -36,7 +36,7 @@
36/* Size of the thumb in pixels. */36/* Size of the thumb in pixels. */
37#define MIN_THUMB_HEIGHT 3537#define MIN_THUMB_HEIGHT 35
38#define THUMB_WIDTH 1738#define THUMB_WIDTH 17
39#define THUMB_HEIGHT 6939#define THUMB_HEIGHT 68
4040
41/* Number of tolerance pixels on pageup/down, while intercepting a motion-notify-event. */41/* Number of tolerance pixels on pageup/down, while intercepting a motion-notify-event. */
42#define TOLERANCE_MOTION 242#define TOLERANCE_MOTION 2
4343
=== modified file 'os/os-thumb.c'
--- os/os-thumb.c 2011-10-12 15:08:31 +0000
+++ os/os-thumb.c 2011-10-20 20:07:26 +0000
@@ -366,6 +366,36 @@
366 cairo_restore (cr);366 cairo_restore (cr);
367}367}
368368
369/* Draw a grip using cairo. */
370static void
371draw_grip (cairo_t *cr,
372 const GdkRGBA *color1,
373 const GdkRGBA *color2,
374 gdouble x,
375 gdouble y,
376 gint nx,
377 gint ny)
378{
379 gint lx, ly;
380
381 for (ly = 0; ly < ny; ly++)
382 {
383 for (lx = 0; lx < nx; lx++)
384 {
385 gint sx = lx * 3;
386 gint sy = ly * 3;
387
388 cairo_set_source_rgba (cr, color2->red, color2->green, color2->blue, color2->alpha);
389 cairo_rectangle (cr, x + sx, y + sy, 2, 2);
390 cairo_fill (cr);
391
392 cairo_set_source_rgba (cr, color1->red, color1->green, color1->blue, color1->alpha);
393 cairo_rectangle (cr, x + sx, y + sy, 1, 1);
394 cairo_fill (cr);
395 }
396 }
397}
398
369/* Draw a rounded rectangle using cairo. */399/* Draw a rounded rectangle using cairo. */
370static void400static void
371draw_round_rect (cairo_t *cr,401draw_round_rect (cairo_t *cr,
@@ -756,28 +786,62 @@
756786
757 shade_gdk_rgba (&bg, 1.2, &bg_bright_line);787 shade_gdk_rgba (&bg, 1.2, &bg_bright_line);
758788
789 /* Only draw the grip when the thumb is at full height. */
790 if ((priv->orientation == GTK_ORIENTATION_VERTICAL && height == THUMB_HEIGHT - 1) ||
791 (priv->orientation == GTK_ORIENTATION_HORIZONTAL && width == THUMB_HEIGHT - 1) )
792 {
793 GdkRGBA grip_dot_up, grip_dot_down, grip_inset_up, grip_inset_down;
794
795 grip_dot_up = bg_dark_line;
796 grip_dot_up.alpha = 0.74;
797 grip_dot_down = bg_dark_line;
798 grip_dot_down.alpha = 0.86;
799 grip_inset_up = bg_bright_line;
800 grip_inset_up.alpha = priv->event & OS_EVENT_BUTTON_PRESS ? 0.62 : 1.0;
801 grip_inset_down = bg_bright_line;
802 grip_inset_down.alpha = 0.36;
803
804 /* Grip. */
805 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
806 {
807 /* Page UP. */
808 draw_grip (cr, &grip_dot_up, &grip_inset_up, 4.5, 15.5, 3, 5);
809
810 /* Page DOWN. */
811 draw_grip (cr, &grip_dot_down, &grip_inset_down, 4.5, height / 2 + 4.5, 3, 5);
812 }
813 else
814 {
815 /* Page UP. */
816 draw_grip (cr, &grip_dot_up, &grip_inset_up, 15.5, 4.5, 5, 3);
817
818 /* Page DOWN. */
819 draw_grip (cr, &grip_dot_down, &grip_inset_down, width / 2 + 4.5, 4.5, 5, 3);
820 }
821 }
822
759 /* Separators between the two steppers. */823 /* Separators between the two steppers. */
760 if (priv->orientation == GTK_ORIENTATION_VERTICAL)824 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
761 {825 {
762 cairo_move_to (cr, 2.5, - 1 + height / 2);
763 cairo_line_to (cr, width - 2.5, - 1 + height / 2);
764 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
765 cairo_stroke (cr);
766
767 cairo_move_to (cr, 2.5, height / 2);826 cairo_move_to (cr, 2.5, height / 2);
768 cairo_line_to (cr, width - 2.5, height / 2);827 cairo_line_to (cr, width - 2.5, height / 2);
828 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
829 cairo_stroke (cr);
830
831 cairo_move_to (cr, 2.5, 1 + height / 2);
832 cairo_line_to (cr, width - 2.5, 1 + height / 2);
769 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);833 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);
770 cairo_stroke (cr);834 cairo_stroke (cr);
771 }835 }
772 else836 else
773 {837 {
774 cairo_move_to (cr, - 1 + width / 2, 2.5);
775 cairo_line_to (cr, - 1 + width / 2, height - 2.5);
776 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
777 cairo_stroke (cr);
778
779 cairo_move_to (cr, width / 2, 2.5);838 cairo_move_to (cr, width / 2, 2.5);
780 cairo_line_to (cr, width / 2, height - 2.5);839 cairo_line_to (cr, width / 2, height - 2.5);
840 set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
841 cairo_stroke (cr);
842
843 cairo_move_to (cr, 1 + width / 2, 2.5);
844 cairo_line_to (cr, 1 + width / 2, height - 2.5);
781 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);845 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);
782 cairo_stroke (cr);846 cairo_stroke (cr);
783 }847 }

Subscribers

People subscribed via source and target branches