From: Jim Evins Date: Fri, 17 Feb 2006 03:03:53 +0000 (+0000) Subject: 2006-02-16 Jim Evins X-Git-Tag: glabels-2_3_0~380 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=dbcb557b5640362136324341b71a8d05ea87a476;p=glabels 2006-02-16 Jim Evins * src/view-box.c: Comment changes. * src/print.c: (draw_ellipse_object): * src/view-ellipse.c: (gl_view_ellipse_new), (construct_properties_editor), (update_canvas_item_from_object_cb), (update_object_from_editor_cb), (update_editor_from_object_cb), (update_editor_from_label_cb): Added shadow support to ellipse object. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@585 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index eb8d7278..f0241063 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,14 @@ +2006-02-16 Jim Evins + + * src/view-box.c: + Comment changes. + * src/print.c: (draw_ellipse_object): + * src/view-ellipse.c: (gl_view_ellipse_new), + (construct_properties_editor), (update_canvas_item_from_object_cb), + (update_object_from_editor_cb), (update_editor_from_object_cb), + (update_editor_from_label_cb): + Added shadow support to ellipse object. + 2006-02-15 Jim Evins * src/label-object.c: diff --git a/glabels2/src/print.c b/glabels2/src/print.c index eef6ec97..c2c3738b 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -5,7 +5,7 @@ * * print.c: Print module * - * Copyright (C) 2001 Jim Evins . + * Copyright (C) 2001-2006 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1017,6 +1017,12 @@ draw_ellipse_object (PrintInfo *pi, glColorNode *fill_color_node; guint line_color; guint fill_color; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + guint shadow_line_color; + guint shadow_fill_color; gl_debug (DEBUG_PRINT, "START"); @@ -1035,6 +1041,40 @@ draw_ellipse_object (PrintInfo *pi, x0 = rx; y0 = ry; + shadow_state = gl_label_object_get_shadow_state (GL_LABEL_OBJECT (object)); + gl_label_object_get_shadow_offset (GL_LABEL_OBJECT (object), &shadow_x, &shadow_y); + shadow_color_node = gl_label_object_get_shadow_color (GL_LABEL_OBJECT (object)); + if (shadow_color_node->field_flag) + { + shadow_color_node->color = GL_COLOR_SHADOW_MERGE_DEFAULT; + } + shadow_opacity = gl_label_object_get_shadow_opacity (GL_LABEL_OBJECT (object)); + shadow_line_color = gl_color_shadow (shadow_color_node->color, shadow_opacity, line_color); + shadow_fill_color = gl_color_shadow (shadow_color_node->color, shadow_opacity, fill_color); + gl_color_node_free (&shadow_color_node); + + if (shadow_state) + { + /* Draw fill shadow */ + create_ellipse_path (pi->pc, x0+shadow_x, y0+shadow_y, rx, ry); + gnome_print_setrgbcolor (pi->pc, + GL_COLOR_F_RED (shadow_fill_color), + GL_COLOR_F_GREEN (shadow_fill_color), + GL_COLOR_F_BLUE (shadow_fill_color)); + gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_fill_color)); + gnome_print_fill (pi->pc); + + /* Draw outline shadow */ + create_ellipse_path (pi->pc, x0+shadow_x, y0+shadow_y, rx, ry); + gnome_print_setrgbcolor (pi->pc, + GL_COLOR_F_RED (shadow_line_color), + GL_COLOR_F_GREEN (shadow_line_color), + GL_COLOR_F_BLUE (shadow_line_color)); + gnome_print_setopacity (pi->pc, GL_COLOR_F_ALPHA (shadow_line_color)); + gnome_print_setlinewidth (pi->pc, line_width); + gnome_print_stroke (pi->pc); + } + /* Paint fill color */ create_ellipse_path (pi->pc, x0, y0, rx, ry); gnome_print_setrgbcolor (pi->pc, diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index 46a9a7b6..35245a6a 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -1,3 +1,5 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * diff --git a/glabels2/src/view-ellipse.c b/glabels2/src/view-ellipse.c index e31286ff..bcbfef33 100644 --- a/glabels2/src/view-ellipse.c +++ b/glabels2/src/view-ellipse.c @@ -1,9 +1,11 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ + /* * (GLABELS) Label and Business Card Creation program for GNOME * * view_ellipse.c: GLabels label ellipse object widget * - * Copyright (C) 2001-2003 Jim Evins . + * Copyright (C) 2001-2006 Jim Evins . * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +49,8 @@ /*========================================================*/ struct _glViewEllipsePrivate { - GnomeCanvasItem *item; + GnomeCanvasItem *object_item; + GnomeCanvasItem *shadow_item; }; /*========================================================*/ @@ -164,12 +167,9 @@ gl_view_ellipse_new (glLabelEllipse *object, glView *view) { glViewEllipse *view_ellipse; - gdouble line_width; - glColorNode *line_color_node; - gdouble w, h; - glColorNode *fill_color_node; gl_debug (DEBUG_VIEW, "START"); + g_return_if_fail (object && GL_IS_LABEL_ELLIPSE (object)); g_return_if_fail (view && GL_IS_VIEW (view)); @@ -180,36 +180,17 @@ gl_view_ellipse_new (glLabelEllipse *object, GL_LABEL_OBJECT(object), GL_VIEW_HIGHLIGHT_ELLIPSE_RESIZABLE); - /* Query properties of object. */ - gl_label_object_get_size (GL_LABEL_OBJECT(object), &w, &h); - line_width = gl_label_object_get_line_width(GL_LABEL_OBJECT(object)); - line_color_node = gl_label_object_get_line_color(GL_LABEL_OBJECT(object)); - if (line_color_node->field_flag) - { - line_color_node->color = GL_COLOR_MERGE_DEFAULT; - } - fill_color_node = gl_label_object_get_fill_color(GL_LABEL_OBJECT(object)); - if (fill_color_node->field_flag) - { - fill_color_node->color = GL_COLOR_FILL_MERGE_DEFAULT; - } - - /* Create analogous canvas item. */ - view_ellipse->private->item = + /* Create analogous canvas items. */ + view_ellipse->private->shadow_item = + gl_view_object_item_new (GL_VIEW_OBJECT(view_ellipse), + gnome_canvas_ellipse_get_type (), + NULL); + view_ellipse->private->object_item = gl_view_object_item_new (GL_VIEW_OBJECT(view_ellipse), gnome_canvas_ellipse_get_type (), - "x1", 0.0, - "y1", 0.0, - "x2", w + DELTA, - "y2", h + DELTA, - "width_units", line_width, - "outline_color_rgba", line_color_node->color, - "fill_color_rgba", fill_color_node->color, NULL); + update_canvas_item_from_object_cb (GL_LABEL_OBJECT(object), view_ellipse); - gl_color_node_free (&line_color_node); - gl_color_node_free (&fill_color_node); - g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_canvas_item_from_object_cb), view_ellipse); @@ -238,6 +219,7 @@ construct_properties_editor (glViewObject *view_object) GL_OBJECT_EDITOR_SIZE_PAGE, GL_OBJECT_EDITOR_FILL_PAGE, GL_OBJECT_EDITOR_LINE_PAGE, + GL_OBJECT_EDITOR_SHADOW_PAGE, 0); /* Update */ @@ -273,6 +255,12 @@ update_canvas_item_from_object_cb (glLabelObject *object, glColorNode *line_color_node; gdouble w, h; glColorNode *fill_color_node; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + guint shadow_line_color; + guint shadow_fill_color; gl_debug (DEBUG_VIEW, "START"); @@ -289,9 +277,42 @@ update_canvas_item_from_object_cb (glLabelObject *object, { fill_color_node->color = GL_COLOR_FILL_MERGE_DEFAULT; } + shadow_state = gl_label_object_get_shadow_state (GL_LABEL_OBJECT (object)); + gl_label_object_get_shadow_offset (GL_LABEL_OBJECT (object), &shadow_x, &shadow_y); + shadow_color_node = gl_label_object_get_shadow_color (GL_LABEL_OBJECT (object)); + if (shadow_color_node->field_flag) + { + shadow_color_node->color = GL_COLOR_SHADOW_MERGE_DEFAULT; + } + shadow_opacity = gl_label_object_get_shadow_opacity (GL_LABEL_OBJECT (object)); + shadow_line_color = gl_color_shadow (shadow_color_node->color, + shadow_opacity, + line_color_node->color); + shadow_fill_color = gl_color_shadow (shadow_color_node->color, + shadow_opacity, + fill_color_node->color); + + /* Adjust appearance of analogous canvas items. */ + gnome_canvas_item_set (view_ellipse->private->shadow_item, + "x1", shadow_x, + "y1", shadow_y, + "x2", shadow_x + w + DELTA, + "y2", shadow_y + h + DELTA, + "width_units", line_width, + "outline_color_rgba", shadow_line_color, + "fill_color_rgba", shadow_fill_color, + NULL); - /* Adjust appearance of analogous canvas item. */ - gnome_canvas_item_set (view_ellipse->private->item, + if (shadow_state) + { + gnome_canvas_item_show (view_ellipse->private->shadow_item); + } + else + { + gnome_canvas_item_hide (view_ellipse->private->shadow_item); + } + + gnome_canvas_item_set (view_ellipse->private->object_item, "x2", w + DELTA, "y2", h + DELTA, "width_units", line_width, @@ -301,6 +322,7 @@ update_canvas_item_from_object_cb (glLabelObject *object, gl_color_node_free (&line_color_node); gl_color_node_free (&fill_color_node); + gl_color_node_free (&shadow_color_node); gl_debug (DEBUG_VIEW, "END"); } @@ -316,7 +338,11 @@ update_object_from_editor_cb (glObjectEditor *editor, glColorNode *line_color_node; gdouble line_width; glColorNode *fill_color_node; - glMerge *merge; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + gl_debug (DEBUG_VIEW, "START"); @@ -327,7 +353,6 @@ update_object_from_editor_cb (glObjectEditor *editor, update_editor_from_move_cb, editor); - gl_object_editor_get_position (editor, &x, &y); gl_label_object_set_position (object, x, y); @@ -345,6 +370,18 @@ update_object_from_editor_cb (glObjectEditor *editor, line_width = gl_object_editor_get_line_width (editor); gl_label_object_set_line_width (object, line_width); + shadow_state = gl_object_editor_get_shadow_state (editor); + gl_label_object_set_shadow_state (object, shadow_state); + + gl_object_editor_get_shadow_offset (editor, &shadow_x, &shadow_y); + gl_label_object_set_shadow_offset (object, shadow_x, shadow_y); + + shadow_color_node = gl_object_editor_get_shadow_color (editor); + gl_label_object_set_shadow_color (object, shadow_color_node); + gl_color_node_free (&shadow_color_node); + + shadow_opacity = gl_object_editor_get_shadow_opacity (editor); + gl_label_object_set_shadow_opacity (object, shadow_opacity); g_signal_handlers_unblock_by_func (G_OBJECT(object), update_editor_from_object_cb, @@ -367,6 +404,10 @@ update_editor_from_object_cb (glLabelObject *object, glColorNode *line_color_node; gdouble line_width; glColorNode *fill_color_node; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; glMerge *merge; gl_debug (DEBUG_VIEW, "START"); @@ -386,6 +427,19 @@ update_editor_from_object_cb (glLabelObject *object, line_width = gl_label_object_get_line_width (GL_LABEL_OBJECT(object)); gl_object_editor_set_line_width (editor, line_width); + shadow_state = gl_label_object_get_shadow_state (object); + gl_object_editor_set_shadow_state (editor, shadow_state); + + gl_label_object_get_shadow_offset (object, &shadow_x, &shadow_y); + gl_object_editor_set_shadow_offset (editor, shadow_x, shadow_y); + + shadow_color_node = gl_label_object_get_shadow_color (object); + gl_object_editor_set_shadow_color (editor, (merge != NULL), shadow_color_node); + gl_color_node_free (&shadow_color_node); + + shadow_opacity = gl_label_object_get_shadow_opacity (object); + gl_object_editor_set_shadow_opacity (editor, shadow_opacity); + gl_debug (DEBUG_VIEW, "END"); } @@ -425,6 +479,8 @@ update_editor_from_label_cb (glLabel *label, label_width, label_height); gl_object_editor_set_max_size (GL_OBJECT_EDITOR (editor), label_width, label_height); + gl_object_editor_set_max_shadow_offset (GL_OBJECT_EDITOR (editor), + label_width, label_height); merge = gl_label_get_merge (label); gl_object_editor_set_key_names (editor, merge);