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
1=== modified file 'os/os-private.h'
2--- os/os-private.h 2011-10-08 12:24:13 +0000
3+++ os/os-private.h 2011-10-20 20:07:26 +0000
4@@ -36,7 +36,7 @@
5 /* Size of the thumb in pixels. */
6 #define MIN_THUMB_HEIGHT 35
7 #define THUMB_WIDTH 17
8-#define THUMB_HEIGHT 69
9+#define THUMB_HEIGHT 68
10
11 /* Number of tolerance pixels on pageup/down, while intercepting a motion-notify-event. */
12 #define TOLERANCE_MOTION 2
13
14=== modified file 'os/os-thumb.c'
15--- os/os-thumb.c 2011-10-12 15:08:31 +0000
16+++ os/os-thumb.c 2011-10-20 20:07:26 +0000
17@@ -366,6 +366,36 @@
18 cairo_restore (cr);
19 }
20
21+/* Draw a grip using cairo. */
22+static void
23+draw_grip (cairo_t *cr,
24+ const GdkRGBA *color1,
25+ const GdkRGBA *color2,
26+ gdouble x,
27+ gdouble y,
28+ gint nx,
29+ gint ny)
30+{
31+ gint lx, ly;
32+
33+ for (ly = 0; ly < ny; ly++)
34+ {
35+ for (lx = 0; lx < nx; lx++)
36+ {
37+ gint sx = lx * 3;
38+ gint sy = ly * 3;
39+
40+ cairo_set_source_rgba (cr, color2->red, color2->green, color2->blue, color2->alpha);
41+ cairo_rectangle (cr, x + sx, y + sy, 2, 2);
42+ cairo_fill (cr);
43+
44+ cairo_set_source_rgba (cr, color1->red, color1->green, color1->blue, color1->alpha);
45+ cairo_rectangle (cr, x + sx, y + sy, 1, 1);
46+ cairo_fill (cr);
47+ }
48+ }
49+}
50+
51 /* Draw a rounded rectangle using cairo. */
52 static void
53 draw_round_rect (cairo_t *cr,
54@@ -756,28 +786,62 @@
55
56 shade_gdk_rgba (&bg, 1.2, &bg_bright_line);
57
58+ /* Only draw the grip when the thumb is at full height. */
59+ if ((priv->orientation == GTK_ORIENTATION_VERTICAL && height == THUMB_HEIGHT - 1) ||
60+ (priv->orientation == GTK_ORIENTATION_HORIZONTAL && width == THUMB_HEIGHT - 1) )
61+ {
62+ GdkRGBA grip_dot_up, grip_dot_down, grip_inset_up, grip_inset_down;
63+
64+ grip_dot_up = bg_dark_line;
65+ grip_dot_up.alpha = 0.74;
66+ grip_dot_down = bg_dark_line;
67+ grip_dot_down.alpha = 0.86;
68+ grip_inset_up = bg_bright_line;
69+ grip_inset_up.alpha = priv->event & OS_EVENT_BUTTON_PRESS ? 0.62 : 1.0;
70+ grip_inset_down = bg_bright_line;
71+ grip_inset_down.alpha = 0.36;
72+
73+ /* Grip. */
74+ if (priv->orientation == GTK_ORIENTATION_VERTICAL)
75+ {
76+ /* Page UP. */
77+ draw_grip (cr, &grip_dot_up, &grip_inset_up, 4.5, 15.5, 3, 5);
78+
79+ /* Page DOWN. */
80+ draw_grip (cr, &grip_dot_down, &grip_inset_down, 4.5, height / 2 + 4.5, 3, 5);
81+ }
82+ else
83+ {
84+ /* Page UP. */
85+ draw_grip (cr, &grip_dot_up, &grip_inset_up, 15.5, 4.5, 5, 3);
86+
87+ /* Page DOWN. */
88+ draw_grip (cr, &grip_dot_down, &grip_inset_down, width / 2 + 4.5, 4.5, 5, 3);
89+ }
90+ }
91+
92 /* Separators between the two steppers. */
93 if (priv->orientation == GTK_ORIENTATION_VERTICAL)
94 {
95- cairo_move_to (cr, 2.5, - 1 + height / 2);
96- cairo_line_to (cr, width - 2.5, - 1 + height / 2);
97- set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
98- cairo_stroke (cr);
99-
100 cairo_move_to (cr, 2.5, height / 2);
101 cairo_line_to (cr, width - 2.5, height / 2);
102+ set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
103+ cairo_stroke (cr);
104+
105+ cairo_move_to (cr, 2.5, 1 + height / 2);
106+ cairo_line_to (cr, width - 2.5, 1 + height / 2);
107 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);
108 cairo_stroke (cr);
109 }
110 else
111 {
112- cairo_move_to (cr, - 1 + width / 2, 2.5);
113- cairo_line_to (cr, - 1 + width / 2, height - 2.5);
114- set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
115- cairo_stroke (cr);
116-
117 cairo_move_to (cr, width / 2, 2.5);
118 cairo_line_to (cr, width / 2, height - 2.5);
119+ set_source_gdk_rgba (cr, &bg_dark_line, 0.36);
120+ cairo_stroke (cr);
121+
122+ cairo_move_to (cr, 1 + width / 2, 2.5);
123+ cairo_line_to (cr, 1 + width / 2, height - 2.5);
124 set_source_gdk_rgba (cr, &bg_bright_line, 0.5);
125 cairo_stroke (cr);
126 }

Subscribers

People subscribed via source and target branches