From 5cc9f150f427f0b4e9cb70bd1b5a3cbd1818418d Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Sat, 18 Feb 2006 05:20:44 +0000 Subject: [PATCH] 2006-02-18 Jim Evins * src/print.c: (draw_line_object): * src/view-line.c: (gl_view_line_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 line object. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@586 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 9 +++ glabels2/src/print.c | 29 ++++++++++ glabels2/src/view-line.c | 117 +++++++++++++++++++++++++++++---------- 3 files changed, 127 insertions(+), 28 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index f0241063..beb704fd 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,12 @@ +2006-02-18 Jim Evins + + * src/print.c: (draw_line_object): + * src/view-line.c: (gl_view_line_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 line object. + 2006-02-16 Jim Evins * src/view-box.c: diff --git a/glabels2/src/print.c b/glabels2/src/print.c index c2c3738b..2827dede 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.c @@ -980,6 +980,11 @@ draw_line_object (PrintInfo *pi, gdouble line_width; guint line_color; glColorNode *line_color_node; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + guint shadow_line_color; gl_debug (DEBUG_PRINT, "START"); @@ -990,6 +995,30 @@ draw_line_object (PrintInfo *pi, line_color = gl_color_node_expand (line_color_node, record); gl_color_node_free (&line_color_node); + 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); + gl_color_node_free (&shadow_color_node); + + if (shadow_state) + { + gnome_print_moveto (pi->pc, shadow_x, shadow_y); + gnome_print_lineto (pi->pc, shadow_x + w, shadow_y + h); + 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); + } + gnome_print_moveto (pi->pc, 0.0, 0.0); gnome_print_lineto (pi->pc, w, h); gnome_print_setrgbcolor (pi->pc, diff --git a/glabels2/src/view-line.c b/glabels2/src/view-line.c index 10262510..02895fd3 100644 --- a/glabels2/src/view-line.c +++ b/glabels2/src/view-line.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_line.c: GLabels label line 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 @@ -45,7 +47,8 @@ /*========================================================*/ struct _glViewLinePrivate { - GnomeCanvasItem *item; + GnomeCanvasItem *object_item; + GnomeCanvasItem *shadow_item; }; /*========================================================*/ @@ -162,12 +165,9 @@ gl_view_line_new (glLabelLine *object, glView *view) { glViewLine *view_line; - gdouble line_width; - glColorNode *line_color_node; - gdouble w, h; - GnomeCanvasPoints *points; gl_debug (DEBUG_VIEW, "START"); + g_return_if_fail (object && GL_IS_LABEL_LINE (object)); g_return_if_fail (view && GL_IS_VIEW (view)); @@ -178,30 +178,16 @@ gl_view_line_new (glLabelLine *object, GL_LABEL_OBJECT(object), GL_VIEW_HIGHLIGHT_LINE_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; - } - /* Create analogous canvas item. */ - points = gnome_canvas_points_new (2); - points->coords[0] = 0.0; - points->coords[1] = 0.0; - points->coords[2] = w; - points->coords[3] = h; - view_line->private->item = + view_line->private->shadow_item = gl_view_object_item_new (GL_VIEW_OBJECT(view_line), gnome_canvas_line_get_type (), - "points", points, - "width_units", line_width, - "fill_color_rgba", line_color_node->color, NULL); - gl_color_node_free (&line_color_node); - gnome_canvas_points_free (points); + view_line->private->object_item = + gl_view_object_item_new (GL_VIEW_OBJECT(view_line), + gnome_canvas_line_get_type (), + NULL); + update_canvas_item_from_object_cb (GL_LABEL_OBJECT(object), view_line); g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_canvas_item_from_object_cb), view_line); @@ -230,6 +216,7 @@ construct_properties_editor (glViewObject *view_object) GL_OBJECT_EDITOR_POSITION_PAGE, GL_OBJECT_EDITOR_SIZE_LINE_PAGE, GL_OBJECT_EDITOR_LINE_PAGE, + GL_OBJECT_EDITOR_SHADOW_PAGE, 0); /* Update */ @@ -265,6 +252,11 @@ update_canvas_item_from_object_cb (glLabelObject *object, glColorNode *line_color_node; gdouble w, h; GnomeCanvasPoints *points; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + guint shadow_line_color; gl_debug (DEBUG_VIEW, "START"); @@ -276,21 +268,54 @@ update_canvas_item_from_object_cb (glLabelObject *object, { line_color_node->color = GL_COLOR_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); /* Adjust appearance of analogous canvas item. */ points = gnome_canvas_points_new (2); + points->coords[0] = shadow_x; + points->coords[1] = shadow_y; + points->coords[2] = shadow_x + w; + points->coords[3] = shadow_y + h; + gnome_canvas_item_set (view_line->private->shadow_item, + "points", points, + "width_units", line_width, + "fill_color_rgba", shadow_line_color, + NULL); + + if (shadow_state) + { + gnome_canvas_item_show (view_line->private->shadow_item); + } + else + { + gnome_canvas_item_hide (view_line->private->shadow_item); + } + points->coords[0] = 0.0; points->coords[1] = 0.0; points->coords[2] = w; points->coords[3] = h; - gnome_canvas_item_set (view_line->private->item, + gnome_canvas_item_set (view_line->private->object_item, "points", points, "width_units", line_width, "fill_color_rgba", line_color_node->color, NULL); - gl_color_node_free (&line_color_node); + gnome_canvas_points_free (points); + gl_color_node_free (&line_color_node); + gl_color_node_free (&shadow_color_node); + gl_debug (DEBUG_VIEW, "END"); } @@ -304,6 +329,10 @@ update_object_from_editor_cb (glObjectEditor *editor, gdouble x, y, w, h; glColorNode *line_color_node; gdouble line_width; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; gl_debug (DEBUG_VIEW, "START"); @@ -328,6 +357,19 @@ 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, @@ -349,6 +391,10 @@ update_editor_from_object_cb (glLabelObject *object, gdouble w, h; glColorNode *line_color_node; gdouble line_width; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; glMerge *merge; gl_debug (DEBUG_VIEW, "START"); @@ -365,6 +411,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"); } @@ -404,6 +463,8 @@ update_editor_from_label_cb (glLabel *label, label_width, label_height); gl_object_editor_set_max_lsize (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); -- 2.39.5