Merge lp:~cimi/overlay-scrollbar/new-visuals into lp:overlay-scrollbar
- new-visuals
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Merged |
---|---|
Merged at revision: | 326 |
Proposed branch: | lp:~cimi/overlay-scrollbar/new-visuals |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
343 lines (+113/-69) 3 files modified
os/os-private.h (+1/-1) os/os-scrollbar.c (+1/-1) os/os-thumb.c (+111/-67) |
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/new-visuals |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alberto Ruiz (community) | Approve | ||
Ayatana Scrollbar Team | Pending | ||
Review via email: mp+86260@code.launchpad.net |
Commit message
Description of the change
Some changes to visuals, bigger thumbs too
To post a comment you must log in.
- 329. By Andrea Cimitan
-
More tweaks
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-20 20:05:45 +0000 |
3 | +++ os/os-private.h 2011-12-20 14:36:31 +0000 |
4 | @@ -35,7 +35,7 @@ |
5 | |
6 | /* Size of the thumb in pixels. */ |
7 | #define MIN_THUMB_HEIGHT 35 |
8 | -#define THUMB_WIDTH 17 |
9 | +#define THUMB_WIDTH 21 |
10 | #define THUMB_HEIGHT 68 |
11 | |
12 | /* Number of tolerance pixels on pageup/down, while intercepting a motion-notify-event. */ |
13 | |
14 | === modified file 'os/os-scrollbar.c' |
15 | --- os/os-scrollbar.c 2011-12-05 16:45:35 +0000 |
16 | +++ os/os-scrollbar.c 2011-12-20 14:36:31 +0000 |
17 | @@ -38,7 +38,7 @@ |
18 | #define BAR_SIZE 3 |
19 | |
20 | /* Size of the proximity effect in pixels. */ |
21 | -#define PROXIMITY_SIZE 30 |
22 | +#define PROXIMITY_SIZE 34 |
23 | |
24 | /* Max duration of the scrolling. */ |
25 | #define MAX_DURATION_SCROLLING 1000 |
26 | |
27 | === modified file 'os/os-thumb.c' |
28 | --- os/os-thumb.c 2011-10-20 20:05:45 +0000 |
29 | +++ os/os-thumb.c 2011-12-20 14:36:31 +0000 |
30 | @@ -369,8 +369,6 @@ |
31 | /* Draw a grip using cairo. */ |
32 | static void |
33 | draw_grip (cairo_t *cr, |
34 | - const GdkRGBA *color1, |
35 | - const GdkRGBA *color2, |
36 | gdouble x, |
37 | gdouble y, |
38 | gint nx, |
39 | @@ -385,13 +383,7 @@ |
40 | gint sx = lx * 3; |
41 | gint sy = ly * 3; |
42 | |
43 | - cairo_set_source_rgba (cr, color2->red, color2->green, color2->blue, color2->alpha); |
44 | - cairo_rectangle (cr, x + sx, y + sy, 2, 2); |
45 | - cairo_fill (cr); |
46 | - |
47 | - cairo_set_source_rgba (cr, color1->red, color1->green, color1->blue, color1->alpha); |
48 | cairo_rectangle (cr, x + sx, y + sy, 1, 1); |
49 | - cairo_fill (cr); |
50 | } |
51 | } |
52 | } |
53 | @@ -636,6 +628,13 @@ |
54 | } |
55 | #endif |
56 | |
57 | +enum { |
58 | + ACTION_NORMAL, |
59 | + ACTION_DRAG, |
60 | + ACTION_PAGE_UP, |
61 | + ACTION_PAGE_DOWN |
62 | +}; |
63 | + |
64 | static gboolean |
65 | #ifdef USE_GTK3 |
66 | os_thumb_draw (GtkWidget *widget, |
67 | @@ -659,6 +658,7 @@ |
68 | cairo_pattern_t *pat; |
69 | gint width, height; |
70 | gint radius; |
71 | + gint action; |
72 | |
73 | thumb = OS_THUMB (widget); |
74 | priv = thumb->priv; |
75 | @@ -704,6 +704,19 @@ |
76 | cairo_set_line_width (cr, 1.0); |
77 | cairo_set_operator (cr, CAIRO_OPERATOR_OVER); |
78 | |
79 | + /* Type of action. */ |
80 | + action = ACTION_NORMAL; |
81 | + if (priv->event & OS_EVENT_BUTTON_PRESS) |
82 | + { |
83 | + if (priv->event & OS_EVENT_MOTION_NOTIFY) |
84 | + action = ACTION_DRAG; |
85 | + else if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer.y < height / 2)) || |
86 | + (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer.x < width / 2))) |
87 | + action = ACTION_PAGE_UP; |
88 | + else |
89 | + action = ACTION_PAGE_DOWN; |
90 | + } |
91 | + |
92 | /* Background. */ |
93 | draw_round_rect (cr, 0, 0, width, height, radius); |
94 | |
95 | @@ -711,52 +724,52 @@ |
96 | cairo_fill_preserve (cr); |
97 | |
98 | /* Background pattern from top to bottom. */ |
99 | - shade_gdk_rgba (&bg, 1.3, &bg_arrow_up); |
100 | - shade_gdk_rgba (&bg, 0.7, &bg_arrow_down); |
101 | + shade_gdk_rgba (&bg, 0.86, &bg_arrow_up); |
102 | + shade_gdk_rgba (&bg, 1.1, &bg_arrow_down); |
103 | |
104 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
105 | pat = cairo_pattern_create_linear (0, 0, 0, height); |
106 | else |
107 | pat = cairo_pattern_create_linear (0, 0, width, 0); |
108 | |
109 | - if ((priv->event & OS_EVENT_BUTTON_PRESS) && |
110 | - !(priv->event & OS_EVENT_MOTION_NOTIFY)) |
111 | - { |
112 | - if ((priv->orientation == GTK_ORIENTATION_VERTICAL && (priv->pointer.y < height / 2)) || |
113 | - (priv->orientation == GTK_ORIENTATION_HORIZONTAL && (priv->pointer.x < width / 2))) |
114 | - { |
115 | - pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_down, 0.6); |
116 | - pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1); |
117 | - pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1); |
118 | - pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 0.8); |
119 | - } |
120 | - else |
121 | - { |
122 | - pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_up, 0.8); |
123 | - pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_up, 0.1); |
124 | - pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.2); |
125 | - pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 1.0); |
126 | - } |
127 | - } |
128 | - else |
129 | - { |
130 | - pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_up, 0.8); |
131 | - pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_up, 0.1); |
132 | - pattern_add_gdk_rgba_stop (pat, 0.49, &bg_arrow_down, 0.1); |
133 | - pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 0.8); |
134 | - } |
135 | + pattern_add_gdk_rgba_stop (pat, 0.0, &bg_arrow_up, 0.8); |
136 | + pattern_add_gdk_rgba_stop (pat, 1.0, &bg_arrow_down, 0.8); |
137 | + |
138 | cairo_set_source (cr, pat); |
139 | cairo_pattern_destroy (pat); |
140 | |
141 | - if (priv->event & OS_EVENT_MOTION_NOTIFY) |
142 | + if (action == ACTION_DRAG) |
143 | { |
144 | cairo_fill_preserve (cr); |
145 | - set_source_gdk_rgba (cr, &bg_arrow_down, 0.3); |
146 | + set_source_gdk_rgba (cr, &bg, 0.8); |
147 | cairo_fill (cr); |
148 | } |
149 | else |
150 | cairo_fill (cr); |
151 | |
152 | + /* Page up or down pressed buttons. */ |
153 | + if (action == ACTION_PAGE_UP || |
154 | + action == ACTION_PAGE_DOWN) |
155 | + { |
156 | + if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
157 | + { |
158 | + if (action == ACTION_PAGE_UP) |
159 | + cairo_rectangle (cr, 0, 0, width, height / 2); |
160 | + else |
161 | + cairo_rectangle (cr, 0, height / 2, width, height / 2); |
162 | + } |
163 | + else |
164 | + { |
165 | + if (action == ACTION_PAGE_UP) |
166 | + cairo_rectangle (cr, 0, 0, width / 2, height); |
167 | + else |
168 | + cairo_rectangle (cr, width / 2, 0, width / 2, height); |
169 | + } |
170 | + |
171 | + set_source_gdk_rgba (cr, &bg, 0.8); |
172 | + cairo_fill (cr); |
173 | + } |
174 | + |
175 | /* 2px fat border around the thumb. */ |
176 | cairo_save (cr); |
177 | |
178 | @@ -773,75 +786,106 @@ |
179 | /* 1px subtle shadow around the background. */ |
180 | shade_gdk_rgba (&bg, 0.2, &bg_shadow); |
181 | |
182 | + if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
183 | + pat = cairo_pattern_create_linear (0, 0, 0, height); |
184 | + else |
185 | + pat = cairo_pattern_create_linear (0, 0, width, 0); |
186 | + |
187 | + pattern_add_gdk_rgba_stop (pat, 0.5, &bg_shadow, 0.06); |
188 | + switch (action) |
189 | + { |
190 | + default: |
191 | + case ACTION_NORMAL: |
192 | + pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.22); |
193 | + pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.22); |
194 | + break; |
195 | + case ACTION_DRAG: |
196 | + pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.2); |
197 | + pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.2); |
198 | + break; |
199 | + case ACTION_PAGE_UP: |
200 | + pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.1); |
201 | + pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.22); |
202 | + break; |
203 | + case ACTION_PAGE_DOWN: |
204 | + pattern_add_gdk_rgba_stop (pat, 0.0, &bg_shadow, 0.22); |
205 | + pattern_add_gdk_rgba_stop (pat, 1.0, &bg_shadow, 0.1); |
206 | + break; |
207 | + } |
208 | + |
209 | + cairo_set_source (cr, pat); |
210 | + cairo_pattern_destroy (pat); |
211 | + |
212 | draw_round_rect (cr, 1, 1, width - 2, height - 2, radius); |
213 | - set_source_gdk_rgba (cr, &bg_shadow, 0.26); |
214 | cairo_stroke (cr); |
215 | |
216 | /* 1px frame around the background. */ |
217 | shade_gdk_rgba (&bg, 0.6, &bg_dark_line); |
218 | + shade_gdk_rgba (&bg, 1.2, &bg_bright_line); |
219 | |
220 | draw_round_rect (cr, 2, 2, width - 4, height - 4, radius - 1); |
221 | - set_source_gdk_rgba (cr, &bg_dark_line, 0.26); |
222 | + set_source_gdk_rgba (cr, &bg_bright_line, 0.6); |
223 | cairo_stroke (cr); |
224 | |
225 | - shade_gdk_rgba (&bg, 1.2, &bg_bright_line); |
226 | - |
227 | /* Only draw the grip when the thumb is at full height. */ |
228 | if ((priv->orientation == GTK_ORIENTATION_VERTICAL && height == THUMB_HEIGHT - 1) || |
229 | (priv->orientation == GTK_ORIENTATION_HORIZONTAL && width == THUMB_HEIGHT - 1) ) |
230 | { |
231 | - GdkRGBA grip_dot_up, grip_dot_down, grip_inset_up, grip_inset_down; |
232 | + if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
233 | + pat = cairo_pattern_create_linear (0, 0, 0, height); |
234 | + else |
235 | + pat = cairo_pattern_create_linear (0, 0, width, 0); |
236 | |
237 | - grip_dot_up = bg_dark_line; |
238 | - grip_dot_up.alpha = 0.74; |
239 | - grip_dot_down = bg_dark_line; |
240 | - grip_dot_down.alpha = 0.86; |
241 | - grip_inset_up = bg_bright_line; |
242 | - grip_inset_up.alpha = priv->event & OS_EVENT_BUTTON_PRESS ? 0.62 : 1.0; |
243 | - grip_inset_down = bg_bright_line; |
244 | - grip_inset_down.alpha = 0.36; |
245 | + pattern_add_gdk_rgba_stop (pat, 0.0, &bg_dark_line, 0.0); |
246 | + pattern_add_gdk_rgba_stop (pat, 0.49, &bg_dark_line, 0.36); |
247 | + pattern_add_gdk_rgba_stop (pat, 0.49, &bg_dark_line, 0.36); |
248 | + pattern_add_gdk_rgba_stop (pat, 1.0, &bg_dark_line, 0.0); |
249 | + cairo_set_source (cr, pat); |
250 | + cairo_pattern_destroy (pat); |
251 | |
252 | /* Grip. */ |
253 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
254 | { |
255 | /* Page UP. */ |
256 | - draw_grip (cr, &grip_dot_up, &grip_inset_up, 4.5, 15.5, 3, 5); |
257 | + draw_grip (cr, width / 2 - 6.5, 13.5, 5, 6); |
258 | |
259 | /* Page DOWN. */ |
260 | - draw_grip (cr, &grip_dot_down, &grip_inset_down, 4.5, height / 2 + 4.5, 3, 5); |
261 | + draw_grip (cr, width / 2 - 6.5, height / 2 + 3.5, 5, 6); |
262 | } |
263 | else |
264 | { |
265 | /* Page UP. */ |
266 | - draw_grip (cr, &grip_dot_up, &grip_inset_up, 15.5, 4.5, 5, 3); |
267 | + draw_grip (cr, 16.5, height / 2 - 6.5, 5, 6); |
268 | |
269 | /* Page DOWN. */ |
270 | - draw_grip (cr, &grip_dot_down, &grip_inset_down, width / 2 + 4.5, 4.5, 5, 3); |
271 | + draw_grip (cr, width / 2 + 3.5, height / 2 - 6.5, 5, 6); |
272 | } |
273 | + |
274 | + cairo_fill (cr); |
275 | } |
276 | |
277 | /* Separators between the two steppers. */ |
278 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
279 | { |
280 | - cairo_move_to (cr, 2.5, height / 2); |
281 | - cairo_line_to (cr, width - 2.5, height / 2); |
282 | + cairo_move_to (cr, 1.5, height / 2); |
283 | + cairo_line_to (cr, width - 1.5, height / 2); |
284 | set_source_gdk_rgba (cr, &bg_dark_line, 0.36); |
285 | cairo_stroke (cr); |
286 | |
287 | - cairo_move_to (cr, 2.5, 1 + height / 2); |
288 | - cairo_line_to (cr, width - 2.5, 1 + height / 2); |
289 | + cairo_move_to (cr, 1.5, 1 + height / 2); |
290 | + cairo_line_to (cr, width - 1.5, 1 + height / 2); |
291 | set_source_gdk_rgba (cr, &bg_bright_line, 0.5); |
292 | cairo_stroke (cr); |
293 | } |
294 | else |
295 | { |
296 | - cairo_move_to (cr, width / 2, 2.5); |
297 | - cairo_line_to (cr, width / 2, height - 2.5); |
298 | + cairo_move_to (cr, width / 2, 1.5); |
299 | + cairo_line_to (cr, width / 2, height - 1.5); |
300 | set_source_gdk_rgba (cr, &bg_dark_line, 0.36); |
301 | cairo_stroke (cr); |
302 | |
303 | - cairo_move_to (cr, 1 + width / 2, 2.5); |
304 | - cairo_line_to (cr, 1 + width / 2, height - 2.5); |
305 | + cairo_move_to (cr, 1 + width / 2, 1.5); |
306 | + cairo_line_to (cr, 1 + width / 2, height - 1.5); |
307 | set_source_gdk_rgba (cr, &bg_bright_line, 0.5); |
308 | cairo_stroke (cr); |
309 | } |
310 | @@ -851,14 +895,14 @@ |
311 | { |
312 | /* Direction UP. */ |
313 | cairo_save (cr); |
314 | - cairo_translate (cr, 8.5, 8.5); |
315 | + cairo_translate (cr, width / 2 + 0.5, 8.5); |
316 | cairo_rotate (cr, G_PI); |
317 | draw_arrow (cr, &arrow_color, 0.5, 0, 5, 3); |
318 | cairo_restore (cr); |
319 | |
320 | /* Direction DOWN. */ |
321 | cairo_save (cr); |
322 | - cairo_translate (cr, 8.5, height - 8.5); |
323 | + cairo_translate (cr, width / 2 + 0.5, height - 8.5); |
324 | cairo_rotate (cr, 0); |
325 | draw_arrow (cr, &arrow_color, -0.5, 0, 5, 3); |
326 | cairo_restore (cr); |
327 | @@ -867,14 +911,14 @@ |
328 | { |
329 | /* Direction LEFT. */ |
330 | cairo_save (cr); |
331 | - cairo_translate (cr, 8.5, 8.5); |
332 | + cairo_translate (cr, 8.5, height / 2 + 0.5); |
333 | cairo_rotate (cr, G_PI * 0.5); |
334 | draw_arrow (cr, &arrow_color, -0.5, 0, 5, 3); |
335 | cairo_restore (cr); |
336 | |
337 | /* Direction RIGHT. */ |
338 | cairo_save (cr); |
339 | - cairo_translate (cr, width - 8.5, 8.5); |
340 | + cairo_translate (cr, width - 8.5, height / 2 + 0.5); |
341 | cairo_rotate (cr, G_PI * 1.5); |
342 | draw_arrow (cr, &arrow_color, 0.5, 0, 5, 3); |
343 | cairo_restore (cr); |
Changes look good to me, mostly changes in rendering besides the new action enumeration/ variable. I don't see anything risky or wrong here. Approved.