Merge lp:~cimi/overlay-scrollbar/fitt-law into lp:overlay-scrollbar
- fitt-law
- Merge into trunk
Proposed by
Andrea Cimitan
Status: | Merged |
---|---|
Merged at revision: | 230 |
Proposed branch: | lp:~cimi/overlay-scrollbar/fitt-law |
Merge into: | lp:overlay-scrollbar |
Diff against target: |
461 lines (+196/-116) 3 files modified
os/os-private.h (+8/-5) os/os-scrollbar.c (+38/-4) os/os-thumb.c (+150/-107) |
To merge this branch: | bzr merge lp:~cimi/overlay-scrollbar/fitt-law |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ted Gould (community) | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
- 231. By Andrea Cimitan
-
Don't check for detached state on drag. Indentation fixes
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-04-05 16:21:15 +0000 | |||
3 | +++ os/os-private.h 2011-05-08 14:08:31 +0000 | |||
4 | @@ -31,8 +31,8 @@ | |||
5 | 31 | #endif /* __GNUC__ */ | 31 | #endif /* __GNUC__ */ |
6 | 32 | 32 | ||
7 | 33 | /* Default size of the thumb in pixels. */ | 33 | /* Default size of the thumb in pixels. */ |
10 | 34 | #define DEFAULT_THUMB_WIDTH 15 | 34 | #define DEFAULT_THUMB_WIDTH 17 |
11 | 35 | #define DEFAULT_THUMB_HEIGHT 67 | 35 | #define DEFAULT_THUMB_HEIGHT 69 |
12 | 36 | 36 | ||
13 | 37 | G_BEGIN_DECLS | 37 | G_BEGIN_DECLS |
14 | 38 | 38 | ||
15 | @@ -167,9 +167,12 @@ | |||
16 | 167 | GtkWindowClass parent_class; | 167 | GtkWindowClass parent_class; |
17 | 168 | }; | 168 | }; |
18 | 169 | 169 | ||
22 | 170 | GType os_thumb_get_type (void) G_GNUC_CONST; | 170 | GType os_thumb_get_type (void) G_GNUC_CONST; |
23 | 171 | 171 | ||
24 | 172 | GtkWidget* os_thumb_new (GtkOrientation orientation); | 172 | GtkWidget* os_thumb_new (GtkOrientation orientation); |
25 | 173 | |||
26 | 174 | void os_thumb_set_detached (OsThumb *thumb, | ||
27 | 175 | gboolean detached); | ||
28 | 173 | 176 | ||
29 | 174 | /* os-pager.c */ | 177 | /* os-pager.c */ |
30 | 175 | 178 | ||
31 | 176 | 179 | ||
32 | === modified file 'os/os-scrollbar.c' | |||
33 | --- os/os-scrollbar.c 2011-04-26 22:33:59 +0000 | |||
34 | +++ os/os-scrollbar.c 2011-05-08 14:08:31 +0000 | |||
35 | @@ -32,6 +32,9 @@ | |||
36 | 32 | /* Default size of the pager in pixels. */ | 32 | /* Default size of the pager in pixels. */ |
37 | 33 | #define DEFAULT_PAGER_WIDTH 3 | 33 | #define DEFAULT_PAGER_WIDTH 3 |
38 | 34 | 34 | ||
39 | 35 | /* Default thumb allocation shift in pixels. */ | ||
40 | 36 | #define THUMB_ALLOCATION_SHIFT -3 | ||
41 | 37 | |||
42 | 35 | /* Width of the proximity effect in pixels. */ | 38 | /* Width of the proximity effect in pixels. */ |
43 | 36 | #define PROXIMITY_WIDTH 30 | 39 | #define PROXIMITY_WIDTH 30 |
44 | 37 | 40 | ||
45 | @@ -539,7 +542,7 @@ | |||
46 | 539 | (x - 1 + priv->slider.width) >= screen_width)) | 542 | (x - 1 + priv->slider.width) >= screen_width)) |
47 | 540 | { | 543 | { |
48 | 541 | priv->internal = TRUE; | 544 | priv->internal = TRUE; |
50 | 542 | return x - DEFAULT_PAGER_WIDTH - priv->slider.width; | 545 | return MAX (x - priv->slider.width, screen_width - priv->slider.width); |
51 | 543 | } | 546 | } |
52 | 544 | 547 | ||
53 | 545 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 548 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
54 | @@ -573,7 +576,7 @@ | |||
55 | 573 | (y - 1 + priv->slider.height) >= screen_height)) | 576 | (y - 1 + priv->slider.height) >= screen_height)) |
56 | 574 | { | 577 | { |
57 | 575 | priv->internal = TRUE; | 578 | priv->internal = TRUE; |
59 | 576 | return y - DEFAULT_PAGER_WIDTH - priv->slider.height; | 579 | return MAX (y - priv->slider.height, screen_height - priv->slider.height); |
60 | 577 | } | 580 | } |
61 | 578 | 581 | ||
62 | 579 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) | 582 | if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) |
63 | @@ -1162,6 +1165,35 @@ | |||
64 | 1162 | if (!priv->motion_notify_event && !priv->enter_notify_event) | 1165 | if (!priv->motion_notify_event && !priv->enter_notify_event) |
65 | 1163 | gtk_widget_hide (GTK_WIDGET (priv->thumb)); | 1166 | gtk_widget_hide (GTK_WIDGET (priv->thumb)); |
66 | 1164 | 1167 | ||
67 | 1168 | if (gtk_widget_get_mapped (GTK_WIDGET (priv->thumb))) | ||
68 | 1169 | { | ||
69 | 1170 | /* if we're dragging the thumb, it can't be detached. */ | ||
70 | 1171 | if (priv->motion_notify_event) | ||
71 | 1172 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
72 | 1173 | else | ||
73 | 1174 | { | ||
74 | 1175 | gint x_pos, y_pos; | ||
75 | 1176 | gdk_window_get_origin (gtk_widget_get_window (GTK_WIDGET (priv->thumb)), &x_pos, &y_pos); | ||
76 | 1177 | |||
77 | 1178 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | ||
78 | 1179 | { | ||
79 | 1180 | if ((priv->win_y + priv->overlay.y > y_pos + priv->slider.height) || | ||
80 | 1181 | (priv->win_y + priv->overlay.y + priv->overlay.height < y_pos)) | ||
81 | 1182 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
82 | 1183 | else | ||
83 | 1184 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
84 | 1185 | } | ||
85 | 1186 | else | ||
86 | 1187 | { | ||
87 | 1188 | if ((priv->win_x + priv->overlay.x > x_pos + priv->slider.width) || | ||
88 | 1189 | (priv->win_x + priv->overlay.x + priv->overlay.width < x_pos)) | ||
89 | 1190 | os_thumb_set_detached (OS_THUMB (priv->thumb), TRUE); | ||
90 | 1191 | else | ||
91 | 1192 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
92 | 1193 | } | ||
93 | 1194 | } | ||
94 | 1195 | } | ||
95 | 1196 | |||
96 | 1165 | pager_move (scrollbar); | 1197 | pager_move (scrollbar); |
97 | 1166 | } | 1198 | } |
98 | 1167 | 1199 | ||
99 | @@ -1399,6 +1431,7 @@ | |||
100 | 1399 | os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); | 1431 | os_scrollbar_move_thumb (scrollbar, priv->win_x, priv->win_y + priv->slider.y); |
101 | 1400 | } | 1432 | } |
102 | 1401 | 1433 | ||
103 | 1434 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
104 | 1402 | gtk_widget_show (GTK_WIDGET (priv->thumb)); | 1435 | gtk_widget_show (GTK_WIDGET (priv->thumb)); |
105 | 1403 | } | 1436 | } |
106 | 1404 | else | 1437 | else |
107 | @@ -1438,6 +1471,7 @@ | |||
108 | 1438 | os_scrollbar_move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y); | 1471 | os_scrollbar_move_thumb (scrollbar, priv->win_x + priv->slider.x, priv->win_y); |
109 | 1439 | } | 1472 | } |
110 | 1440 | 1473 | ||
111 | 1474 | os_thumb_set_detached (OS_THUMB (priv->thumb), FALSE); | ||
112 | 1441 | gtk_widget_show (GTK_WIDGET (priv->thumb)); | 1475 | gtk_widget_show (GTK_WIDGET (priv->thumb)); |
113 | 1442 | } | 1476 | } |
114 | 1443 | else | 1477 | else |
115 | @@ -1771,7 +1805,7 @@ | |||
116 | 1771 | priv->slider.width = DEFAULT_THUMB_WIDTH; | 1805 | priv->slider.width = DEFAULT_THUMB_WIDTH; |
117 | 1772 | priv->slider.height = DEFAULT_THUMB_HEIGHT; | 1806 | priv->slider.height = DEFAULT_THUMB_HEIGHT; |
118 | 1773 | priv->overlay_all.x = allocation->x - DEFAULT_PAGER_WIDTH; | 1807 | priv->overlay_all.x = allocation->x - DEFAULT_PAGER_WIDTH; |
120 | 1774 | priv->thumb_all.x = allocation->x; | 1808 | priv->thumb_all.x = allocation->x + THUMB_ALLOCATION_SHIFT; |
121 | 1775 | 1809 | ||
122 | 1776 | rect.x = priv->overlay_all.x; | 1810 | rect.x = priv->overlay_all.x; |
123 | 1777 | rect.y = priv->overlay_all.y; | 1811 | rect.y = priv->overlay_all.y; |
124 | @@ -1785,7 +1819,7 @@ | |||
125 | 1785 | priv->slider.width = DEFAULT_THUMB_HEIGHT; | 1819 | priv->slider.width = DEFAULT_THUMB_HEIGHT; |
126 | 1786 | priv->slider.height = DEFAULT_THUMB_WIDTH; | 1820 | priv->slider.height = DEFAULT_THUMB_WIDTH; |
127 | 1787 | priv->overlay_all.y = allocation->y - DEFAULT_PAGER_WIDTH ; | 1821 | priv->overlay_all.y = allocation->y - DEFAULT_PAGER_WIDTH ; |
129 | 1788 | priv->thumb_all.y = allocation->y; | 1822 | priv->thumb_all.y = allocation->y + THUMB_ALLOCATION_SHIFT; |
130 | 1789 | 1823 | ||
131 | 1790 | rect.x = priv->overlay_all.x; | 1824 | rect.x = priv->overlay_all.x; |
132 | 1791 | rect.y = priv->overlay_all.y; | 1825 | rect.y = priv->overlay_all.y; |
133 | 1792 | 1826 | ||
134 | === modified file 'os/os-thumb.c' | |||
135 | --- os/os-thumb.c 2011-04-20 14:51:48 +0000 | |||
136 | +++ os/os-thumb.c 2011-05-08 14:08:31 +0000 | |||
137 | @@ -40,6 +40,9 @@ | |||
138 | 40 | /* Number of tolerance pixels. */ | 40 | /* Number of tolerance pixels. */ |
139 | 41 | #define TOLERANCE_PIXELS 3 | 41 | #define TOLERANCE_PIXELS 3 |
140 | 42 | 42 | ||
141 | 43 | /* Thumb radius in pixels (higher values are automatically clamped). */ | ||
142 | 44 | #define THUMB_RADIUS 9 | ||
143 | 45 | |||
144 | 43 | struct _OsThumbPrivate { | 46 | struct _OsThumbPrivate { |
145 | 44 | GtkOrientation orientation; | 47 | GtkOrientation orientation; |
146 | 45 | GtkWidget *grabbed_widget; | 48 | GtkWidget *grabbed_widget; |
147 | @@ -48,6 +51,7 @@ | |||
148 | 48 | gboolean motion_notify_event; | 51 | gboolean motion_notify_event; |
149 | 49 | gboolean can_rgba; | 52 | gboolean can_rgba; |
150 | 50 | gboolean use_tolerance; | 53 | gboolean use_tolerance; |
151 | 54 | gboolean detached; | ||
152 | 51 | gint pointer_x; | 55 | gint pointer_x; |
153 | 52 | gint pointer_y; | 56 | gint pointer_y; |
154 | 53 | guint32 source_id; | 57 | guint32 source_id; |
155 | @@ -79,6 +83,31 @@ | |||
156 | 79 | 83 | ||
157 | 80 | /* Private functions. */ | 84 | /* Private functions. */ |
158 | 81 | 85 | ||
159 | 86 | /* Draw an arror. */ | ||
160 | 87 | static void | ||
161 | 88 | os_cairo_draw_arrow (cairo_t *cr, | ||
162 | 89 | gdouble x, | ||
163 | 90 | gdouble y, | ||
164 | 91 | gdouble width, | ||
165 | 92 | gdouble height) | ||
166 | 93 | { | ||
167 | 94 | cairo_save (cr); | ||
168 | 95 | |||
169 | 96 | cairo_translate (cr, x, y); | ||
170 | 97 | cairo_move_to (cr, -width / 2, -height / 2); | ||
171 | 98 | cairo_line_to (cr, 0, height / 2); | ||
172 | 99 | cairo_line_to (cr, width / 2, -height / 2); | ||
173 | 100 | cairo_close_path (cr); | ||
174 | 101 | |||
175 | 102 | cairo_set_source_rgba (cr, 0.3, 0.3, 0.3, 0.75); | ||
176 | 103 | cairo_fill_preserve (cr); | ||
177 | 104 | |||
178 | 105 | cairo_set_source_rgba (cr, 0.3, 0.3, 0.3, 1.0); | ||
179 | 106 | cairo_stroke (cr); | ||
180 | 107 | |||
181 | 108 | cairo_restore (cr); | ||
182 | 109 | } | ||
183 | 110 | |||
184 | 82 | /* Draw a rounded rectangle. */ | 111 | /* Draw a rounded rectangle. */ |
185 | 83 | static void | 112 | static void |
186 | 84 | os_cairo_draw_rounded_rect (cairo_t *cr, | 113 | os_cairo_draw_rounded_rect (cairo_t *cr, |
187 | @@ -189,6 +218,7 @@ | |||
188 | 189 | priv = thumb->priv; | 218 | priv = thumb->priv; |
189 | 190 | 219 | ||
190 | 191 | priv->can_rgba = FALSE; | 220 | priv->can_rgba = FALSE; |
191 | 221 | priv->detached = FALSE; | ||
192 | 192 | 222 | ||
193 | 193 | priv->source_id = 0; | 223 | priv->source_id = 0; |
194 | 194 | priv->animation = os_animation_new (RATE_FADE_OUT, DURATION_FADE_OUT, | 224 | priv->animation = os_animation_new (RATE_FADE_OUT, DURATION_FADE_OUT, |
195 | @@ -350,6 +380,7 @@ | |||
196 | 350 | { | 380 | { |
197 | 351 | GtkAllocation allocation; | 381 | GtkAllocation allocation; |
198 | 352 | GtkStateType state_type_down, state_type_up; | 382 | GtkStateType state_type_down, state_type_up; |
199 | 383 | GtkStyle *style; | ||
200 | 353 | OsThumb *thumb; | 384 | OsThumb *thumb; |
201 | 354 | OsThumbPrivate *priv; | 385 | OsThumbPrivate *priv; |
202 | 355 | cairo_pattern_t *pat; | 386 | cairo_pattern_t *pat; |
203 | @@ -357,6 +388,8 @@ | |||
204 | 357 | gint x, y, width, height; | 388 | gint x, y, width, height; |
205 | 358 | gint radius; | 389 | gint radius; |
206 | 359 | 390 | ||
207 | 391 | style = gtk_widget_get_style (widget); | ||
208 | 392 | |||
209 | 360 | thumb = OS_THUMB (widget); | 393 | thumb = OS_THUMB (widget); |
210 | 361 | priv = thumb->priv; | 394 | priv = thumb->priv; |
211 | 362 | 395 | ||
212 | @@ -369,10 +402,12 @@ | |||
213 | 369 | y = 0; | 402 | y = 0; |
214 | 370 | width = allocation.width; | 403 | width = allocation.width; |
215 | 371 | height = allocation.height; | 404 | height = allocation.height; |
217 | 372 | radius = priv->can_rgba ? 18 : 0; | 405 | radius = priv->can_rgba ? THUMB_RADIUS : 0; |
218 | 373 | 406 | ||
219 | 374 | cr = gdk_cairo_create (gtk_widget_get_window (widget)); | 407 | cr = gdk_cairo_create (gtk_widget_get_window (widget)); |
220 | 375 | 408 | ||
221 | 409 | cairo_save (cr); | ||
222 | 410 | |||
223 | 376 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); | 411 | cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); |
224 | 377 | cairo_set_source_rgba (cr, 0, 0, 0, 0); | 412 | cairo_set_source_rgba (cr, 0, 0, 0, 0); |
225 | 378 | cairo_paint (cr); | 413 | cairo_paint (cr); |
226 | @@ -434,117 +469,101 @@ | |||
227 | 434 | } | 469 | } |
228 | 435 | cairo_set_source (cr, pat); | 470 | cairo_set_source (cr, pat); |
229 | 436 | cairo_pattern_destroy (pat); | 471 | cairo_pattern_destroy (pat); |
230 | 437 | cairo_fill_preserve (cr); | ||
231 | 438 | 472 | ||
232 | 439 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 1.0); | ||
233 | 440 | 473 | ||
234 | 441 | if (priv->motion_notify_event) | 474 | if (priv->motion_notify_event) |
235 | 442 | { | 475 | { |
236 | 476 | cairo_fill_preserve (cr); | ||
237 | 443 | cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.2); | 477 | cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.2); |
342 | 444 | cairo_fill_preserve (cr); | 478 | cairo_fill (cr); |
343 | 445 | cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 1.0); | 479 | } |
344 | 446 | cairo_stroke (cr); | 480 | else |
345 | 447 | 481 | cairo_fill (cr); | |
346 | 448 | os_cairo_draw_rounded_rect (cr, x + 1, y + 1, width - 2, height - 2, radius + 1); | 482 | |
347 | 449 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); | 483 | cairo_set_line_width (cr, 2.0); |
348 | 450 | cairo_stroke (cr); | 484 | os_cairo_draw_rounded_rect (cr, x + 0.5, y + 0.5, width - 1, height - 1, radius - 1); |
349 | 451 | } | 485 | if (!priv->detached) |
350 | 452 | else | 486 | cairo_set_source_rgba (cr, style->bg[GTK_STATE_SELECTED].red/65535.0, |
351 | 453 | { | 487 | style->bg[GTK_STATE_SELECTED].green/65535.0, |
352 | 454 | cairo_stroke (cr); | 488 | style->bg[GTK_STATE_SELECTED].blue/65535.0, 1.0f); |
353 | 455 | 489 | else | |
354 | 456 | os_cairo_draw_rounded_rect (cr, x + 1, y + 1, width - 2, height - 2, radius + 1); | 490 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 1.0f); |
355 | 457 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); | 491 | cairo_stroke (cr); |
356 | 458 | cairo_stroke (cr); | 492 | |
357 | 459 | } | 493 | cairo_set_line_width (cr, 1.0); |
358 | 460 | 494 | os_cairo_draw_rounded_rect (cr, x + 1, y + 1, width - 2, height - 2, radius - 1); | |
359 | 461 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 495 | cairo_set_source_rgba (cr, 0.1, 0.1, 0.1, 0.1); |
360 | 462 | { | 496 | cairo_stroke (cr); |
361 | 463 | cairo_move_to (cr, x + 0.5, y - 1 + height / 2); | 497 | |
362 | 464 | cairo_line_to (cr, width - 0.5, y - 1 + height / 2); | 498 | os_cairo_draw_rounded_rect (cr, x + 2, y + 2, width - 4, height - 4, radius - 3); |
363 | 465 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 0.4); | 499 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 0.5); |
364 | 466 | cairo_stroke (cr); | 500 | cairo_stroke (cr); |
365 | 467 | 501 | ||
366 | 468 | cairo_move_to (cr, x + 0.5, y + height / 2); | 502 | os_cairo_draw_rounded_rect (cr, x + 3, y + 3, width - 6, height - 6, radius - 4); |
367 | 469 | cairo_line_to (cr, width - 0.5, y + height / 2); | 503 | cairo_set_source_rgba (cr, 1, 1, 1, 0.2); |
368 | 470 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); | 504 | cairo_stroke (cr); |
369 | 471 | cairo_stroke (cr); | 505 | |
370 | 472 | } | 506 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
371 | 473 | else | 507 | { |
372 | 474 | { | 508 | cairo_move_to (cr, x + 2.5, y - 1 + height / 2); |
373 | 475 | cairo_move_to (cr, x - 1 + width / 2, y + 0.5); | 509 | cairo_line_to (cr, width - 2.5, y - 1 + height / 2); |
374 | 476 | cairo_line_to (cr, x - 1 + width / 2, height - 0.5); | 510 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 0.4); |
375 | 477 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 0.4); | 511 | cairo_stroke (cr); |
376 | 478 | cairo_stroke (cr); | 512 | |
377 | 479 | 513 | cairo_move_to (cr, x + 2.5, y + height / 2); | |
378 | 480 | cairo_move_to (cr, x + width / 2, y + 0.5); | 514 | cairo_line_to (cr, width - 2.5, y + height / 2); |
379 | 481 | cairo_line_to (cr, x + width / 2, height - 0.5); | 515 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); |
380 | 482 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); | 516 | cairo_stroke (cr); |
381 | 483 | cairo_stroke (cr); | 517 | } |
382 | 484 | } | 518 | else |
383 | 485 | 519 | { | |
384 | 486 | cairo_restore (cr); | 520 | cairo_move_to (cr, x - 1 + width / 2, y + 2.5); |
385 | 487 | 521 | cairo_line_to (cr, x - 1 + width / 2, height - 2.5); | |
386 | 488 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) | 522 | cairo_set_source_rgba (cr, 0.6, 0.6, 0.6, 0.4); |
387 | 489 | { | 523 | cairo_stroke (cr); |
388 | 490 | gtk_paint_arrow (gtk_widget_get_style (widget), | 524 | |
389 | 491 | gtk_widget_get_window (widget), | 525 | cairo_move_to (cr, x + width / 2, y + 2.5); |
390 | 492 | state_type_up, | 526 | cairo_line_to (cr, x + width / 2, height - 2.5); |
391 | 493 | GTK_SHADOW_IN, | 527 | cairo_set_source_rgba (cr, 1, 1, 1, 0.5); |
392 | 494 | NULL, | 528 | cairo_stroke (cr); |
393 | 495 | widget, | 529 | } |
394 | 496 | "arrow", | 530 | |
395 | 497 | GTK_ARROW_UP, | 531 | if (priv->orientation == GTK_ORIENTATION_VERTICAL) |
396 | 498 | FALSE, | 532 | { |
397 | 499 | 4, | 533 | /* direction UP. */ |
398 | 500 | 4, | 534 | cairo_save (cr); |
399 | 501 | width - 8, | 535 | cairo_translate (cr, 8.5, 8.5); |
400 | 502 | width - 8); | 536 | cairo_rotate (cr, G_PI); |
401 | 503 | 537 | os_cairo_draw_arrow (cr, 0.5, 0, 4, 3); | |
402 | 504 | gtk_paint_arrow (gtk_widget_get_style (widget), | 538 | cairo_restore (cr); |
403 | 505 | gtk_widget_get_window (widget), | 539 | |
404 | 506 | state_type_down, | 540 | /* direction DOWN. */ |
405 | 507 | GTK_SHADOW_NONE, | 541 | cairo_save (cr); |
406 | 508 | NULL, | 542 | cairo_translate (cr, 8.5, height - 8.5); |
407 | 509 | widget, | 543 | cairo_rotate (cr, 0); |
408 | 510 | "arrow", | 544 | os_cairo_draw_arrow (cr, -0.5, 0, 4, 3); |
409 | 511 | GTK_ARROW_DOWN, | 545 | cairo_restore (cr); |
410 | 512 | FALSE, | 546 | } |
411 | 513 | 4, | 547 | else |
412 | 514 | height - (width - 8) - 4, | 548 | { |
413 | 515 | width - 8, | 549 | /* direction LEFT. */ |
414 | 516 | width - 8); | 550 | cairo_save (cr); |
415 | 517 | } | 551 | cairo_translate (cr, 8.5, 8.5); |
416 | 518 | else | 552 | cairo_rotate (cr, G_PI * 0.5); |
417 | 519 | { | 553 | os_cairo_draw_arrow (cr, -0.5, 0, 4, 3); |
418 | 520 | gtk_paint_arrow (gtk_widget_get_style (widget), | 554 | cairo_restore (cr); |
419 | 521 | gtk_widget_get_window (widget), | 555 | |
420 | 522 | state_type_up, | 556 | /* direction RIGHT. */ |
421 | 523 | GTK_SHADOW_IN, | 557 | cairo_save (cr); |
422 | 524 | NULL, | 558 | cairo_translate (cr, width - 8.5, 8.5); |
423 | 525 | widget, | 559 | cairo_rotate (cr, G_PI * 1.5); |
424 | 526 | "arrow", | 560 | os_cairo_draw_arrow (cr, 0.5, 0, 4, 3); |
425 | 527 | GTK_ARROW_LEFT, | 561 | cairo_restore (cr); |
426 | 528 | FALSE, | 562 | } |
427 | 529 | 4, | 563 | |
428 | 530 | 4, | 564 | cairo_restore (cr); |
429 | 531 | height - 8, | 565 | |
430 | 532 | height - 8); | 566 | cairo_restore (cr); |
327 | 533 | |||
328 | 534 | gtk_paint_arrow (gtk_widget_get_style (widget), | ||
329 | 535 | gtk_widget_get_window (widget), | ||
330 | 536 | state_type_down, | ||
331 | 537 | GTK_SHADOW_NONE, | ||
332 | 538 | NULL, | ||
333 | 539 | widget, | ||
334 | 540 | "arrow", | ||
335 | 541 | GTK_ARROW_RIGHT, | ||
336 | 542 | FALSE, | ||
337 | 543 | width - (height - 8) - 4, | ||
338 | 544 | 4, | ||
339 | 545 | height - 8, | ||
340 | 546 | height - 8); | ||
341 | 547 | } | ||
431 | 548 | 567 | ||
432 | 549 | cairo_destroy (cr); | 568 | cairo_destroy (cr); |
433 | 550 | 569 | ||
434 | @@ -802,3 +821,27 @@ | |||
435 | 802 | { | 821 | { |
436 | 803 | return g_object_new (OS_TYPE_THUMB, "orientation", orientation, NULL); | 822 | return g_object_new (OS_TYPE_THUMB, "orientation", orientation, NULL); |
437 | 804 | } | 823 | } |
438 | 824 | |||
439 | 825 | /** | ||
440 | 826 | * os_thumb_set_detached: | ||
441 | 827 | * @thumb: a #OsThumb | ||
442 | 828 | * @detached: a gboolean | ||
443 | 829 | * | ||
444 | 830 | * Sets the thumb to be detached. | ||
445 | 831 | **/ | ||
446 | 832 | void | ||
447 | 833 | os_thumb_set_detached (OsThumb *thumb, | ||
448 | 834 | gboolean detached) | ||
449 | 835 | { | ||
450 | 836 | OsThumbPrivate *priv; | ||
451 | 837 | |||
452 | 838 | g_return_if_fail (OS_THUMB (thumb)); | ||
453 | 839 | |||
454 | 840 | priv = thumb->priv; | ||
455 | 841 | |||
456 | 842 | if (priv->detached != detached) | ||
457 | 843 | { | ||
458 | 844 | priv->detached = detached; | ||
459 | 845 | gtk_widget_queue_draw (GTK_WIDGET (thumb)); | ||
460 | 846 | } | ||
461 | 847 | } |
Love the video!
review approve