Merge lp:~eyelash/granite/fix-931249 into lp:~elementary-pantheon/granite/granite

Proposed by eyelash
Status: Merged
Merged at revision: 264
Proposed branch: lp:~eyelash/granite/fix-931249
Merge into: lp:~elementary-pantheon/granite/granite
Diff against target: 71 lines (+14/-12)
1 file modified
lib/Widgets/PopOver.vala (+14/-12)
To merge this branch: bzr merge lp:~eyelash/granite/fix-931249
Reviewer Review Type Date Requested Status
Cody Garver (community) Approve
Review via email: mp+109581@code.launchpad.net

Description of the change

I wanted to make sure different border-widths and border-radii were actually supported so I propose to merge the last few commits as well.

To post a comment you must log in.
Revision history for this message
Cody Garver (codygarver) wrote :

Hey man, great work. Send me your email address so I can give you proper credit when I commit this. https://launchpad.net/~codygarver/+contactuser

Revision history for this message
Cody Garver (codygarver) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/Widgets/PopOver.vala'
2--- lib/Widgets/PopOver.vala 2012-05-28 13:36:39 +0000
3+++ lib/Widgets/PopOver.vala 2012-06-11 08:55:26 +0000
4@@ -358,30 +358,32 @@
5 move(x, y);
6 }
7
8- protected void cairo_popover (Cairo.Context cr, double x, double y, double width, double height) {
9+ protected void cairo_popover (Cairo.Context cr, double x, double y, double width, double height, double border_radius) {
10+
11+ if (border_radius < 0.0) border_radius = 0.0;
12
13 // The top half
14 if (arrow_up) {
15- cr.arc (x + BORDER_RADIUS, y + ARROW_HEIGHT + BORDER_RADIUS, BORDER_RADIUS, Math.PI, Math.PI * 1.5);
16+ cr.arc (x + border_radius, y + ARROW_HEIGHT + border_radius, border_radius, Math.PI, Math.PI * 1.5);
17 cr.line_to (arrow_offset, y + ARROW_HEIGHT);
18 cr.rel_line_to (ARROW_WIDTH / 2.0, -ARROW_HEIGHT);
19 cr.rel_line_to (ARROW_WIDTH / 2.0, ARROW_HEIGHT);
20- cr.arc (x + width - BORDER_RADIUS, y + ARROW_HEIGHT + BORDER_RADIUS, BORDER_RADIUS, Math.PI * 1.5, Math.PI * 2.0);
21+ cr.arc (x + width - border_radius, y + ARROW_HEIGHT + border_radius, border_radius, Math.PI * 1.5, Math.PI * 2.0);
22 } else {
23- cr.arc (x + BORDER_RADIUS, y + BORDER_RADIUS, BORDER_RADIUS, Math.PI, Math.PI * 1.5);
24- cr.arc (x + width - BORDER_RADIUS, y + BORDER_RADIUS, BORDER_RADIUS, Math.PI * 1.5, Math.PI * 2.0);
25+ cr.arc (x + border_radius, y + border_radius, border_radius, Math.PI, Math.PI * 1.5);
26+ cr.arc (x + width - border_radius, y + border_radius, border_radius, Math.PI * 1.5, Math.PI * 2.0);
27 }
28
29 // The bottom half
30 if (arrow_up) {
31- cr.arc (x + width - BORDER_RADIUS, y + height - BORDER_RADIUS, BORDER_RADIUS, 0, Math.PI * 0.5);
32- cr.arc (x + BORDER_RADIUS, y + height - BORDER_RADIUS, BORDER_RADIUS, Math.PI * 0.5, Math.PI);
33+ cr.arc (x + width - border_radius, y + height - border_radius, border_radius, 0, Math.PI * 0.5);
34+ cr.arc (x + border_radius, y + height - border_radius, border_radius, Math.PI * 0.5, Math.PI);
35 } else {
36- cr.arc (x + width - BORDER_RADIUS, y + height - ARROW_HEIGHT - BORDER_RADIUS, BORDER_RADIUS, 0, Math.PI * 0.5);
37+ cr.arc (x + width - border_radius, y + height - ARROW_HEIGHT - border_radius, border_radius, 0, Math.PI * 0.5);
38 cr.line_to (arrow_offset + ARROW_WIDTH, y + height - ARROW_HEIGHT);
39 cr.rel_line_to (-ARROW_WIDTH / 2.0, ARROW_HEIGHT);
40 cr.rel_line_to (-ARROW_WIDTH / 2.0, -ARROW_HEIGHT);
41- cr.arc (x + BORDER_RADIUS, y + height - ARROW_HEIGHT - BORDER_RADIUS, BORDER_RADIUS, Math.PI * 0.5, Math.PI);
42+ cr.arc (x + border_radius, y + height - ARROW_HEIGHT - border_radius, border_radius, Math.PI * 0.5, Math.PI);
43 }
44 cr.close_path ();
45 }
46@@ -397,14 +399,14 @@
47
48 // Shadow first
49 cairo_popover (main_buffer.context, SHADOW_SIZE, SHADOW_SIZE,
50- w - SHADOW_SIZE * 2, h - SHADOW_SIZE * 2);
51+ w - SHADOW_SIZE * 2, h - SHADOW_SIZE * 2, BORDER_RADIUS);
52 main_buffer.context.set_source_rgba (0.0, 0.0, 0.0, 0.4);
53 main_buffer.context.fill_preserve ();
54 main_buffer.exponential_blur (SHADOW_SIZE / 2 - 1); // rough approximation
55
56 // Background
57 main_buffer.context.clip ();
58- Gtk.render_background (menu.get_style_context (), main_buffer.context, SHADOW_SIZE, SHADOW_SIZE, w - 2 * SHADOW_SIZE, h - 2 * SHADOW_SIZE);
59+ Gtk.render_background (menu.get_style_context (), main_buffer.context, 0, 0, w, h);
60 if(is_composited) {
61 if(get_window () != null)
62 get_window ().input_shape_combine_region (new Cairo.Region.rectangle({0, 0, w - 2*(PADDINGS.right + SHADOW_SIZE), h - 2*(PADDINGS.top + SHADOW_SIZE) - ARROW_HEIGHT}),
63@@ -415,7 +417,7 @@
64 // Outer border
65 main_buffer.context.reset_clip ();
66 cairo_popover (main_buffer.context, SHADOW_SIZE + BORDER_WIDTH / 2.0, SHADOW_SIZE + BORDER_WIDTH / 2.0,
67- w - SHADOW_SIZE * 2 - BORDER_WIDTH, h - SHADOW_SIZE * 2 - BORDER_WIDTH);
68+ w - SHADOW_SIZE * 2 - BORDER_WIDTH, h - SHADOW_SIZE * 2 - BORDER_WIDTH, BORDER_RADIUS - BORDER_WIDTH / 2.0);
69 main_buffer.context.set_line_width (BORDER_WIDTH);
70 Gdk.cairo_set_source_rgba (main_buffer.context, get_style_context ().get_border_color (Gtk.StateFlags.NORMAL));
71 main_buffer.context.stroke ();

Subscribers

People subscribed via source and target branches