From 51db34d22341b5533e9129f50d29232269b7ab4e Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 13 Aug 2009 10:10:50 -0400 Subject: [PATCH] Implement distinct 2-window and multi-window highlights --- js/ui/appDisplay.js | 2 +- src/shell-drawing.c | 46 ++++++++++++++++++++++++++++----------------- src/shell-drawing.h | 2 +- 3 files changed, 31 insertions(+), 19 deletions(-) diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js index cbc873d8c..906c45fc2 100644 --- a/js/ui/appDisplay.js +++ b/js/ui/appDisplay.js @@ -488,7 +488,7 @@ WellDisplayItem.prototype = { let glow = new Shell.DrawingArea({}); glow.connect('redraw', Lang.bind(this, function (e, tex) { Shell.draw_app_highlight(tex, - this._windows.length > 1, + this._windows.length, GLOW_COLOR.red / 255, GLOW_COLOR.green / 255, GLOW_COLOR.blue / 255, diff --git a/src/shell-drawing.c b/src/shell-drawing.c index 9271790e6..44eafd498 100644 --- a/src/shell-drawing.c +++ b/src/shell-drawing.c @@ -168,7 +168,7 @@ draw_glow (cairo_t *cr, double red, double green, double blue, double alpha) void shell_draw_app_highlight (ClutterCairoTexture *texture, - gboolean multi, + int num_windows, double red, double green, double blue, @@ -177,6 +177,8 @@ shell_draw_app_highlight (ClutterCairoTexture *texture, cairo_t *cr; guint width, height; + g_return_if_fail (num_windows > 0); + clutter_cairo_texture_get_surface_size (texture, &width, &height); clutter_cairo_texture_clear (texture); @@ -185,28 +187,38 @@ shell_draw_app_highlight (ClutterCairoTexture *texture, cairo_save (cr); cairo_translate (cr, width / 2.0, height / 2.0); - if (multi) + if (num_windows == 1) { - double scale; - - /* We draw three circles of radius 1, at 0.0, -1.8, and +1.8. - * Total width is therefore 1 + 1.8 + 1.8 + 1 = 5.6. - */ - scale = MIN (height / 2.0, width / 5.6); - cairo_scale (cr, scale, scale); - - draw_glow (cr, red, green, blue, alpha); - - cairo_translate (cr, -1.8, 0.0); - draw_glow (cr, red, green, blue, alpha); - - cairo_translate (cr, 3.6, 0.0); + cairo_scale (cr, width / 2.0, height / 2.0); draw_glow (cr, red, green, blue, alpha); } else { - cairo_scale (cr, width / 2.0, height / 2.0); + int num_circles; + double scale, highlight_width; + + num_circles = num_windows == 2 ? 2 : 3; + + /* The circles will have radius 1.0 (diameter 2.0) and overlap + * by 0.2, so the total width of the highlight is: + */ + highlight_width = 2.0 * num_circles - 0.2 * (num_circles - 1); + + scale = MIN (height / 2.0, width / highlight_width); + cairo_scale (cr, scale, scale); + + /* Leftmost circle first; its left side is at + * -highlight_width/2, so its center is that plus 1. + */ + cairo_translate (cr, -highlight_width / 2.0 + 1.0, 0.0); draw_glow (cr, red, green, blue, alpha); + + /* Remaining circles */ + while (--num_circles) + { + cairo_translate (cr, 1.8, 0.0); + draw_glow (cr, red, green, blue, alpha); + } } cairo_restore (cr); diff --git a/src/shell-drawing.h b/src/shell-drawing.h index 0d73786f7..d462d418d 100644 --- a/src/shell-drawing.h +++ b/src/shell-drawing.h @@ -18,7 +18,7 @@ void shell_draw_clock (ClutterCairoTexture *texture, int minute); void shell_draw_app_highlight (ClutterCairoTexture *texture, - gboolean multi, + int num_windows, double red, double blue, double green,