]> git.sur5r.net Git - glabels/commitdiff
Moved highlights/handles to separate layer (top-level group).
authorJim Evins <evins@snaught.com>
Thu, 21 Nov 2002 04:33:24 +0000 (04:33 +0000)
committerJim Evins <evins@snaught.com>
Thu, 21 Nov 2002 04:33:24 +0000 (04:33 +0000)
Tweaked appearance of highlights.
Removed shuffling of items after a raise or lower, these were artifacts from when all items belonged to a single top-level group.

git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@178 f5e0f49d-192f-0410-a22d-a8d8700d0965

glabels2/src/view-highlight.c
glabels2/src/view-object.c
glabels2/src/view.c
glabels2/src/view.h

index 0bf05f15aa5291e3eb08c78b8ecccb8dadf8f6ed..d45000480ba1292418194c2f2288f9c803652bd3 100644 (file)
 
 #include "debug.h"
 
+/*===========================================*/
+/* Private constants and macros.             */
+/*===========================================*/
+
 #define MIN_ITEM_SIZE 1.0
-#define FG_COLOR GNOME_CANVAS_COLOR_A (0, 0, 255, 255)
-#define BG_COLOR GNOME_CANVAS_COLOR_A (255, 255, 255, 255)
+#define FG_COLOR GNOME_CANVAS_COLOR_A (0, 200, 0, 100)
+#define BG_COLOR GNOME_CANVAS_COLOR_A (0, 0, 0, 200)
+#define HANDLE_PIXELS 3.0 /* 2*HANDLE_PIXELS = handle size */
 
 /*===========================================*/
 /* Private data types                        */
 /*===========================================*/
+
 struct _glViewHighlightPrivate {
        glViewHighlightStyle     style;
        glLabelObject           *object;
@@ -72,9 +78,18 @@ static void   highlight_resizable_line_construct (glViewHighlight        *view_h
 static void   highlight_simple_construct         (glViewHighlight        *view_highlight,
                                                  glViewObject           *view_object);
 
+static void   object_moved_cb                    (glLabelObject          *object,
+                                                 gdouble                 x,
+                                                 gdouble                 y,
+                                                 glViewHighlight        *view_highlight);
+
 static void   object_changed_cb                  (glLabelObject          *object,
                                                  glViewHighlight        *view_highlight);
 
+static void   view_scale_changed_cb              (glView                 *view,
+                                                 gdouble                 scale,
+                                                 glViewHighlight        *view_highlight);
+
 
 static void   update_resizable_box               (glViewHighlight        *view_highlight);
 
@@ -198,6 +213,8 @@ gl_view_highlight_new (glViewObject         *view_object,
 {
        glViewHighlight *view_highlight;
        gdouble          affine[6];
+       GList           *item_list, *p;
+       GnomeCanvasItem *item;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -229,11 +246,21 @@ gl_view_highlight_new (glViewObject         *view_object,
 
 
        gl_label_object_get_applied_affine (view_highlight->private->object, affine);
-       gnome_canvas_item_affine_absolute (view_highlight->private->group, affine);
+       item_list = GNOME_CANVAS_GROUP(view_highlight->private->group)->item_list;
+       for ( p=item_list; p != NULL; p=p->next ) {
+               item = GNOME_CANVAS_ITEM(p->data);
+               gnome_canvas_item_affine_absolute (item, affine);
+       }
+
+       g_signal_connect (G_OBJECT (view_highlight->private->object), "moved",
+                         G_CALLBACK (object_moved_cb), view_highlight);
 
        g_signal_connect (G_OBJECT (view_highlight->private->object), "changed",
                          G_CALLBACK (object_changed_cb), view_highlight);
 
+       g_signal_connect (G_OBJECT (view_highlight->private->view), "zoom_changed",
+                         G_CALLBACK (view_scale_changed_cb), view_highlight);
+
        gl_debug (DEBUG_VIEW, "END");
 
        return G_OBJECT (view_highlight);
@@ -247,10 +274,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
                                   glViewObject           *view_object,
                                   glViewHighlightStyle    style)
 {
-       gdouble w, h;
+       gdouble          x, y, w, h;
        GnomeCanvasItem *group;
-       glView *view;
-       glLabelObject *object;
+       glView          *view;
+       glLabelObject   *object;
+       gdouble          scale;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -259,6 +287,7 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
 
        view   = gl_view_object_get_view (view_object);
        view_highlight->private->view = view;
+       scale = view->scale;
 
        object = gl_view_object_get_object (view_object);
        view_highlight->private->object = object;
@@ -266,15 +295,17 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        g_return_if_fail (view && GL_IS_VIEW (view));
        g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
 
+       gl_label_object_get_position (object, &x, &y);
        gl_label_object_get_size (object, &w, &h);
 
        view_highlight->private->group =
-               gnome_canvas_item_new (GNOME_CANVAS_GROUP(gl_view_object_get_group (view_object)),
+               gnome_canvas_item_new (view->highlight_group,
                                       gnome_canvas_group_get_type (),
-                                      "x", 0.0, "y", 0.0, NULL);
+                                      "x", x, "y", y, NULL);
        gnome_canvas_item_hide (view_highlight->private->group);
        group = view_highlight->private->group;
 
+#ifdef SHOW_OUTLINE
        switch (style) {
        case GL_VIEW_HIGHLIGHT_BOX_RESIZABLE:
                view_highlight->private->outline =
@@ -284,7 +315,7 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
                                               "y1", -0.5,
                                               "x2", w + 0.5,
                                               "y2", h + 0.5,
-                                              "width_pixels", 2,
+                                              "width_pixels", 3,
                                               "outline_color_rgba", FG_COLOR,
                                               NULL);
                break;
@@ -296,7 +327,7 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
                                               "y1", -0.5,
                                               "x2", w + 0.5,
                                               "y2", h + 0.5,
-                                              "width_pixels", 2,
+                                              "width_pixels", 3,
                                               "outline_color_rgba", FG_COLOR,
                                               NULL);
                break;
@@ -304,14 +335,16 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
                view_highlight->private->outline = NULL;
                g_warning ("Invalid resizable highlight style");
        }
+#endif
 
        view_highlight->private->tl =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", -1.0,
-                                      "y1", -1.0,
-                                      "x2", +1.0,
-                                      "y2", +1.0,
+                                      "x1", -HANDLE_PIXELS/scale,
+                                      "y1", -HANDLE_PIXELS/scale,
+                                      "x2", +HANDLE_PIXELS/scale,
+                                      "y2", +HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -319,10 +352,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->tr =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", w - 1.0,
-                                      "y1", -1.0,
-                                      "x2", w + 1.0,
-                                      "y2", +1.0,
+                                      "x1", w - HANDLE_PIXELS/scale,
+                                      "y1", -HANDLE_PIXELS/scale,
+                                      "x2", w + HANDLE_PIXELS/scale,
+                                      "y2", +HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -330,10 +364,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->bl =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", -1.0,
-                                      "y1", h - 1.0,
-                                      "x2", +1.0,
-                                      "y2", h + 1.0,
+                                      "x1", -HANDLE_PIXELS/scale,
+                                      "y1", h - HANDLE_PIXELS/scale,
+                                      "x2", +HANDLE_PIXELS/scale,
+                                      "y2", h + HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -341,10 +376,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->br =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", w - 1.0,
-                                      "y1", h - 1.0,
-                                      "x2", w + 1.0,
-                                      "y2", h + 1.0,
+                                      "x1", w - HANDLE_PIXELS/scale,
+                                      "y1", h - HANDLE_PIXELS/scale,
+                                      "x2", w + HANDLE_PIXELS/scale,
+                                      "y2", h + HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -352,10 +388,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->sl =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", -1.0,
-                                      "y1", h / 2.0 - 1.0,
-                                      "x2", +1.0,
-                                      "y2", h / 2.0 + 1.0,
+                                      "x1", -HANDLE_PIXELS/scale,
+                                      "y1", h / 2.0 - HANDLE_PIXELS/scale,
+                                      "x2", +HANDLE_PIXELS/scale,
+                                      "y2", h / 2.0 + HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -363,10 +400,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->sr =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", w - 1.0,
-                                      "y1", h / 2.0 - 1.0,
-                                      "x2", w + 1.0,
-                                      "y2", h / 2.0 + 1.0,
+                                      "x1", w - HANDLE_PIXELS/scale,
+                                      "y1", h / 2.0 - HANDLE_PIXELS/scale,
+                                      "x2", w + HANDLE_PIXELS/scale,
+                                      "y2", h / 2.0 + HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -374,10 +412,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->st =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", w / 2.0 - 1.0,
-                                      "y1", -1.0,
-                                      "x2", w / 2.0 + 1.0,
-                                      "y2", +1.0,
+                                      "x1", w / 2.0 - HANDLE_PIXELS/scale,
+                                      "y1", -HANDLE_PIXELS/scale,
+                                      "x2", w / 2.0 + HANDLE_PIXELS/scale,
+                                      "y2", +HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -385,10 +424,11 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        view_highlight->private->sb =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", w / 2.0 - 1.0,
-                                      "y1", h - 1.0,
-                                      "x2", w / 2.0 + 1.0,
-                                      "y2", h + 1.0,
+                                      "x1", w / 2.0 - HANDLE_PIXELS/scale,
+                                      "y1", h - HANDLE_PIXELS/scale,
+                                      "x2", w / 2.0 + HANDLE_PIXELS/scale,
+                                      "y2", h + HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -410,12 +450,12 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
        g_signal_connect (G_OBJECT (view_highlight->private->sb), "event",
                          G_CALLBACK (sb_resize_event_handler), view_highlight);
 
+#ifdef SHOW_OUTLINE
        g_signal_connect (G_OBJECT (view_highlight->private->outline), "event",
                          G_CALLBACK (passthrough_event_handler), view_object);
+#endif
 
-       /* send to top, then lower below all items that form the foregound */
        gnome_canvas_item_raise_to_top (group);
-       gl_view_raise_fg (view);
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -424,14 +464,17 @@ highlight_resizable_box_construct (glViewHighlight        *view_highlight,
 /* PRIVATE.  Create a resizable line highlight.                              */
 /*---------------------------------------------------------------------------*/
 static void
-highlight_resizable_line_construct (glViewHighlight        *view_highlight,
-                                   glViewObject           *view_object)
+highlight_resizable_line_construct (glViewHighlight *view_highlight,
+                                   glViewObject    *view_object)
 {
-       gdouble dx, dy;
-       GnomeCanvasItem *group;
+       gdouble            x, y, dx, dy;
+       GnomeCanvasItem   *group;
+#ifdef SHOW_OUTLINE
        GnomeCanvasPoints *points;
-       glView *view;
-       glLabelObject *object;
+#endif
+       glView            *view;
+       glLabelObject     *object;
+       gdouble            scale;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -440,6 +483,7 @@ highlight_resizable_line_construct (glViewHighlight        *view_highlight,
 
        view   = gl_view_object_get_view (view_object);
        view_highlight->private->view = view;
+       scale = view->scale;
 
        object = gl_view_object_get_object (view_object);
        view_highlight->private->object = object;
@@ -447,17 +491,21 @@ highlight_resizable_line_construct (glViewHighlight        *view_highlight,
        g_return_if_fail (view && GL_IS_VIEW (view));
        g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
 
+       gl_label_object_get_position (object, &x, &y);
        gl_label_object_get_size (object, &dx, &dy);
 
+#ifdef SHOW_OUTLINE
        points = gnome_canvas_points_new (2);
+#endif
 
        view_highlight->private->group =
-               gnome_canvas_item_new (GNOME_CANVAS_GROUP(gl_view_object_get_group (view_object)),
+               gnome_canvas_item_new (view->highlight_group,
                                       gnome_canvas_group_get_type (),
-                                      "x", 0.0, "y", 0.0, NULL);
+                                      "x", x, "y", y, NULL);
        gnome_canvas_item_hide (view_highlight->private->group);
        group = view_highlight->private->group;
 
+#ifdef SHOW_OUTLINE
        points->coords[0] = 0.0;
        points->coords[1] = 0.0;
        points->coords[2] = dx;
@@ -469,14 +517,16 @@ highlight_resizable_line_construct (glViewHighlight        *view_highlight,
                                       "width_pixels", 3,
                                       "fill_color_rgba", FG_COLOR,
                                       NULL);
+#endif
 
        view_highlight->private->p1 =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", -1.0,
-                                      "y1", -1.0,
-                                      "x2", +1.0,
-                                      "y2", +1.0,
+                                      "x1", -HANDLE_PIXELS/scale,
+                                      "y1", -HANDLE_PIXELS/scale,
+                                      "x2", +HANDLE_PIXELS/scale,
+                                      "y2", +HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -484,10 +534,11 @@ highlight_resizable_line_construct (glViewHighlight        *view_highlight,
        view_highlight->private->p2 =
                gnome_canvas_item_new (GNOME_CANVAS_GROUP(group),
                                       gnome_canvas_rect_get_type (),
-                                      "x1", dx - 1.0,
-                                      "y1", dy - 1.0,
-                                      "x2", dx + 1.0,
-                                      "y2", dy + 1.0,
+                                      "x1", dx - HANDLE_PIXELS/scale,
+                                      "y1", dy - HANDLE_PIXELS/scale,
+                                      "x2", dx + HANDLE_PIXELS/scale,
+                                      "y2", dy + HANDLE_PIXELS/scale,
+                                      "width_pixels", 1,
                                       "fill_color_rgba", FG_COLOR,
                                       "outline_color_rgba", BG_COLOR,
                                       NULL);
@@ -497,14 +548,16 @@ highlight_resizable_line_construct (glViewHighlight        *view_highlight,
        g_signal_connect (G_OBJECT (view_highlight->private->p2), "event",
                          G_CALLBACK (p2_resize_event_handler), view_highlight);
 
+#ifdef SHOW_OUTLINE
        g_signal_connect (G_OBJECT (view_highlight->private->outline), "event",
                          G_CALLBACK (passthrough_event_handler), view_object);
+#endif
 
+#ifdef SHOW_OUTLINE
        gnome_canvas_points_free (points);
+#endif
 
-       /* send to top, then lower below all items that form the foregound */
        gnome_canvas_item_raise_to_top (group);
-       gl_view_raise_fg (view);
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -513,13 +566,13 @@ highlight_resizable_line_construct (glViewHighlight        *view_highlight,
 /* PRIVATE.  Create a simple box highlight.                                  */
 /*---------------------------------------------------------------------------*/
 static void
-highlight_simple_construct (glViewHighlight        *view_highlight,
-                           glViewObject           *view_object)
+highlight_simple_construct (glViewHighlight *view_highlight,
+                           glViewObject    *view_object)
 {
-       gdouble w, h;
+       gdouble          x, y, w, h;
        GnomeCanvasItem *group;
-       glView *view;
-       glLabelObject *object;
+       glView          *view;
+       glLabelObject   *object;
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -535,13 +588,14 @@ highlight_simple_construct (glViewHighlight        *view_highlight,
        g_return_if_fail (view && GL_IS_VIEW (view));
        g_return_if_fail (object && GL_IS_LABEL_OBJECT (object));
 
+       gl_label_object_get_position (object, &x, &y);
        gl_label_object_get_size (object, &w, &h);
 
 
        view_highlight->private->group =
-               gnome_canvas_item_new (GNOME_CANVAS_GROUP(gl_view_object_get_group (view_object)),
+               gnome_canvas_item_new (view->highlight_group,
                                       gnome_canvas_group_get_type (),
-                                      "x", 0.0, "y", 0.0, NULL);
+                                      "x", x, "y", y, NULL);
        gnome_canvas_item_hide (view_highlight->private->group);
        group = view_highlight->private->group;
 
@@ -552,7 +606,7 @@ highlight_simple_construct (glViewHighlight        *view_highlight,
                                       "y1", -0.5,
                                       "x2", w + 0.5,
                                       "y2", h + 0.5,
-                                      "width_pixels", 2,
+                                      "width_pixels", 3,
                                       "outline_color_rgba", FG_COLOR,
                                       NULL);
 
@@ -560,9 +614,7 @@ highlight_simple_construct (glViewHighlight        *view_highlight,
        g_signal_connect (G_OBJECT (view_highlight->private->outline), "event",
                          G_CALLBACK (passthrough_event_handler), view_object);
 
-       /* send to top, then lower below all items that form the foregound */
        gnome_canvas_item_raise_to_top (group);
-       gl_view_raise_fg (view);
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -576,7 +628,6 @@ gl_view_highlight_show (glViewHighlight *view_highlight)
        gnome_canvas_item_show (view_highlight->private->group);
 
        gnome_canvas_item_raise_to_top (view_highlight->private->group);
-       gl_view_raise_fg (view_highlight->private->view);
 }
 
 /****************************************************************************/
@@ -588,6 +639,23 @@ gl_view_highlight_hide (glViewHighlight *view_highlight)
        gnome_canvas_item_hide (view_highlight->private->group);
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  label object "moved" callback.                                  */
+/*---------------------------------------------------------------------------*/
+static void
+object_moved_cb (glLabelObject   *object,
+                gdouble          dx,
+                gdouble          dy,
+                glViewHighlight *view_highlight)
+{
+       gl_debug (DEBUG_VIEW, "START");
+
+       /* Adjust location of analogous canvas group. */
+       gnome_canvas_item_move (view_highlight->private->group, dx, dy);
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE. label object "changed" callback.                                 */
 /*---------------------------------------------------------------------------*/
@@ -623,6 +691,42 @@ object_changed_cb (glLabelObject   *object,
        gl_debug (DEBUG_VIEW, "END");
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE. view scale (zoom) changed callback.                              */
+/*---------------------------------------------------------------------------*/
+static void
+view_scale_changed_cb (glView          *view,
+                      gdouble          scale,
+                      glViewHighlight *view_highlight)
+{
+       gl_debug (DEBUG_VIEW, "START");
+
+       g_return_if_fail (view_highlight && GL_IS_VIEW_HIGHLIGHT (view_highlight));
+       g_return_if_fail (view && GL_IS_VIEW (view));
+
+       switch (view_highlight->private->style) {
+
+       case GL_VIEW_HIGHLIGHT_BOX_RESIZABLE:
+       case GL_VIEW_HIGHLIGHT_ELLIPSE_RESIZABLE:
+               update_resizable_box (view_highlight);
+               break;
+
+       case GL_VIEW_HIGHLIGHT_LINE_RESIZABLE:
+               update_resizable_line (view_highlight);
+               break;
+
+       case GL_VIEW_HIGHLIGHT_SIMPLE:
+               update_simple (view_highlight);
+               break;
+
+       default:
+               g_warning ("Invalid resizable highlight style");
+
+       }
+
+       gl_debug (DEBUG_VIEW, "END");
+}
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Update a resizable box highlight.                               */
 /*---------------------------------------------------------------------------*/
@@ -630,80 +734,83 @@ static void
 update_resizable_box  (glViewHighlight *view_highlight)
 {
        gdouble w, h;
+       gdouble scale;
 
        gl_debug (DEBUG_VIEW, "START");
 
        g_return_if_fail (view_highlight && GL_IS_VIEW_HIGHLIGHT (view_highlight));
 
+       scale = view_highlight->private->view->scale;
+
        gl_label_object_get_size (view_highlight->private->object, &w, &h);
 
 
+#ifdef SHOW_OUTLINE
        gnome_canvas_item_set (view_highlight->private->outline,
                               "x1", -0.5,
                               "y1", -0.5,
                               "x2", w + 0.5,
                               "y2", h + 0.5,
                               NULL);
+#endif
 
        gnome_canvas_item_set (view_highlight->private->tl,
-                              "x1", -1.0,
-                              "y1", -1.0,
-                              "x2", +1.0,
-                              "y2", +1.0,
+                              "x1", -HANDLE_PIXELS/scale,
+                              "y1", -HANDLE_PIXELS/scale,
+                              "x2", +HANDLE_PIXELS/scale,
+                              "y2", +HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->tr,
-                              "x1", w - 1.0,
-                              "y1", -1.0,
-                              "x2", w + 1.0,
-                              "y2", +1.0,
+                              "x1", w - HANDLE_PIXELS/scale,
+                              "y1", -HANDLE_PIXELS/scale,
+                              "x2", w + HANDLE_PIXELS/scale,
+                              "y2", +HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->bl,
-                              "x1", -1.0,
-                              "y1", h - 1.0,
-                              "x2", +1.0,
-                              "y2", h + 1.0,
+                              "x1", -HANDLE_PIXELS/scale,
+                              "y1", h - HANDLE_PIXELS/scale,
+                              "x2", +HANDLE_PIXELS/scale,
+                              "y2", h + HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->br,
-                              "x1", w - 1.0,
-                              "y1", h - 1.0,
-                              "x2", w + 1.0,
-                              "y2", h + 1.0,
+                              "x1", w - HANDLE_PIXELS/scale,
+                              "y1", h - HANDLE_PIXELS/scale,
+                              "x2", w + HANDLE_PIXELS/scale,
+                              "y2", h + HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->sl,
-                              "x1", -1.0,
-                              "y1", h / 2.0 - 1.0,
-                              "x2", +1.0,
-                              "y2", h / 2.0 + 1.0,
+                              "x1", -HANDLE_PIXELS/scale,
+                              "y1", h / 2.0 - HANDLE_PIXELS/scale,
+                              "x2", +HANDLE_PIXELS/scale,
+                              "y2", h / 2.0 + HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->sr,
-                              "x1", w - 1.0,
-                              "y1", h / 2.0 - 1.0,
-                              "x2", w + 1.0,
-                              "y2", h / 2.0 + 1.0,
+                              "x1", w - HANDLE_PIXELS/scale,
+                              "y1", h / 2.0 - HANDLE_PIXELS/scale,
+                              "x2", w + HANDLE_PIXELS/scale,
+                              "y2", h / 2.0 + HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->st,
-                              "x1", w / 2.0 - 1.0,
-                              "y1", -1.0,
-                              "x2", w / 2.0 + 1.0,
-                              "y2", +1.0,
+                              "x1", w / 2.0 - HANDLE_PIXELS/scale,
+                              "y1", -HANDLE_PIXELS/scale,
+                              "x2", w / 2.0 + HANDLE_PIXELS/scale,
+                              "y2", +HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->sb,
-                              "x1", w / 2.0 - 1.0,
-                              "y1", h - 1.0,
-                              "x2", w / 2.0 + 1.0,
-                              "y2", h + 1.0,
+                              "x1", w / 2.0 - HANDLE_PIXELS/scale,
+                              "y1", h - HANDLE_PIXELS/scale,
+                              "x2", w / 2.0 + HANDLE_PIXELS/scale,
+                              "y2", h + HANDLE_PIXELS/scale,
                               NULL);
 
-       /* send to top, then lower below all items that form the foregound */
        gnome_canvas_item_raise_to_top (view_highlight->private->group);
-       gl_view_raise_fg (view_highlight->private->view);
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -715,14 +822,20 @@ static void
 update_resizable_line (glViewHighlight *view_highlight)
 {
        gdouble dx, dy;
+#ifdef SHOW_OUTLINE
        GnomeCanvasPoints *points;
+#endif
+       gdouble scale;
 
        gl_debug (DEBUG_VIEW, "START");
 
        g_return_if_fail (view_highlight && GL_IS_VIEW_HIGHLIGHT (view_highlight));
 
+       scale = view_highlight->private->view->scale;
+
        gl_label_object_get_size (view_highlight->private->object, &dx, &dy);
 
+#ifdef SHOW_OUTLINE
        points = gnome_canvas_points_new (2);
 
        points->coords[0] = 0.0;
@@ -730,26 +843,27 @@ update_resizable_line (glViewHighlight *view_highlight)
        points->coords[2] = dx;
        points->coords[3] = dy;
        gnome_canvas_item_set (view_highlight->private->outline, "points", points, NULL);
+#endif
 
        gnome_canvas_item_set (view_highlight->private->p1,
-                              "x1", -1.0,
-                              "y1", -1.0,
-                              "x2", +1.0,
-                              "y2", +1.0,
+                              "x1", -HANDLE_PIXELS/scale,
+                              "y1", -HANDLE_PIXELS/scale,
+                              "x2", +HANDLE_PIXELS/scale,
+                              "y2", +HANDLE_PIXELS/scale,
                               NULL);
 
        gnome_canvas_item_set (view_highlight->private->p2,
-                              "x1", dx - 1.0,
-                              "y1", dy - 1.0,
-                              "x2", dx + 1.0,
-                              "y2", dy + 1.0,
+                              "x1", dx - HANDLE_PIXELS/scale,
+                              "y1", dy - HANDLE_PIXELS/scale,
+                              "x2", dx + HANDLE_PIXELS/scale,
+                              "y2", dy + HANDLE_PIXELS/scale,
                               NULL);
 
+#ifdef SHOW_OUTLINE
        gnome_canvas_points_free (points);
+#endif
 
-       /* send to top, then lower below all items that form the foregound */
        gnome_canvas_item_raise_to_top (view_highlight->private->group);
-       gl_view_raise_fg (view_highlight->private->view);
 
        gl_debug (DEBUG_VIEW, "END");
 }
@@ -773,9 +887,7 @@ update_simple (glViewHighlight *view_highlight)
                               "y2", h + 0.5,
                               NULL);
 
-       /* send to top, then lower below all items that form the foregound */
        gnome_canvas_item_raise_to_top (view_highlight->private->group);
-       gl_view_raise_fg (view_highlight->private->view);
 
        gl_debug (DEBUG_VIEW, "END");
 }
index c718e65d9a53bcf9355ad5ae9b8313204609e2c6..62b951dfdc1e435a100f8e76e80e015bb4740c03 100644 (file)
@@ -32,7 +32,7 @@
 /*========================================================*/
 
 /* Used for a workaround for a bug with images when flipped or rotated by 90 degrees. */
-#define DELTA_DEG 0.0001
+#define DELTA_DEG 0.001
 
 /*========================================================*/
 /* Private types.                                         */
@@ -235,8 +235,6 @@ gl_view_object_set_object     (glViewObject         *view_object,
        view_object->private->highlight =
                GL_VIEW_HIGHLIGHT (gl_view_highlight_new (view_object, style));
 
-       gl_view_raise_fg (view_object->private->view);
-
        view_object->private->menu = GTK_WIDGET(new_menu (view_object));
 
        g_signal_connect (G_OBJECT (object), "moved",
@@ -335,7 +333,7 @@ gl_view_object_item_new (glViewObject *view_object,
 {
        GnomeCanvasItem *item;
        va_list          args;
-       gdouble          affine[6];
+       gdouble          affine[6], delta_affine[6];
 
        gl_debug (DEBUG_VIEW, "START");
 
@@ -349,6 +347,11 @@ gl_view_object_item_new (glViewObject *view_object,
         va_end (args);
 
        gl_label_object_get_applied_affine (view_object->private->object, affine);
+
+       /* Apply a very small rotation, fixes problems with flipped or rotated images */
+       art_affine_rotate (delta_affine, DELTA_DEG);
+       art_affine_multiply (affine, affine, delta_affine);
+       
        gnome_canvas_item_affine_absolute (item, affine);
 
        gl_debug (DEBUG_VIEW, "END");
@@ -512,8 +515,6 @@ object_moved_cb (glLabelObject *object,
                 gdouble        dy,
                 glViewObject  *view_object)
 {
-       GnomeCanvasItem    *item, *highlight;
-
        gl_debug (DEBUG_VIEW, "START");
 
        /* Adjust location of analogous canvas group. */
@@ -534,9 +535,6 @@ raise_object_cb (glLabelObject *object,
        /* send to top */
        gnome_canvas_item_raise_to_top (view_object->private->group);
 
-       /* send highlight to top */
-       gl_view_highlight_show (view_object->private->highlight);
-
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -552,11 +550,6 @@ lower_object_cb (glLabelObject *object,
        /* Send to bottom */
        gnome_canvas_item_lower_to_bottom (view_object->private->group);
 
-       /* now raise it above all items that form the backgound */
-       gnome_canvas_item_lower_to_bottom (GNOME_CANVAS_ITEM(view_object->private->view->markup_group));
-       gnome_canvas_item_lower_to_bottom (GNOME_CANVAS_ITEM(view_object->private->view->grid_group));
-       gnome_canvas_item_lower_to_bottom (GNOME_CANVAS_ITEM(view_object->private->view->bg_group));
-
        gl_debug (DEBUG_VIEW, "END");
 }
 
index 846706cb3a1c90ae589a265b407fc11deb07409f..0257cfdd2f2bc10b112523ea6da803ce1dfaf060 100644 (file)
@@ -106,6 +106,8 @@ static void       draw_layers                     (glView *view);
 
 static void       draw_label_layer                (glView *view);
 
+static void       draw_highlight_layer            (glView *view);
+
 static void       draw_bg_fg_layers               (glView *view);
 static void       draw_bg_fg_rect                 (glView *view);
 static void       draw_bg_fg_rounded_rect         (glView *view);
@@ -481,9 +483,11 @@ draw_layers (glView *view)
        draw_bg_fg_layers (view);
        draw_grid_layer (view);
        draw_markup_layer (view);
+       draw_highlight_layer (view); /* Must be done before label layer */
        draw_label_layer (view);
 
        gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->fg_group));
+       gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->highlight_group));
 }
 
 /*---------------------------------------------------------------------------*/
@@ -537,6 +541,23 @@ draw_label_layer (glView *view)
        }
 }
 
+/*---------------------------------------------------------------------------*/
+/* PRIVATE.  Create highlight layer.                                         */
+/*---------------------------------------------------------------------------*/
+static void
+draw_highlight_layer (glView *view)
+{
+       GnomeCanvasGroup *group;
+
+       group = gnome_canvas_root (GNOME_CANVAS (view->canvas));
+       view->highlight_group = GNOME_CANVAS_GROUP(
+               gnome_canvas_item_new (group,
+                                      gnome_canvas_group_get_type (),
+                                      "x", 0.0,
+                                      "y", 0.0,
+                                      NULL));
+}
+
 /*---------------------------------------------------------------------------*/
 /* PRIVATE.  Draw background and foreground outlines.                        */
 /*---------------------------------------------------------------------------*/
@@ -1183,17 +1204,6 @@ draw_markup_line (glView               *view,
        gl_debug (DEBUG_VIEW, "END");
 }
 
-/*****************************************************************************/
-/* Raise foreground items to top.                                            */
-/*****************************************************************************/
-void
-gl_view_raise_fg (glView *view)
-{
-       GList *p;
-
-       gnome_canvas_item_raise_to_top (GNOME_CANVAS_ITEM(view->fg_group));
-}
-
 /*****************************************************************************/
 /* Show grid.                                                                */
 /*****************************************************************************/
@@ -1491,8 +1501,9 @@ object_at (glView  *view,
        if (item == NULL)
                return FALSE;
 
-       /* ignore items not in label group, e.g. background items */
-       if (!is_item_member_of_group(view, item, GNOME_CANVAS_ITEM(view->label_group)))
+       /* ignore items not in label or highlight layers, e.g. background items */
+       if (!is_item_member_of_group(view, item, GNOME_CANVAS_ITEM(view->label_group)) &&
+           !is_item_member_of_group(view, item, GNOME_CANVAS_ITEM(view->highlight_group)))
                return FALSE;
 
        return TRUE;
index 45778d382cf8e7e6460c05a9f29859ee8c370d06..56ddd9ac46544b3572658aa85f7b6335e82fe797 100644 (file)
@@ -57,6 +57,7 @@ struct _glView {
        GnomeCanvasGroup *markup_group;          /* Markup layer */
        GnomeCanvasGroup *label_group;           /* Label layer (user objects) */
        GnomeCanvasGroup *fg_group;              /* Foreground layer */
+       GnomeCanvasGroup *highlight_group;       /* Highlight layer */
 
        gdouble           grid_spacing;
 
@@ -102,9 +103,6 @@ guint      gl_view_get_type                (void);
 GtkWidget *gl_view_new                     (glLabel           *label);
 
 
-void       gl_view_raise_fg                (glView            *view);
-
-
 void       gl_view_show_grid               (glView            *view);
 
 void       gl_view_hide_grid               (glView            *view);