[gnome-shell] [AppIcon] Improve shell_draw_box_pointer()



commit ff4ac0d02ed00712894ab25f6ecae16d6567b4a7
Author: Dan Winship <danw gnome org>
Date:   Sun Oct 4 11:37:11 2009 -0400

    [AppIcon] Improve shell_draw_box_pointer()
    
    Add a new enum type for the pointer direction, rather than abusing
    ClutterGravity, and implement the missing directions.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=597498

 js/ui/appIcon.js    |    2 +-
 src/shell-drawing.c |   42 ++++++++++++++++++++++++++++--------------
 src/shell-drawing.h |   15 +++++++++++----
 3 files changed, 40 insertions(+), 19 deletions(-)
---
diff --git a/js/ui/appIcon.js b/js/ui/appIcon.js
index bc9001f..5585eb0 100644
--- a/js/ui/appIcon.js
+++ b/js/ui/appIcon.js
@@ -322,7 +322,7 @@ AppIconMenu.prototype = {
         this._arrow = new Shell.DrawingArea();
         this._arrow.connect('redraw', Lang.bind(this, function (area, texture) {
             Shell.draw_box_pointer(texture,
-                                   this._type == MenuType.ON_RIGHT ? Clutter.Gravity.WEST : Clutter.Gravity.NORTH,
+                                   this._type == MenuType.ON_RIGHT ? Shell.PointerDirection.LEFT : Shell.PointerDirection.UP,
                                    source.highlight_border_color,
                                    APPICON_MENU_BACKGROUND_COLOR);
         }));
diff --git a/src/shell-drawing.c b/src/shell-drawing.c
index 50d913a..69c47b9 100644
--- a/src/shell-drawing.c
+++ b/src/shell-drawing.c
@@ -147,17 +147,14 @@ shell_draw_clock (ClutterCairoTexture *texture,
 }
 
 void
-shell_draw_box_pointer (ClutterCairoTexture *texture,
-                        ClutterGravity       pointing_towards,
-                        ClutterColor        *border_color,
-                        ClutterColor        *background_color)
+shell_draw_box_pointer (ClutterCairoTexture   *texture,
+                        ShellPointerDirection  direction,
+                        ClutterColor          *border_color,
+                        ClutterColor          *background_color)
 {
   guint width, height;
   cairo_t *cr;
 
-  g_return_if_fail (pointing_towards == CLUTTER_GRAVITY_NORTH ||
-                    pointing_towards == CLUTTER_GRAVITY_WEST);
-
   clutter_cairo_texture_get_surface_size (texture, &width, &height);
 
   clutter_cairo_texture_clear (texture);
@@ -167,17 +164,34 @@ shell_draw_box_pointer (ClutterCairoTexture *texture,
 
   clutter_cairo_set_source_color (cr, border_color);
 
-  if (pointing_towards == CLUTTER_GRAVITY_WEST)
-    {
-      cairo_move_to (cr, width, 0);
-      cairo_line_to (cr, 0, floor (height * 0.5));
-      cairo_line_to (cr, width, height);
-    }
-  else /* CLUTTER_GRAVITY_NORTH */
+  switch (direction)
     {
+    case SHELL_POINTER_UP:
       cairo_move_to (cr, 0, height);
       cairo_line_to (cr, floor (width * 0.5), 0);
       cairo_line_to (cr, width, height);
+      break;
+
+    case SHELL_POINTER_DOWN:
+      cairo_move_to (cr, width, 0);
+      cairo_line_to (cr, floor (width * 0.5), height);
+      cairo_line_to (cr, 0, 0);
+      break;
+
+    case SHELL_POINTER_LEFT:
+      cairo_move_to (cr, width, height);
+      cairo_line_to (cr, 0, floor (height * 0.5));
+      cairo_line_to (cr, width, 0);
+      break;
+
+    case SHELL_POINTER_RIGHT:
+      cairo_move_to (cr, 0, 0);
+      cairo_line_to (cr, width, floor (height * 0.5));
+      cairo_line_to (cr, 0, height);
+      break;
+
+    default:
+      g_assert_not_reached();
     }
 
   cairo_stroke_preserve (cr);
diff --git a/src/shell-drawing.h b/src/shell-drawing.h
index d3db5cf..eae39fc 100644
--- a/src/shell-drawing.h
+++ b/src/shell-drawing.h
@@ -13,10 +13,17 @@ ClutterCairoTexture *shell_create_vertical_gradient (ClutterColor *top,
 ClutterCairoTexture *shell_create_horizontal_gradient (ClutterColor *left,
                                                        ClutterColor *right);
 
-void shell_draw_box_pointer (ClutterCairoTexture *texture,
-                             ClutterGravity       pointing_towards,
-                             ClutterColor        *border_color,
-                             ClutterColor        *background_color);
+typedef enum {
+  SHELL_POINTER_UP,
+  SHELL_POINTER_DOWN,
+  SHELL_POINTER_LEFT,
+  SHELL_POINTER_RIGHT
+} ShellPointerDirection;
+
+void shell_draw_box_pointer (ClutterCairoTexture   *texture,
+                             ShellPointerDirection  direction,
+                             ClutterColor          *border_color,
+                             ClutterColor          *background_color);
 
 void shell_draw_clock (ClutterCairoTexture *texture,
 	               int                  hour,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]