From 40e256fa0bafd52f616ee3c6696efe6702d256f9 Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Fri, 20 Jan 2006 03:38:08 +0000 Subject: [PATCH] 2006-01-19 Jim Evins * src/merge-evolution.c: (gl_merge_evolution_get_key_list): Initialize key_list to NULL. Only lucky that this worked at all -- will probably crash for many people. * data/glade/object-editor.glade: * src/Makefile.am: * src/color.c: * src/color.h: * src/label-object.c: * src/label-object.h: * src/object-editor-fill-page.c: * src/object-editor-private.h: * src/object-editor.c: * src/object-editor.h: * src/xml-label.c: Created infrastructure for shadow support. * src/view-box.c: * src/print.c: Initial shadow support in box object only. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@581 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 20 + glabels2/data/glade/object-editor.glade | 498 ++++++++++++++++++++++++ glabels2/src/Makefile.am | 1 + glabels2/src/color.c | 16 + glabels2/src/color.h | 11 +- glabels2/src/label-object.c | 182 ++++++++- glabels2/src/label-object.h | 24 ++ glabels2/src/merge-evolution.c | 3 +- glabels2/src/object-editor-fill-page.c | 2 +- glabels2/src/object-editor-private.h | 18 + glabels2/src/object-editor.c | 191 ++++----- glabels2/src/object-editor.h | 34 ++ glabels2/src/print.c | 48 ++- glabels2/src/view-box.c | 116 +++++- glabels2/src/xml-label.c | 273 ++++++++----- 15 files changed, 1231 insertions(+), 206 deletions(-) diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index e345e10f..a8f2997c 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,23 @@ +2006-01-19 Jim Evins + + * src/merge-evolution.c: (gl_merge_evolution_get_key_list): + Initialize key_list to NULL. + * data/glade/object-editor.glade: + * src/Makefile.am: + * src/color.c: + * src/color.h: + * src/label-object.c: + * src/label-object.h: + * src/object-editor-fill-page.c: + * src/object-editor-private.h: + * src/object-editor.c: + * src/object-editor.h: + * src/xml-label.c: + Created infrastructure for shadow support. + * src/view-box.c: + * src/print.c: + Initial shadow support in box object only. + 2006-01-05 Jim Evins * src/merge-properties-dialog.c: (src_changed_cb): diff --git a/glabels2/data/glade/object-editor.glade b/glabels2/data/glade/object-editor.glade index 386e96fd..4b93983f 100644 --- a/glabels2/data/glade/object-editor.glade +++ b/glabels2/data/glade/object-editor.glade @@ -2895,6 +2895,504 @@ tab + + + + 12 + True + False + 12 + + + + True + True + Enable shadow + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + 4 + 2 + False + 12 + 12 + + + + True + X Offset: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 0 + 1 + fill + + + + + + + True + Y Offset: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 1 + 2 + fill + + + + + + + True + Opacity: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 3 + 4 + fill + + + + + + + True + False + 12 + + + + True + True + 0.00999999977648 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 0 0 100 0.00999999977648 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 1 + 2 + 1 + 2 + fill + fill + + + + + + True + False + 12 + + + + True + True + 1 + 0 + False + GTK_UPDATE_ALWAYS + False + False + 1 0 100 1 10 10 + + + 0 + False + True + + + + + + True + % + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 1 + 2 + 3 + 4 + fill + fill + + + + + + True + Color: + False + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.140000000596 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + 1 + 2 + 3 + fill + fill + + + + + + True + False + 6 + + + + True + False + 6 + + + + True + True + + True + GTK_RELIEF_NORMAL + True + False + False + True + + + 0 + False + False + + + + + + True + False + 12 + + + + True + gl_object_editor_construct_color_combo + 2 + 0 + Sun, 16 Nov 2003 06:52:23 GMT + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + True + False + 6 + + + + True + True + Key: + True + GTK_RELIEF_NORMAL + True + False + False + True + shadow_color_radio + + + 0 + False + False + + + + + + True + False + 12 + + + + True + False + True + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 1 + 2 + 2 + 3 + fill + + + + + + True + False + 12 + + + + True + True + 0.00999999977648 + 2 + True + GTK_UPDATE_ALWAYS + True + False + 0 0 100 0.00999999977648 10 10 + + + 0 + False + True + + + + + + True + inches + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + 1 + 2 + 0 + 1 + fill + fill + + + + + 0 + True + True + + + + + False + True + + + + + + True + Shadow + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + tab + + 0 diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index 23b729fa..33fd13ce 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -105,6 +105,7 @@ glabels_SOURCES = \ object-editor-edit-page.c \ object-editor-bc-page.c \ object-editor-data-page.c \ + object-editor-shadow-page.c \ print.c \ print.h \ print-dialog.c \ diff --git a/glabels2/src/color.c b/glabels2/src/color.c index 7004fef2..38d40a95 100644 --- a/glabels2/src/color.c +++ b/glabels2/src/color.c @@ -69,6 +69,22 @@ gl_color_from_gdk_color (GdkColor *gdk_color) return color; } +/*****************************************************************************/ +/* Resolve actual shadow color by adjusting opacity. */ +/*****************************************************************************/ +guint +gl_color_shadow (guint base_color, + gdouble opacity, + guint object_color) +{ + guint color; + + color = gl_color_set_opacity (base_color, + opacity * GL_COLOR_F_ALPHA (object_color)); + + return color; +} + /****************************************************************************/ /* Create a single color node with default color. */ /****************************************************************************/ diff --git a/glabels2/src/color.h b/glabels2/src/color.h index 65f8b027..9fa55df0 100644 --- a/glabels2/src/color.h +++ b/glabels2/src/color.h @@ -37,9 +37,10 @@ typedef struct { #define GL_COLOR(r,g,b) GNOME_CANVAS_COLOR(r,g,b) #define GL_COLOR_A(r,g,b,a) GNOME_CANVAS_COLOR_A(r,g,b,a) -#define GL_COLOR_NONE GL_COLOR_A(0,0,0,0) -#define GL_COLOR_FILL_MERGE_DEFAULT GL_COLOR_A(255,255,255,128) -#define GL_COLOR_MERGE_DEFAULT GL_COLOR_A(0,0,0,128) +#define GL_COLOR_NONE GL_COLOR_A(0,0,0,0) +#define GL_COLOR_FILL_MERGE_DEFAULT GL_COLOR_A(255,255,255,128) +#define GL_COLOR_MERGE_DEFAULT GL_COLOR_A(0,0,0,128) +#define GL_COLOR_SHADOW_MERGE_DEFAULT GL_COLOR_A(0,0,0,255) #define GL_COLOR_I_RED(x) (((x)>>24) & 0xff) #define GL_COLOR_I_GREEN(x) (((x)>>16) & 0xff) @@ -56,6 +57,10 @@ guint gl_color_set_opacity (guint color, gdouble opacity); GdkColor *gl_color_to_gdk_color (guint color); guint gl_color_from_gdk_color (GdkColor *gdk_color); +guint gl_color_shadow (guint base_color, + gdouble opacity, + guint object_color); + glColorNode *gl_color_node_new_default (); glColorNode *gl_color_node_dup (glColorNode *color_node); diff --git a/glabels2/src/label-object.c b/glabels2/src/label-object.c index 36076652..f091213a 100644 --- a/glabels2/src/label-object.c +++ b/glabels2/src/label-object.c @@ -32,6 +32,15 @@ #include "debug.h" + +/*========================================================*/ +/* Private defines. */ +/*========================================================*/ + +#define DEFAULT_SHADOW_X_OFFSET (5.0) +#define DEFAULT_SHADOW_Y_OFFSET (5.0) +#define DEFAULT_SHADOW_OPACITY (0.5) + /*========================================================*/ /* Private types. */ /*========================================================*/ @@ -43,6 +52,12 @@ struct _glLabelObjectPrivate { gdouble affine[6]; gdouble aspect_ratio; + + gboolean shadow_state; + gdouble shadow_x; + gdouble shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; }; enum { @@ -190,6 +205,12 @@ gl_label_object_instance_init (glLabelObject *object) art_affine_identity (object->private->affine); + object->private->shadow_state = FALSE; + object->private->shadow_x = DEFAULT_SHADOW_X_OFFSET; + object->private->shadow_y = DEFAULT_SHADOW_Y_OFFSET; + object->private->shadow_color_node = gl_color_node_new_default (); + object->private->shadow_opacity = DEFAULT_SHADOW_OPACITY; + gl_debug (DEBUG_LABEL, "END"); } @@ -242,6 +263,10 @@ gl_label_object_dup (glLabelObject *src_object, glLabelObject *dst_object; gdouble x, y, w, h; gdouble affine[6]; + gboolean shadow_state; + gdouble shadow_x, shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; gl_debug (DEBUG_LABEL, "START"); @@ -251,13 +276,23 @@ gl_label_object_dup (glLabelObject *src_object, gl_label_object_set_parent (dst_object, label); - gl_label_object_get_position (src_object, &x, &y); - gl_label_object_get_size (src_object, &w, &h); - gl_label_object_get_affine (src_object, affine); + gl_label_object_get_position (src_object, &x, &y); + gl_label_object_get_size (src_object, &w, &h); + gl_label_object_get_affine (src_object, affine); + gl_label_object_get_shadow_offset (src_object, &shadow_x, &shadow_y); + shadow_color_node = gl_label_object_get_shadow_color (src_object); + shadow_opacity = gl_label_object_get_shadow_opacity (src_object); + shadow_state = gl_label_object_get_shadow_state (src_object); gl_label_object_set_position (dst_object, x, y); gl_label_object_set_size (dst_object, w, h); gl_label_object_set_affine (dst_object, affine); + gl_label_object_set_shadow_offset (dst_object, shadow_x, shadow_y); + gl_label_object_set_shadow_color (dst_object, shadow_color_node); + gl_label_object_set_shadow_opacity (dst_object, shadow_opacity); + gl_label_object_set_shadow_state (dst_object, shadow_state); + + gl_color_node_free (&shadow_color_node); if ( GL_LABEL_OBJECT_GET_CLASS(src_object)->copy != NULL ) { @@ -1143,6 +1178,147 @@ gl_label_object_get_line_width (glLabelObject *object) return ret; } +/****************************************************************************/ +/* Set shadow state of object. */ +/****************************************************************************/ +void +gl_label_object_set_shadow_state (glLabelObject *object, + gboolean state) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + if (object->private->shadow_state != state) + { + object->private->shadow_state = state; + gl_label_object_emit_changed (object); + } + + gl_debug (DEBUG_LABEL, "END"); +} + +/****************************************************************************/ +/* Get shadow state of object. */ +/****************************************************************************/ +gboolean +gl_label_object_get_shadow_state (glLabelObject *object) +{ + gl_debug (DEBUG_LABEL, ""); + + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), FALSE); + + return object->private->shadow_state; +} + +/****************************************************************************/ +/* Set offset of object's shadow. */ +/****************************************************************************/ +void +gl_label_object_set_shadow_offset (glLabelObject *object, + gdouble x, + gdouble y) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + if ( (x != object->private->shadow_x) || (y != object->private->shadow_y) ) + { + object->private->shadow_x = x; + object->private->shadow_y = y; + + gl_label_object_emit_changed (object); + } + + gl_debug (DEBUG_LABEL, "END"); +} + +/****************************************************************************/ +/* Get offset of object's shadow. */ +/****************************************************************************/ +void +gl_label_object_get_shadow_offset (glLabelObject *object, + gdouble *x, + gdouble *y) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + *x = object->private->shadow_x; + *y = object->private->shadow_y; + + gl_debug (DEBUG_LABEL, "END"); +} + +/****************************************************************************/ +/* Set color of object's shadow. */ +/****************************************************************************/ +void +gl_label_object_set_shadow_color (glLabelObject *object, + glColorNode *color_node) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + if ( !gl_color_node_equal (object->private->shadow_color_node, color_node )) + { + gl_color_node_free (&(object->private->shadow_color_node)); + object->private->shadow_color_node = gl_color_node_dup (color_node); + gl_label_object_emit_changed (GL_LABEL_OBJECT(object)); + } + + gl_debug (DEBUG_LABEL, "END"); +} + +/****************************************************************************/ +/* Get color of object's shadow. */ +/****************************************************************************/ +glColorNode* +gl_label_object_get_shadow_color (glLabelObject *object) +{ + gl_debug (DEBUG_LABEL, ""); + + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), NULL); + + return gl_color_node_dup (object->private->shadow_color_node); +} + +/****************************************************************************/ +/* Set opacity of object's shadow. */ +/****************************************************************************/ +void +gl_label_object_set_shadow_opacity (glLabelObject *object, + gdouble alpha) +{ + gl_debug (DEBUG_LABEL, "START"); + + g_return_if_fail (object && GL_IS_LABEL_OBJECT (object)); + + if (object->private->shadow_opacity != alpha) + { + object->private->shadow_opacity = alpha; + gl_label_object_emit_changed (object); + } + + gl_debug (DEBUG_LABEL, "END"); +} + +/****************************************************************************/ +/* Get opacity of object's shadow. */ +/****************************************************************************/ +gdouble +gl_label_object_get_shadow_opacity (glLabelObject *object) +{ + gl_debug (DEBUG_LABEL, ""); + + g_return_val_if_fail (object && GL_IS_LABEL_OBJECT (object), FALSE); + + return object->private->shadow_opacity; +} + /****************************************************************************/ /* Flip object horizontally. */ /****************************************************************************/ diff --git a/glabels2/src/label-object.h b/glabels2/src/label-object.h index 810f6bd7..8464118e 100644 --- a/glabels2/src/label-object.h +++ b/glabels2/src/label-object.h @@ -293,6 +293,30 @@ void gl_label_object_get_i2w_affine (glLabelObject *object, void gl_label_object_get_w2i_affine (glLabelObject *object, gdouble affine[6]); +void gl_label_object_set_shadow_state (glLabelObject *object, + gboolean state); + +void gl_label_object_set_shadow_offset (glLabelObject *object, + gdouble x, + gdouble y); + +void gl_label_object_set_shadow_color (glLabelObject *object, + glColorNode *color_node); + +void gl_label_object_set_shadow_opacity (glLabelObject *object, + gdouble alpha); + +gboolean gl_label_object_get_shadow_state (glLabelObject *object); + +void gl_label_object_get_shadow_offset (glLabelObject *object, + gdouble *x, + gdouble *y); + +glColorNode* gl_label_object_get_shadow_color (glLabelObject *object); + +gdouble gl_label_object_get_shadow_opacity (glLabelObject *object); + + G_END_DECLS #endif /* __LABEL_OBJECT_H__ */ diff --git a/glabels2/src/merge-evolution.c b/glabels2/src/merge-evolution.c index a8c31c27..30efb897 100644 --- a/glabels2/src/merge-evolution.c +++ b/glabels2/src/merge-evolution.c @@ -253,7 +253,8 @@ static GList * gl_merge_evolution_get_key_list (glMerge *merge) { glMergeEvolution *merge_evolution; - GList *key_list, *iter; + GList *key_list = NULL; + GList *iter; gl_debug (DEBUG_MERGE, "BEGIN"); diff --git a/glabels2/src/object-editor-fill-page.c b/glabels2/src/object-editor-fill-page.c index a09532b1..52a38b64 100644 --- a/glabels2/src/object-editor-fill-page.c +++ b/glabels2/src/object-editor-fill-page.c @@ -83,7 +83,7 @@ gl_object_editor_prepare_fill_page (glObjectEditor *editor) /* Modify widgets based on configuration */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->fill_color_radio), TRUE); gtk_widget_set_sensitive (editor->priv->fill_color_combo, TRUE); - gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE); + gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE); gdk_color = gl_color_to_gdk_color (gl_prefs->default_fill_color); color_combo_set_color (COLOR_COMBO(editor->priv->fill_color_combo), gdk_color); g_free (gdk_color); diff --git a/glabels2/src/object-editor-private.h b/glabels2/src/object-editor-private.h index acb5045c..a927bc2c 100644 --- a/glabels2/src/object-editor-private.h +++ b/glabels2/src/object-editor-private.h @@ -131,6 +131,24 @@ struct _glObjectEditorPrivate { GtkWidget *data_digits_label; GtkWidget *data_digits_spin; gboolean data_format_fixed_flag; + + GtkWidget *shadow_page_vbox; + GtkWidget *shadow_enable_check; + GtkWidget *shadow_controls_table; + GtkWidget *shadow_x_spin; + GtkWidget *shadow_y_spin; + GtkWidget *shadow_x_units_label; + GtkWidget *shadow_y_units_label; + GtkWidget *shadow_color_radio; + GtkWidget *shadow_key_radio; + GtkWidget *shadow_color_combo; + GtkWidget *shadow_key_combo; + GtkWidget *shadow_opacity_spin; + gdouble shadow_x; + gdouble shadow_y; + gdouble shadow_x_max; + gdouble shadow_y_max; + }; enum { diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index 2290d764..ca82cf20 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -325,6 +325,11 @@ gl_object_notebook_construct_valist (glObjectEditor *editor, pages++; break; + case GL_OBJECT_EDITOR_SHADOW_PAGE: + gl_object_editor_prepare_shadow_page (editor); + pages++; + break; + default: g_message ("option = %d", option); g_assert_not_reached (); @@ -380,6 +385,7 @@ gl_object_editor_set_key_names (glObjectEditor *editor, GList *keys; GtkWidget *combo; gboolean fixed_flag; + gboolean state; gl_debug (DEBUG_EDITOR, "START"); @@ -396,18 +402,21 @@ gl_object_editor_set_key_names (glObjectEditor *editor, merge != NULL); } - if (editor->priv->text_color_key_combo) { - gtk_widget_set_sensitive (editor->priv->text_color_key_combo, merge != NULL); - } - - if (editor->priv->text_color_key_radio) { + if (editor->priv->text_page_vbox) { gtk_widget_set_sensitive (editor->priv->text_color_key_radio, merge != NULL); if (merge == NULL) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(editor->priv->text_color_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->text_color_combo, TRUE); + gtk_widget_set_sensitive (editor->priv->text_color_key_combo, FALSE); + } else { + state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->priv->text_color_key_radio)); + gtk_widget_set_sensitive (editor->priv->text_color_combo, !state); + gtk_widget_set_sensitive (editor->priv->text_color_key_combo, state); + } - } - + } + if (editor->priv->edit_insert_field_button) { gtk_widget_set_sensitive (editor->priv->edit_insert_field_button, merge != NULL); @@ -455,122 +464,112 @@ gl_object_editor_set_key_names (glObjectEditor *editor, (merge != NULL) && !fixed_flag); } - if (editor->priv->fill_key_combo) { - gtk_widget_set_sensitive (editor->priv->fill_key_combo, merge != NULL); - } - - if (editor->priv->fill_key_radio) { + if (editor->priv->fill_page_vbox) { gtk_widget_set_sensitive (editor->priv->fill_key_radio, merge != NULL); if (merge == NULL) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(editor->priv->fill_color_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->fill_color_combo, TRUE); + gtk_widget_set_sensitive (editor->priv->fill_key_combo, FALSE); + } else { + state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->priv->fill_key_radio)); + gtk_widget_set_sensitive (editor->priv->fill_color_combo, !state); + gtk_widget_set_sensitive (editor->priv->fill_key_combo, state); + } } - - if (editor->priv->line_key_combo) { - gtk_widget_set_sensitive (editor->priv->line_key_combo, merge != NULL); - } - - if (editor->priv->line_key_radio) { + + if (editor->priv->line_page_vbox) { gtk_widget_set_sensitive (editor->priv->line_key_radio, merge != NULL); if (merge == NULL) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(editor->priv->line_color_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->line_color_combo, TRUE); + gtk_widget_set_sensitive (editor->priv->line_key_combo, FALSE); + } else { + state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->priv->line_key_radio)); + gtk_widget_set_sensitive (editor->priv->line_color_combo, !state); + gtk_widget_set_sensitive (editor->priv->line_key_combo, state); + } } - - if (editor->priv->bc_key_combo) { - gtk_widget_set_sensitive (editor->priv->bc_key_combo, merge != NULL); - } - - if (editor->priv->bc_key_radio) { + + if (editor->priv->bc_page_vbox) { gtk_widget_set_sensitive (editor->priv->bc_key_radio, merge != NULL); if (merge == NULL) { gtk_toggle_button_set_active ( GTK_TOGGLE_BUTTON(editor->priv->bc_color_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->bc_color_combo, TRUE); + gtk_widget_set_sensitive (editor->priv->bc_key_combo, FALSE); + } else { + state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->priv->bc_key_radio)); + gtk_widget_set_sensitive (editor->priv->bc_color_combo, !state); + gtk_widget_set_sensitive (editor->priv->bc_key_combo, state); + } - } - - keys = gl_merge_get_key_list (merge); - if ( keys != NULL ) { + } - combo = editor->priv->img_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + if (editor->priv->shadow_page_vbox) { + gtk_widget_set_sensitive (editor->priv->shadow_key_radio, merge != NULL); + if (merge == NULL) { + gtk_toggle_button_set_active ( + GTK_TOGGLE_BUTTON(editor->priv->shadow_color_radio), TRUE); + gtk_widget_set_sensitive (editor->priv->shadow_color_combo, TRUE); + gtk_widget_set_sensitive (editor->priv->shadow_key_combo, FALSE); + } else { + state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(editor->priv->shadow_key_radio)); + gtk_widget_set_sensitive (editor->priv->shadow_color_combo, !state); + gtk_widget_set_sensitive (editor->priv->shadow_key_combo, state); + } + } - combo = editor->priv->edit_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + keys = gl_merge_get_key_list (merge); + if ( keys == NULL ) { + keys = g_list_append (keys, ""); + } - combo = editor->priv->data_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } - - combo = editor->priv->fill_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->img_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->text_color_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->edit_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->line_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } - - combo = editor->priv->bc_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->data_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - gl_merge_free_key_list (&keys); - } else { - - keys = g_list_append (keys, ""); + combo = editor->priv->fill_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->img_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->text_color_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->edit_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } - - combo = editor->priv->data_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->line_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->fill_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->bc_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->text_color_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } + combo = editor->priv->shadow_key_combo; + if (combo) { + gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + } - combo = editor->priv->line_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } - - combo = editor->priv->bc_key_combo; - if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); - } - - g_list_free (keys); - } + gl_merge_free_key_list (&keys); gl_debug (DEBUG_EDITOR, "END"); } @@ -664,5 +663,9 @@ prefs_changed_cb (glObjectEditor *editor) position_prefs_changed_cb (editor); } + if (editor->priv->shadow_x_spin) { + shadow_prefs_changed_cb (editor); + } + gl_debug (DEBUG_EDITOR, "END"); } diff --git a/glabels2/src/object-editor.h b/glabels2/src/object-editor.h index d95bb63e..a67a652e 100644 --- a/glabels2/src/object-editor.h +++ b/glabels2/src/object-editor.h @@ -47,6 +47,7 @@ typedef enum { GL_OBJECT_EDITOR_EDIT_PAGE, GL_OBJECT_EDITOR_BC_PAGE, GL_OBJECT_EDITOR_DATA_PAGE, + GL_OBJECT_EDITOR_SHADOW_PAGE, } glObjectEditorOption; #define GL_TYPE_OBJECT_EDITOR (gl_object_editor_get_type ()) @@ -260,6 +261,39 @@ void gl_object_editor_set_data (glObjectEditor *editor, glTextNode *gl_object_editor_get_data (glObjectEditor *editor); +/* + * Shadow Page + */ +void gl_object_editor_set_shadow_state (glObjectEditor *editor, + gboolean state); + +void gl_object_editor_set_shadow_offset (glObjectEditor *editor, + gdouble x, + gdouble y); + +void gl_object_editor_set_shadow_color (glObjectEditor *editor, + gboolean merge_flag, + glColorNode *color_node); + +void gl_object_editor_set_shadow_opacity (glObjectEditor *editor, + gdouble alpha); + +void gl_object_editor_set_max_shadow_offset(glObjectEditor *editor, + gdouble x_max, + gdouble y_max); + + +gboolean gl_object_editor_get_shadow_state (glObjectEditor *editor); + +void gl_object_editor_get_shadow_offset (glObjectEditor *editor, + gdouble *x, + gdouble *y); + +glColorNode* gl_object_editor_get_shadow_color (glObjectEditor *editor); + +gdouble gl_object_editor_get_shadow_opacity (glObjectEditor *editor); + + G_END_DECLS diff --git a/glabels2/src/print.c b/glabels2/src/print.c index 5f22ba41..eef6ec97 100644 --- a/glabels2/src/print.c +++ b/glabels2/src/print.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 * @@ -111,15 +113,15 @@ static void draw_text_object (PrintInfo *pi, static void draw_box_object (PrintInfo *pi, glLabelBox *object, - glMergeRecord *record); + glMergeRecord *record); static void draw_line_object (PrintInfo *pi, glLabelLine *object, - glMergeRecord *record); + glMergeRecord *record); static void draw_ellipse_object (PrintInfo *pi, glLabelEllipse *object, - glMergeRecord *record); + glMergeRecord *record); static void draw_image_object (PrintInfo *pi, glLabelImage *object, @@ -891,6 +893,12 @@ draw_box_object (PrintInfo *pi, glColorNode *line_color_node; glColorNode *fill_color_node; 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"); @@ -903,7 +911,41 @@ draw_box_object (PrintInfo *pi, fill_color = gl_color_node_expand (fill_color_node, record); gl_color_node_free (&line_color_node); gl_color_node_free (&fill_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); + 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_rectangle_path (pi->pc, shadow_x, shadow_y, w, h); + 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_rectangle_path (pi->pc, shadow_x, shadow_y, w, 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); + } + /* Paint fill color */ create_rectangle_path (pi->pc, 0.0, 0.0, w, h); gnome_print_setrgbcolor (pi->pc, diff --git a/glabels2/src/view-box.c b/glabels2/src/view-box.c index dac1450b..ebab30d9 100644 --- a/glabels2/src/view-box.c +++ b/glabels2/src/view-box.c @@ -47,7 +47,8 @@ /*========================================================*/ struct _glViewBoxPrivate { - GnomeCanvasItem *item; + GnomeCanvasItem *object_item; + GnomeCanvasItem *shadow_item; }; /*========================================================*/ @@ -168,6 +169,12 @@ gl_view_box_new (glLabelBox *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"); g_return_if_fail (object && GL_IS_LABEL_BOX (object)); @@ -193,9 +200,36 @@ gl_view_box_new (glLabelBox *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); + + /* Create analogous canvas items. */ + view_box->private->shadow_item = + gl_view_object_item_new (GL_VIEW_OBJECT(view_box), + gnome_canvas_rect_get_type (), + "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); - /* Create analogous canvas item. */ - view_box->private->item = + if (!shadow_state) + { + gnome_canvas_item_hide (view_box->private->shadow_item); + } + + view_box->private->object_item = gl_view_object_item_new (GL_VIEW_OBJECT(view_box), gnome_canvas_rect_get_type (), "x1", 0.0, @@ -209,6 +243,7 @@ gl_view_box_new (glLabelBox *object, gl_color_node_free (&line_color_node); gl_color_node_free (&fill_color_node); + gl_color_node_free (&shadow_color_node); g_signal_connect (G_OBJECT (object), "changed", G_CALLBACK (update_canvas_item_from_object_cb), view_box); @@ -238,6 +273,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 +309,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 +331,38 @@ 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_box->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_box->private->item, + if (shadow_state) + { + gnome_canvas_item_show (view_box->private->shadow_item); + } + else + { + gnome_canvas_item_hide (view_box->private->shadow_item); + } + + gnome_canvas_item_set (view_box->private->object_item, "x2", w + DELTA, "y2", h + DELTA, "width_units", line_width, @@ -301,6 +372,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,6 +388,11 @@ update_object_from_editor_cb (glObjectEditor *editor, 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; + gl_debug (DEBUG_VIEW, "START"); @@ -343,6 +420,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, @@ -365,6 +454,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"); @@ -384,6 +477,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"); } diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index 3176df40..71ce6ba8 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -105,6 +105,11 @@ static void xml_parse_pixdata (xmlNodePtr node, static void xml_parse_toplevel_span (xmlNodePtr node, glLabelObject *object); +static void xml_parse_affine_attrs (xmlNodePtr node, + glLabelObject *object); + +static void xml_parse_shadow_attrs (xmlNodePtr node, + glLabelObject *object); static xmlDocPtr xml_label_to_doc (glLabel *label, glXMLLabelStatus *status); @@ -154,6 +159,12 @@ static void xml_create_toplevel_span (xmlNodePtr node, xmlNsPtr ns, glLabelText *object_text); +static void xml_create_affine_attrs (xmlNodePtr node, + glLabelObject *object); + +static void xml_create_shadow_attrs (xmlNodePtr node, + glLabelObject *object); + /****************************************************************************/ /* Open and read label from xml file. */ @@ -412,7 +423,6 @@ xml_parse_object_text (xmlNodePtr node, gchar *string; GtkJustification just; gboolean auto_shrink; - gdouble affine[6]; xmlNodePtr child; gl_debug (DEBUG_XML, "START"); @@ -440,13 +450,10 @@ xml_parse_object_text (xmlNodePtr node, gl_label_text_set_auto_shrink (GL_LABEL_TEXT(object), auto_shrink); /* affine attrs */ - affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); - affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); - affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); - affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); - affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); - affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); - gl_label_object_set_affine (GL_LABEL_OBJECT(object), affine); + xml_parse_affine_attrs (node, GL_LABEL_OBJECT(object)); + + /* shadow attrs */ + xml_parse_shadow_attrs (node, GL_LABEL_OBJECT(object)); /* Process children */ for (child = node->xmlChildrenNode; child != NULL; child = child->next) { @@ -476,7 +483,6 @@ xml_parse_object_box (xmlNodePtr node, gdouble w, h; gdouble line_width; glColorNode *line_color_node; - gdouble affine[6]; gchar *string; glColorNode *fill_color_node; @@ -523,13 +529,10 @@ xml_parse_object_box (xmlNodePtr node, gl_color_node_free (&fill_color_node); /* affine attrs */ - affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); - affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); - affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); - affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); - affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); - affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); - gl_label_object_set_affine (GL_LABEL_OBJECT(object), affine); + xml_parse_affine_attrs (node, GL_LABEL_OBJECT(object)); + + /* shadow attrs */ + xml_parse_shadow_attrs (node, GL_LABEL_OBJECT(object)); gl_debug (DEBUG_XML, "END"); } @@ -546,7 +549,6 @@ xml_parse_object_ellipse (xmlNodePtr node, gdouble w, h; gdouble line_width; glColorNode *line_color_node; - gdouble affine[6]; gchar *string; glColorNode *fill_color_node; @@ -593,13 +595,10 @@ xml_parse_object_ellipse (xmlNodePtr node, gl_color_node_free (&fill_color_node); /* affine attrs */ - affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); - affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); - affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); - affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); - affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); - affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); - gl_label_object_set_affine (GL_LABEL_OBJECT(object), affine); + xml_parse_affine_attrs (node, GL_LABEL_OBJECT(object)); + + /* shadow attrs */ + xml_parse_shadow_attrs (node, GL_LABEL_OBJECT(object)); gl_debug (DEBUG_XML, "END"); } @@ -616,7 +615,6 @@ xml_parse_object_line (xmlNodePtr node, gdouble dx, dy; gdouble line_width; glColorNode *line_color_node; - gdouble affine[6]; gchar *string; gl_debug (DEBUG_XML, "START"); @@ -649,13 +647,10 @@ xml_parse_object_line (xmlNodePtr node, gl_color_node_free (&line_color_node); /* affine attrs */ - affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); - affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); - affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); - affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); - affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); - affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); - gl_label_object_set_affine (GL_LABEL_OBJECT(object), affine); + xml_parse_affine_attrs (node, GL_LABEL_OBJECT(object)); + + /* shadow attrs */ + xml_parse_shadow_attrs (node, GL_LABEL_OBJECT(object)); gl_debug (DEBUG_XML, "END"); } @@ -672,7 +667,6 @@ xml_parse_object_image (xmlNodePtr node, gdouble w, h; gchar *string; glTextNode *filename; - gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -712,13 +706,10 @@ xml_parse_object_image (xmlNodePtr node, gl_label_object_set_size (GL_LABEL_OBJECT(object), w, h); /* affine attrs */ - affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); - affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); - affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); - affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); - affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); - affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); - gl_label_object_set_affine (GL_LABEL_OBJECT(object), affine); + xml_parse_affine_attrs (node, GL_LABEL_OBJECT(object)); + + /* shadow attrs */ + xml_parse_shadow_attrs (node, GL_LABEL_OBJECT(object)); gl_debug (DEBUG_XML, "END"); } @@ -740,7 +731,6 @@ xml_parse_object_barcode (xmlNodePtr node, gboolean checksum_flag; glColorNode *color_node; guint format_digits; - gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -798,13 +788,10 @@ xml_parse_object_barcode (xmlNodePtr node, } /* affine attrs */ - affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); - affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); - affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); - affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); - affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); - affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); - gl_label_object_set_affine (GL_LABEL_OBJECT(object), affine); + xml_parse_affine_attrs (node, GL_LABEL_OBJECT(object)); + + /* shadow attrs */ + xml_parse_shadow_attrs (node, GL_LABEL_OBJECT(object)); gl_debug (DEBUG_XML, "END"); } @@ -1012,6 +999,64 @@ xml_parse_toplevel_span (xmlNodePtr node, gl_debug (DEBUG_XML, "END"); } +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Parse affine attributes. */ +/*--------------------------------------------------------------------------*/ +static void +xml_parse_affine_attrs (xmlNodePtr node, + glLabelObject *object) +{ + gdouble affine[6]; + + affine[0] = gl_xml_get_prop_double (node, "a0", 0.0); + affine[1] = gl_xml_get_prop_double (node, "a1", 0.0); + affine[2] = gl_xml_get_prop_double (node, "a2", 0.0); + affine[3] = gl_xml_get_prop_double (node, "a3", 0.0); + affine[4] = gl_xml_get_prop_double (node, "a4", 0.0); + affine[5] = gl_xml_get_prop_double (node, "a5", 0.0); + + gl_label_object_set_affine (object, affine); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Parse shadow attributes. */ +/*--------------------------------------------------------------------------*/ +static void +xml_parse_shadow_attrs (xmlNodePtr node, + glLabelObject *object) +{ + gboolean shadow_state; + gdouble shadow_x; + gdouble shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + gchar *string; + + shadow_state = gl_xml_get_prop_boolean (node, "shadow", FALSE); + gl_label_object_set_shadow_state (object, shadow_state); + + if (shadow_state) + { + shadow_x = gl_xml_get_prop_length (node, "shadow_x", 0.0); + shadow_y = gl_xml_get_prop_length (node, "shadow_y", 0.0); + gl_label_object_set_shadow_offset (object, shadow_x, shadow_y); + + shadow_color_node = gl_color_node_new_default (); + string = gl_xml_get_prop_string (node, "shadow_color_field", NULL); + if ( string ) { + shadow_color_node->field_flag = TRUE; + shadow_color_node->key = string; + } else { + shadow_color_node->color = gl_xml_get_prop_uint (node, "shadow_color", 0); + } + gl_label_object_set_shadow_color (object, shadow_color_node); + gl_color_node_free (&shadow_color_node); + + shadow_opacity = gl_xml_get_prop_double (node, "shadow_opacity", 1.0); + gl_label_object_set_shadow_opacity (object, shadow_opacity); + } +} + /****************************************************************************/ /* Save label to xml label file. */ /****************************************************************************/ @@ -1178,7 +1223,6 @@ xml_create_object_text (xmlNodePtr root, gdouble w, h; GtkJustification just; gboolean auto_shrink; - gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -1203,13 +1247,10 @@ xml_create_object_text (xmlNodePtr root, gl_xml_set_prop_boolean (node, "auto_shrink", auto_shrink); /* affine attrs */ - gl_label_object_get_affine (object, affine); - gl_xml_set_prop_double (node, "a0", affine[0]); - gl_xml_set_prop_double (node, "a1", affine[1]); - gl_xml_set_prop_double (node, "a2", affine[2]); - gl_xml_set_prop_double (node, "a3", affine[3]); - gl_xml_set_prop_double (node, "a4", affine[4]); - gl_xml_set_prop_double (node, "a5", affine[5]); + xml_create_affine_attrs (node, object); + + /* shadow attrs */ + xml_create_shadow_attrs (node, object); /* Add children */ xml_create_toplevel_span (node, ns, GL_LABEL_TEXT(object)); @@ -1230,7 +1271,6 @@ xml_create_object_box (xmlNodePtr root, gdouble w, h; gdouble line_width; glColorNode *line_color_node; - gdouble affine[6]; glColorNode *fill_color_node; gl_debug (DEBUG_XML, "START"); @@ -1275,13 +1315,10 @@ xml_create_object_box (xmlNodePtr root, gl_color_node_free (&fill_color_node); /* affine attrs */ - gl_label_object_get_affine (object, affine); - gl_xml_set_prop_double (node, "a0", affine[0]); - gl_xml_set_prop_double (node, "a1", affine[1]); - gl_xml_set_prop_double (node, "a2", affine[2]); - gl_xml_set_prop_double (node, "a3", affine[3]); - gl_xml_set_prop_double (node, "a4", affine[4]); - gl_xml_set_prop_double (node, "a5", affine[5]); + xml_create_affine_attrs (node, object); + + /* shadow attrs */ + xml_create_shadow_attrs (node, object); gl_debug (DEBUG_XML, "END"); } @@ -1299,7 +1336,6 @@ xml_create_object_ellipse (xmlNodePtr root, gdouble w, h; gdouble line_width; glColorNode *line_color_node; - gdouble affine[6]; glColorNode *fill_color_node; gl_debug (DEBUG_XML, "START"); @@ -1345,13 +1381,10 @@ xml_create_object_ellipse (xmlNodePtr root, gl_color_node_free (&fill_color_node); /* affine attrs */ - gl_label_object_get_affine (object, affine); - gl_xml_set_prop_double (node, "a0", affine[0]); - gl_xml_set_prop_double (node, "a1", affine[1]); - gl_xml_set_prop_double (node, "a2", affine[2]); - gl_xml_set_prop_double (node, "a3", affine[3]); - gl_xml_set_prop_double (node, "a4", affine[4]); - gl_xml_set_prop_double (node, "a5", affine[5]); + xml_create_affine_attrs (node, object); + + /* shadow attrs */ + xml_create_shadow_attrs (node, object); gl_debug (DEBUG_XML, "END"); } @@ -1369,7 +1402,6 @@ xml_create_object_line (xmlNodePtr root, gdouble dx, dy; gdouble line_width; glColorNode *line_color_node; - gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -1402,13 +1434,10 @@ xml_create_object_line (xmlNodePtr root, /* affine attrs */ - gl_label_object_get_affine (object, affine); - gl_xml_set_prop_double (node, "a0", affine[0]); - gl_xml_set_prop_double (node, "a1", affine[1]); - gl_xml_set_prop_double (node, "a2", affine[2]); - gl_xml_set_prop_double (node, "a3", affine[3]); - gl_xml_set_prop_double (node, "a4", affine[4]); - gl_xml_set_prop_double (node, "a5", affine[5]); + xml_create_affine_attrs (node, object); + + /* shadow attrs */ + xml_create_shadow_attrs (node, object); gl_debug (DEBUG_XML, "END"); } @@ -1425,7 +1454,6 @@ xml_create_object_image (xmlNodePtr root, gdouble x, y; gdouble w, h; glTextNode *filename; - gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -1451,13 +1479,10 @@ xml_create_object_image (xmlNodePtr root, gl_text_node_free (&filename); /* affine attrs */ - gl_label_object_get_affine (object, affine); - gl_xml_set_prop_double (node, "a0", affine[0]); - gl_xml_set_prop_double (node, "a1", affine[1]); - gl_xml_set_prop_double (node, "a2", affine[2]); - gl_xml_set_prop_double (node, "a3", affine[3]); - gl_xml_set_prop_double (node, "a4", affine[4]); - gl_xml_set_prop_double (node, "a5", affine[5]); + xml_create_affine_attrs (node, object); + + /* shadow attrs */ + xml_create_shadow_attrs (node, object); gl_debug (DEBUG_XML, "END"); } @@ -1479,7 +1504,6 @@ xml_create_object_barcode (xmlNodePtr root, gboolean checksum_flag; glColorNode *color_node; guint format_digits; - gdouble affine[6]; gl_debug (DEBUG_XML, "START"); @@ -1527,13 +1551,10 @@ xml_create_object_barcode (xmlNodePtr root, gl_text_node_free (&text_node); /* affine attrs */ - gl_label_object_get_affine (object, affine); - gl_xml_set_prop_double (node, "a0", affine[0]); - gl_xml_set_prop_double (node, "a1", affine[1]); - gl_xml_set_prop_double (node, "a2", affine[2]); - gl_xml_set_prop_double (node, "a3", affine[3]); - gl_xml_set_prop_double (node, "a4", affine[4]); - gl_xml_set_prop_double (node, "a5", affine[5]); + xml_create_affine_attrs (node, object); + + /* shadow attrs */ + xml_create_shadow_attrs (node, object); gl_debug (DEBUG_XML, "END"); } @@ -1718,3 +1739,63 @@ xml_create_toplevel_span (xmlNodePtr root, g_free (font_family); } + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Create affine attributes. */ +/*--------------------------------------------------------------------------*/ +static void +xml_create_affine_attrs (xmlNodePtr node, + glLabelObject *object) +{ + gdouble affine[6]; + + gl_label_object_get_affine (object, affine); + + gl_xml_set_prop_double (node, "a0", affine[0]); + gl_xml_set_prop_double (node, "a1", affine[1]); + gl_xml_set_prop_double (node, "a2", affine[2]); + gl_xml_set_prop_double (node, "a3", affine[3]); + gl_xml_set_prop_double (node, "a4", affine[4]); + gl_xml_set_prop_double (node, "a5", affine[5]); +} + +/*--------------------------------------------------------------------------*/ +/* PRIVATE. Create shadow attributes. */ +/*--------------------------------------------------------------------------*/ +static void +xml_create_shadow_attrs (xmlNodePtr node, + glLabelObject *object) +{ + gboolean shadow_state; + gdouble shadow_x; + gdouble shadow_y; + glColorNode *shadow_color_node; + gdouble shadow_opacity; + + shadow_state = gl_label_object_get_shadow_state (object); + + if (shadow_state) + { + gl_xml_set_prop_boolean (node, "shadow", shadow_state); + + gl_label_object_get_shadow_offset (object, &shadow_x, &shadow_y); + gl_xml_set_prop_length (node, "shadow_x", shadow_x); + gl_xml_set_prop_length (node, "shadow_y", shadow_y); + + shadow_color_node = gl_label_object_get_shadow_color (object); + if (shadow_color_node->field_flag) + { + gl_xml_set_prop_string (node, "shadow_color_field", shadow_color_node->key); + } + else + { + gl_xml_set_prop_uint_hex (node, "shadow_color", shadow_color_node->color); + } + gl_color_node_free (&shadow_color_node); + + shadow_opacity = gl_label_object_get_shadow_opacity (object); + gl_xml_set_prop_double (node, "shadow_opacity", shadow_opacity); + } +} + + -- 2.39.5