]> git.sur5r.net Git - glabels/commitdiff
Added foreground label outlines.
authorJim Evins <evins@snaught.com>
Sun, 25 Aug 2002 05:22:13 +0000 (05:22 +0000)
committerJim Evins <evins@snaught.com>
Sun, 25 Aug 2002 05:22:13 +0000 (05:22 +0000)
git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@59 f5e0f49d-192f-0410-a22d-a8d8700d0965

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

index 9897b3f5420fb618a440ab5cc772839e9a7fcd4a..449f0317ed8336fbf4ff24a0c8053c860989a52d 100644 (file)
@@ -210,6 +210,10 @@ gl_view_object_set_object     (glViewObject         *view_object,
                                       "y", y,
                                       NULL);
 
+       /* lower it below all items that form the foregound */
+       gnome_canvas_item_lower (view_object->private->group,
+                                view_object->private->view->n_fg_items);
+
        /* Create appropriate selection highlight canvas item. */
        view_object->private->highlight =
                gl_view_highlight_new (view_object, style);
@@ -484,6 +488,10 @@ raise_object_cb (GtkWidget * widget,
        gnome_canvas_item_raise_to_top (view_object->private->group);
        gnome_canvas_item_raise_to_top (view_object->private->highlight);
 
+       /* lower it below all items that form the foregound */
+       gnome_canvas_item_lower (view_object->private->group,
+                                view_object->private->view->n_fg_items);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
index d6e3a3dc9d61b436f8198ed3e5f0738a9a321b8c..8b7a1131d2fbeb1e8f70d49f027e089d819c4f78 100644 (file)
@@ -433,6 +433,8 @@ draw_rect_bg (glView * view)
 
        view->n_bg_items = 0;
        view->bg_item_list = NULL;
+       view->n_fg_items = 0;
+       view->fg_item_list = NULL;
 
        group = gnome_canvas_root (GNOME_CANVAS (view->canvas));
 
@@ -460,6 +462,18 @@ draw_rect_bg (glView * view)
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
 
+       item = gnome_canvas_item_new (group,
+                                     gnome_canvas_rect_get_type (),
+                                     "x1", 0.0,
+                                     "y1", 0.0,
+                                     "x2", w,
+                                     "y2", h,
+                                     "width_pixels", 2,
+                                     "outline_color", "light blue",
+                                     NULL);
+       view->n_fg_items++;
+       view->fg_item_list = g_list_append (view->fg_item_list, item);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -470,7 +484,7 @@ static void
 draw_rounded_rect_bg (glView * view)
 {
        glLabel *label = view->label;
-       GnomeCanvasPoints *points;
+       GnomeCanvasPoints *label_points, *margin_points;
        gint i_coords, i_theta;
        glTemplate *template;
        gdouble r, w, h, m;
@@ -486,48 +500,51 @@ draw_rounded_rect_bg (glView * view)
 
        view->n_bg_items = 0;
        view->bg_item_list = NULL;
+       view->n_fg_items = 0;
+       view->fg_item_list = NULL;
 
        gl_label_get_size (label, &w, &h);
        template = gl_label_get_template (label);
        r = template->label_round;
        m = template->label_margin;
 
-       points = gnome_canvas_points_new (4 * (1 + 90 / 5));
+       label_points = gnome_canvas_points_new (4 * (1 + 90 / 5));
        i_coords = 0;
        for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    r - r * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    r - r * cos (i_theta * M_PI / 180.0);
        }
        for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    r - r * cos (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    (h - r) + r * sin (i_theta * M_PI / 180.0);
        }
        for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    (w - r) + r * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    (h - r) + r * cos (i_theta * M_PI / 180.0);
        }
        for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    (w - r) + r * cos (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
+               label_points->coords[i_coords++] =
                    r - r * sin (i_theta * M_PI / 180.0);
        }
+
+       /* Basic background */
        item = gnome_canvas_item_new (group,
                                      gnome_canvas_polygon_get_type (),
-                                     "points", points,
+                                     "points", label_points,
                                      "fill_color", "white",
                                      NULL);
-       gnome_canvas_points_free (points);
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
 
-       /* Bounding box @ margin */
+       /* Margin outline */
        if (template->label_margin >= template->label_round) {
                /* simple rectangle */
                item = gnome_canvas_item_new (group,
@@ -548,44 +565,56 @@ draw_rounded_rect_bg (glView * view)
                h = h - 2 * m;
 
                /* rectangle with rounded corners */
-               points = gnome_canvas_points_new (4 * (1 + 90 / 5));
+               margin_points = gnome_canvas_points_new (4 * (1 + 90 / 5));
                i_coords = 0;
                for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + r - r * sin (i_theta * M_PI / 180.0);
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + r - r * cos (i_theta * M_PI / 180.0);
                }
                for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + r - r * cos (i_theta * M_PI / 180.0);
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + (h - r) + r * sin (i_theta * M_PI / 180.0);
                }
                for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + (w - r) + r * sin (i_theta * M_PI / 180.0);
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + (h - r) + r * cos (i_theta * M_PI / 180.0);
                }
                for (i_theta = 0; i_theta <= 90; i_theta += 5) {
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + (w - r) + r * cos (i_theta * M_PI / 180.0);
-                       points->coords[i_coords++] =
+                       margin_points->coords[i_coords++] =
                            m + r - r * sin (i_theta * M_PI / 180.0);
                }
                item = gnome_canvas_item_new (group,
                                              gnome_canvas_polygon_get_type (),
-                                             "points", points,
+                                             "points", margin_points,
                                              "width_pixels", 1,
                                              "outline_color", "light blue",
                                              NULL);
-               gnome_canvas_points_free (points);
+               gnome_canvas_points_free (margin_points);
                view->n_bg_items++;
                view->bg_item_list =
                    g_list_append (view->bg_item_list, item);
        }
 
+       /* Foreground outline */
+       item = gnome_canvas_item_new (group,
+                                     gnome_canvas_polygon_get_type (),
+                                     "points", label_points,
+                                     "width_pixels", 2,
+                                     "outline_color", "light blue",
+                                     NULL);
+       view->n_fg_items++;
+       view->fg_item_list = g_list_append (view->fg_item_list, item);
+
+       gnome_canvas_points_free (label_points);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -597,9 +626,7 @@ draw_round_bg (glView * view)
 {
        glLabel *label = view->label;
        glTemplate *template;
-       GnomeCanvasPoints *points;
-       gint i_coords, i_theta;
-       gdouble r, r1;
+       gdouble r, m;
        GnomeCanvasItem *item;
        GnomeCanvasGroup *group;
 
@@ -614,44 +641,50 @@ draw_round_bg (glView * view)
 
        view->n_bg_items = 0;
        view->bg_item_list = NULL;
+       view->n_fg_items = 0;
+       view->fg_item_list = NULL;
 
-       r1 = template->label_radius;
-       points = gnome_canvas_points_new (1 + 360/2);
-       i_coords = 0;
-       for (i_theta = 0; i_theta <= 360; i_theta += 2) {
-               points->coords[i_coords++] =
-                   r1 - r1 * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
-                   r1 - r1 * cos (i_theta * M_PI / 180.0);
-       }
+       r = template->label_radius;
+       m = template->label_margin;
+
+       /* Basic background */
        item = gnome_canvas_item_new (group,
-                                     gnome_canvas_polygon_get_type (),
-                                     "points", points,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", 0.0,
+                                     "y1", 0.0,
+                                     "x2", 2.0*r,
+                                     "y2", 2.0*r,
                                      "fill_color", "white",
                                      NULL);
-       gnome_canvas_points_free (points);
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
 
-       /* Bounding box @ margin */
-       r = template->label_radius - template->label_margin;
-       points = gnome_canvas_points_new (360 / 2);
-       i_coords = 0;
-       for (i_theta = 0; i_theta < 360; i_theta += 2) {
-               points->coords[i_coords++] =
-                   r1 - r * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
-                   r1 - r * cos (i_theta * M_PI / 180.0);
-       }
+       /* Margin outline */
        item = gnome_canvas_item_new (group,
-                                     gnome_canvas_polygon_get_type (),
-                                     "points", points,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", m,
+                                     "y1", m,
+                                     "x2", 2.0*r - m,
+                                     "y2", 2.0*r - m,
                                      "width_pixels", 1,
                                      "outline_color", "light blue", NULL);
-       gnome_canvas_points_free (points);
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
 
+       /* Foreground outline */
+       r = template->label_radius;
+       item = gnome_canvas_item_new (group,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", 0.0,
+                                     "y1", 0.0,
+                                     "x2", 2.0*r,
+                                     "y2", 2.0*r,
+                                     "width_pixels", 2,
+                                     "outline_color", "light blue",
+                                     NULL);
+       view->n_fg_items++;
+       view->fg_item_list = g_list_append (view->fg_item_list, item);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
@@ -663,9 +696,7 @@ draw_cd_bg (glView * view)
 {
        glLabel *label = view->label;
        glTemplate *template;
-       GnomeCanvasPoints *points;
-       gint i_coords, i_theta;
-       gdouble r, r1, r2;
+       gdouble m, r1, r2;
        GnomeCanvasItem *item;
        GnomeCanvasGroup *group;
 
@@ -680,72 +711,88 @@ draw_cd_bg (glView * view)
 
        view->n_bg_items = 0;
        view->bg_item_list = NULL;
+       view->n_fg_items = 0;
+       view->fg_item_list = NULL;
 
        r1 = template->label_radius;
        r2 = template->label_hole;
-       points = gnome_canvas_points_new (2 * (1 + 360 / 2));
-       i_coords = 0;
-       for (i_theta = 0; i_theta <= 360; i_theta += 2) {
-               points->coords[i_coords++] =
-                   r1 - r1 * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
-                   r1 - r1 * cos (i_theta * M_PI / 180.0);
-       }
-       for (i_theta = 0; i_theta <= 360; i_theta += 2) {
-               points->coords[i_coords++] =
-                   r1 - r2 * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
-                   r1 - r2 * cos (i_theta * M_PI / 180.0);
-       }
+       m  = template->label_margin;
+
+       /* Basic background */
+       /* outer circle */
        item = gnome_canvas_item_new (group,
-                                     gnome_canvas_polygon_get_type (),
-                                     "points", points,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", 0.0,
+                                     "y1", 0.0,
+                                     "x2", 2.0*r1,
+                                     "y2", 2.0*r1,
                                      "fill_color", "white",
                                      NULL);
-       gnome_canvas_points_free (points);
+       view->n_bg_items++;
+       view->bg_item_list = g_list_append (view->bg_item_list, item);
+       /* hole */
+       item = gnome_canvas_item_new (group,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", r1 - r2,
+                                     "y1", r1 - r2,
+                                     "x2", r1 + r2,
+                                     "y2", r1 + r2,
+                                     "fill_color", "gray",
+                                     NULL);
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
 
-       /* Bounding box @ margin */
+       /* Margin outline */
        /* outer margin */
-       r = template->label_radius - template->label_margin;
-       points = gnome_canvas_points_new (360 / 2);
-       i_coords = 0;
-       for (i_theta = 0; i_theta < 360; i_theta += 2) {
-               points->coords[i_coords++] =
-                   r1 - r * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
-                   r1 - r * cos (i_theta * M_PI / 180.0);
-       }
        item = gnome_canvas_item_new (group,
-                                     gnome_canvas_polygon_get_type (),
-                                     "points", points,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", m,
+                                     "y1", m,
+                                     "x2", 2.0*r1 - m,
+                                     "y2", 2.0*r1 - m,
                                      "width_pixels", 1,
                                      "outline_color", "light blue", NULL);
-       gnome_canvas_points_free (points);
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
-
        /* inner margin */
-       r = template->label_hole + template->label_margin;
-       points = gnome_canvas_points_new (360 / 2);
-       i_coords = 0;
-       for (i_theta = 0; i_theta < 360; i_theta += 2) {
-               points->coords[i_coords++] =
-                   r1 - r * sin (i_theta * M_PI / 180.0);
-               points->coords[i_coords++] =
-                   r1 - r * cos (i_theta * M_PI / 180.0);
-       }
        item = gnome_canvas_item_new (group,
-                                     gnome_canvas_polygon_get_type (),
-                                     "points", points,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", r1 - r2 - m,
+                                     "y1", r1 - r2 - m,
+                                     "x2", r1 + r2 + m,
+                                     "y2", r1 + r2 + m,
                                      "width_pixels", 1,
                                      "outline_color", "light blue",
                                      NULL);
-       gnome_canvas_points_free (points);
        view->n_bg_items++;
        view->bg_item_list = g_list_append (view->bg_item_list, item);
 
+       /* Foreground outline */
+       /* outer circle */
+       item = gnome_canvas_item_new (group,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", 0.0,
+                                     "y1", 0.0,
+                                     "x2", 2.0*r1,
+                                     "y2", 2.0*r1,
+                                     "width_pixels", 2,
+                                     "outline_color", "light blue",
+                                     NULL);
+       view->n_fg_items++;
+       view->fg_item_list = g_list_append (view->fg_item_list, item);
+       /* hole */
+       item = gnome_canvas_item_new (group,
+                                     gnome_canvas_ellipse_get_type (),
+                                     "x1", r1 - r2,
+                                     "y1", r1 - r2,
+                                     "x2", r1 + r2,
+                                     "y2", r1 + r2,
+                                     "width_pixels", 2,
+                                     "outline_color", "light blue",
+                                     NULL);
+       view->n_fg_items++;
+       view->fg_item_list = g_list_append (view->fg_item_list, item);
+
        gl_debug (DEBUG_VIEW, "END");
 }
 
index 813c084265f5d3caaa8bc450aec2c5be99e00f9a..18777f44479af441c3243b47f0fd7e6086910971 100644 (file)
@@ -53,6 +53,8 @@ struct _glView {
        gdouble scale;
        gint n_bg_items;
        GList *bg_item_list;
+       gint n_fg_items;
+       GList *fg_item_list;
 
        glViewState state;
        glLabelObjectType create_type;