[gnome-shell] lookingGlass: Draw a red border around target actor
- From: Colin Walters <walters src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-shell] lookingGlass: Draw a red border around target actor
- Date: Tue, 4 Aug 2009 14:01:17 +0000 (UTC)
commit 902956ca0d1e0cd3ee7b1a73b24928f20795db40
Author: Colin Walters <walters verbum org>
Date: Tue Aug 4 09:48:15 2009 -0400
lookingGlass: Draw a red border around target actor
js/ui/lookingGlass.js | 13 +++++++++++++
src/shell-drawing.c | 35 +++++++++++++++++++++++++++++++++++
src/shell-drawing.h | 2 ++
3 files changed, 50 insertions(+), 0 deletions(-)
---
diff --git a/js/ui/lookingGlass.js b/js/ui/lookingGlass.js
index df80650..0f6b7cb 100644
--- a/js/ui/lookingGlass.js
+++ b/js/ui/lookingGlass.js
@@ -230,6 +230,14 @@ LookingGlass.prototype = {
let displayText = new Clutter.Text({ color: MATRIX_GREEN,
font_name: MATRIX_FONT, text: '' });
eventHandler.append(displayText, Big.BoxPackFlags.EXPAND);
+
+ let borderPaintTarget = null;
+ let borderPaintId = null;
+ eventHandler.connect('destroy', Lang.bind(this, function() {
+ if (borderPaintTarget != null)
+ borderPaintTarget.disconnect(borderPaintId);
+ }));
+
eventHandler.connect('button-press-event', Lang.bind(this, function (actor, event) {
let global = Shell.Global.get();
Clutter.ungrab_pointer(eventHandler);
@@ -246,6 +254,7 @@ LookingGlass.prototype = {
global.stage.set_key_focus(this._entry);
return true;
}));
+
eventHandler.connect('motion-event', Lang.bind(this, function (actor, event) {
let global = Shell.Global.get();
let [stageX, stageY] = event.get_coords();
@@ -253,6 +262,10 @@ LookingGlass.prototype = {
stageX,
stageY);
displayText.text = '<inspect x: ' + stageX + ' y: ' + stageY + '> ' + target;
+ if (borderPaintTarget != null)
+ borderPaintTarget.disconnect(borderPaintId);
+ borderPaintTarget = target;
+ borderPaintId = Shell.add_hook_paint_red_border(target);
return true;
}));
Clutter.grab_pointer(eventHandler);
diff --git a/src/shell-drawing.c b/src/shell-drawing.c
index 58617bd..daac1ee 100644
--- a/src/shell-drawing.c
+++ b/src/shell-drawing.c
@@ -178,3 +178,38 @@ shell_draw_glow (ClutterCairoTexture *texture,
cairo_pattern_destroy (gradient);
cairo_destroy (cr);
}
+
+static void
+hook_paint_red_border (ClutterActor *actor,
+ gpointer user_data)
+{
+ CoglColor color;
+ ClutterGeometry geom;
+ float width = 2;
+ float x2;
+ float y2;
+
+ cogl_color_set_from_4ub (&color, 0xff, 0, 0, 0xc4);
+ cogl_set_source_color (&color);
+
+ clutter_actor_get_allocation_geometry (actor, &geom);
+ x2 = geom.x + geom.width;
+ y2 = geom.y + geom.height;
+
+ /** clockwise order **/
+ cogl_rectangle (geom.x, geom.y,
+ x2, geom.y + width);
+ cogl_rectangle (x2 - width, geom.y + width,
+ x2, y2);
+ cogl_rectangle (x2 - width, y2,
+ geom.x, y2 - width);
+ cogl_rectangle (geom.x + width, y2 - width,
+ geom.x, geom.y + width);
+}
+
+guint
+shell_add_hook_paint_red_border (ClutterActor *actor)
+{
+ return g_signal_connect_after (G_OBJECT (actor), "paint",
+ G_CALLBACK (hook_paint_red_border), NULL);
+}
diff --git a/src/shell-drawing.h b/src/shell-drawing.h
index 78c4fcf..04aa58a 100644
--- a/src/shell-drawing.h
+++ b/src/shell-drawing.h
@@ -23,6 +23,8 @@ void shell_draw_glow (ClutterCairoTexture *texture,
double green,
double alpha);
+guint shell_add_hook_paint_red_border (ClutterActor *actor);
+
G_END_DECLS
#endif /* __SHELL_GLOBAL_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]