From 52abf266c068b3dad369eefc2f2fa8187461869c Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 3 Sep 2009 10:45:01 -0400 Subject: [PATCH] Redo AppWell glow to be based on a based on a .png instead of cairo Instead of drawing an ellipse, use a hand-drawn .png file which looks a bit less regular and blends better. --- data/app-well-glow.png | Bin 0 -> 3724 bytes js/ui/appIcon.js | 88 +++++++++++++++++++++++++++-------------- src/shell-drawing.c | 76 ----------------------------------- src/shell-drawing.h | 7 ---- 4 files changed, 58 insertions(+), 113 deletions(-) create mode 100644 data/app-well-glow.png diff --git a/data/app-well-glow.png b/data/app-well-glow.png new file mode 100644 index 0000000000000000000000000000000000000000..2a8984f035ada52389d93a47a272ec10ece1c2c2 GIT binary patch literal 3724 zcmV;74s-E|P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2iXY$ z7Y{j&y~AMu000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}000f=Nkl`> z0=$x-lEoHTkIamSd%TFOBAe>gYsOwU03s`2MCGY-&pr3vBtN*a=%NKm}O}2GkY+5h5_@P+W6gvc2yI+t=q|% z--LT_L+~a99Rd}DDFpTwCZ!PA8pjkeWlan$S>~azMFaOjv@PUs1L9uzV-Q-%3!CFL zp%7@^0ak*Qplm^AMZxJs^y0}|HbwLzmg4lnWLeCGZOA38O1{fwJ#0Mx!;A6=+^s&p zzJ4cgZvl2<)y-%8^!61uo7cR$f^AlRw6=T~f_K6D95pRs=Ar3x8;ebiViO&yX*@=m zN5TTcP*8$VM#8+nWMq&L0g!wKC;)i6|G4B%AR+*e)$XCYSA;1N3=jh;6Jd0iL>k}! z@GzZ@9nS{=yy zWQY4aglQeKqH`$5D5f8L4c8@B!fs8K#71oG78VYAZK9faZ~-)Pi_Gma6%+S!3B2! z1wy7-5|HRVffxxJ96pddc=5rALopnJ@nDPt3da)0sZ&bbLz98~vf04@^e6Zcw0Qig zc*3mp)P`i=HfQHe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G z3Gx^r1!5L4Q5-<*0pEk%f!qq(%CrNtComxT5IjzdG0~Fw;ZRx~0Q<_L4o;v(vxc<%Np>pRfpk{z{ zYNO5BhW_OHWl;&hIFn!p@SeaAkbZFB-h>Ak9{}u_eNZSoz$h@dJb*GdMbZUi2@{|Zz!JhjP+xtS znrbx|0EM~qAjBExXC=~a3BOaw&5fb@Tg)vUx}XXckO5?Z3E)U*(2-rW_`VnL2IQT< zJ9FI$xMzr4_p*1_SeiKDzRh_(md!OhUSGe~<_qZR>Xi?dcjd4~vO_yq7)*-hbOMIC zIb294)DGqVVDG{ifrX@Fd#42$1=VhA?T7J^ZKrDa7i3WCY2;bL=c}}-{{lZSNQ7k&Of|BZr_ZU5P^{pC&jjNuw*(Dq=DjI&Y62L^ki9@;-ZjCvMgO#7}x`x2O-`GY$!CKB2>Gs4h5^#ol&4p6$9TZ zSEoYy#4n1JTy+a^ZW_`hcLR%9yRC#J35nz+_yl1jG&pP^agdk8ZyAE{Er0Z69=TY& z2=Nc!hrD|cz0Wa}+)m!LG;~7gS(;AtJ`$bay~|o!ZO931AVtg!BNzyo3s#?bZvB|O zU%uQ=!d{u?a8bk&ER!g~rJ9b86C*1iGldK)6G|c{6`PC|xW8%4_9F{^bHh(>Z@JlA zb8`i|TK&=55`r%dQA3KIvB^XeytK(n8_A|9w1I4#xe?d|Q-m0b6v7%m8E_zhROn)bKZvY&D`}ppXPv5WD#|sN(7tCXrf}8mmqAe^MC|DW1)bEC`tD&IFi6jTm7T1pt 0) { - let glow = new Shell.DrawingArea({}); - glow.connect('redraw', Lang.bind(this, function (e, tex) { - Shell.draw_app_highlight(tex, - this._windows.length, - GLOW_COLOR.red / 255, - GLOW_COLOR.green / 255, - GLOW_COLOR.blue / 255, - GLOW_COLOR.alpha / 255); - })); - this._name.connect('notify::allocation', Lang.bind(this, function () { - let x = this._name.x; - let y = this._name.y; - let width = this._name.width; - let height = this._name.height; - // If we're smaller than the allocated box width, pad out the glow a bit - // to make it more visible - if ((width + GLOW_PADDING * 2) < this._nameBox.width) { - width += GLOW_PADDING * 2; - x -= GLOW_PADDING; - } - glow.set_size(width, height); - glow.set_position(x, y); - })); - nameBox.add_actor(glow); - glow.lower(this._name); + nameBox.add_actor(this._name); + this._glowBox = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL }); + let glowPath = GLib.filename_to_uri(Shell.Global.get().imagedir + 'app-well-glow.png', ''); + for (let i = 0; i < this._windows.length && i < 3; i++) { + let glow = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER, + glowPath, -1, -1); + glow.keep_aspect_ratio = false; + this._glowBox.append(glow, Big.BoxPackFlags.EXPAND); } + this._nameBox.add_actor(this._glowBox); + this._glowBox.lower(this._name); this.actor.append(nameBox, Big.BoxPackFlags.NONE); + }, + + _nameBoxGetPreferredWidth: function (nameBox, forHeight, alloc) { + let [min, natural] = this._name.get_preferred_width(forHeight); + alloc.min_size = min + GLOW_PADDING_HORIZONTAL * 2; + alloc.natural_size = natural + GLOW_PADDING_HORIZONTAL * 2; + }, + + _nameBoxGetPreferredHeight: function (nameBox, forWidth, alloc) { + let [min, natural] = this._name.get_preferred_height(forWidth); + alloc.min_size = min + GLOW_PADDING_VERTICAL * 2; + alloc.natural_size = natural + GLOW_PADDING_VERTICAL * 2; + }, + + _nameBoxAllocate: function (nameBox, box, flags) { + let childBox = new Clutter.ActorBox(); + let [minWidth, naturalWidth] = this._name.get_preferred_width(-1); + let [minHeight, naturalHeight] = this._name.get_preferred_height(-1); + let availWidth = box.x2 - box.x1; + let availHeight = box.y2 - box.y1; + let targetWidth = availWidth; + let xPadding = 0; + if (naturalWidth < availWidth) { + xPadding = (availWidth - naturalWidth) / 2; + } + childBox.x1 = Math.floor(xPadding); + childBox.x2 = availWidth; + childBox.y1 = GLOW_PADDING_VERTICAL; + childBox.y2 = availHeight - GLOW_PADDING_VERTICAL; + this._name.allocate(childBox, flags); + + // Now the glow + + if (this._glowBox != null) { + let glowPaddingHoriz = Math.max(0, xPadding - GLOW_PADDING_HORIZONTAL); + childBox.x1 = Math.floor(glowPaddingHoriz); + childBox.x2 = availWidth - glowPaddingHoriz; + childBox.y1 = 0; + childBox.y2 = availHeight; + this._glowBox.allocate(childBox, flags); + } } }; diff --git a/src/shell-drawing.c b/src/shell-drawing.c index ff3ab3dd5..1032547c6 100644 --- a/src/shell-drawing.c +++ b/src/shell-drawing.c @@ -146,82 +146,6 @@ shell_draw_clock (ClutterCairoTexture *texture, cairo_destroy (cr); } -static void -draw_glow (cairo_t *cr, double red, double green, double blue, double alpha) -{ - cairo_pattern_t *gradient; - - cairo_save (cr); - - gradient = cairo_pattern_create_radial (0.0, 0.0, 0.0, 0.0, 0.0, 1.0); - cairo_pattern_add_color_stop_rgba (gradient, 0.0, red, green, blue, alpha); - cairo_pattern_add_color_stop_rgba (gradient, 0.7, red, green, blue, alpha * 0.7); - cairo_pattern_add_color_stop_rgba (gradient, 1.0, red, green, blue, alpha * 0.3); - cairo_set_source (cr, gradient); - - cairo_arc (cr, 0.0, 0.0, 1.0, 0.0, 2.0 * M_PI); - cairo_fill (cr); - - cairo_restore (cr); - cairo_pattern_destroy (gradient); -} - -void -shell_draw_app_highlight (ClutterCairoTexture *texture, - int num_windows, - double red, - double green, - double blue, - double alpha) -{ - 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); - cr = clutter_cairo_texture_create (texture); - - cairo_save (cr); - cairo_translate (cr, width / 2.0, height / 2.0); - - if (num_windows == 1) - { - cairo_scale (cr, width / 2.0, height / 2.0); - draw_glow (cr, red, green, blue, alpha); - } - else - { - int num_circles, i; - 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); - - /* The leftmost circle's 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); - for (i = 0; i < num_circles; i++) - { - draw_glow (cr, red, green, blue, alpha); - cairo_translate (cr, 1.8, 0.0); - } - } - - cairo_restore (cr); - cairo_destroy (cr); -} - static void hook_paint_red_border (ClutterActor *actor, gpointer user_data) diff --git a/src/shell-drawing.h b/src/shell-drawing.h index d462d418d..aea9a2499 100644 --- a/src/shell-drawing.h +++ b/src/shell-drawing.h @@ -17,13 +17,6 @@ void shell_draw_clock (ClutterCairoTexture *texture, int hour, int minute); -void shell_draw_app_highlight (ClutterCairoTexture *texture, - int num_windows, - double red, - double blue, - double green, - double alpha); - guint shell_add_hook_paint_red_border (ClutterActor *actor); G_END_DECLS