summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Evins <evins@snaught.com>2010-06-12 12:20:29 -0400
committerJim Evins <evins@snaught.com>2010-06-12 12:35:02 -0400
commit3f4bd5d778015e524870eeb8bf89ad5bd615eabe (patch)
treeb5d31fff2a5679f238066b13b63a44b3474c6cec
parentfe7a2fbf407047c5d69ccc93e9d5a6cb92d08871 (diff)
Cleanup of shadows for boxes and ellipses.
Do a more intelligent job of drawing shadows for boxes and ellipses. Instead of just blindly drawing a fill shadow and an outline shadow, choose to draw one or the other and adjust size of shadow appropriately.
-rw-r--r--data/ui/object-editor.ui2
-rw-r--r--src/label-box.c47
-rw-r--r--src/label-ellipse.c46
3 files changed, 70 insertions, 25 deletions
diff --git a/data/ui/object-editor.ui b/data/ui/object-editor.ui
index 395882f..43ac7f7 100644
--- a/data/ui/object-editor.ui
+++ b/data/ui/object-editor.ui
@@ -2176,7 +2176,7 @@
<object class="GtkAdjustment" id="adjustment3">
<property name="value">1</property>
<property name="lower">0.25</property>
- <property name="upper">4</property>
+ <property name="upper">10</property>
<property name="step_increment">0.25</property>
<property name="page_increment">1</property>
</object>
diff --git a/src/label-box.c b/src/label-box.c
index 3088ef1..c84b0aa 100644
--- a/src/label-box.c
+++ b/src/label-box.c
@@ -409,11 +409,11 @@ draw_shadow (glLabelObject *object,
glColorNode *shadow_color_node;
guint shadow_color;
gdouble shadow_opacity;
- guint shadow_line_color;
- guint shadow_fill_color;
gl_debug (DEBUG_LABEL, "START");
+ cairo_save (cr);
+
gl_label_object_get_size (object, &w, &h);
line_width = gl_label_object_get_line_width (object);
@@ -438,27 +438,50 @@ draw_shadow (glLabelObject *object,
shadow_color = GL_COLOR_SHADOW_MERGE_DEFAULT;
}
shadow_opacity = gl_label_object_get_shadow_opacity (object);
- shadow_line_color = gl_color_shadow (shadow_color, shadow_opacity, line_color_node->color);
- shadow_fill_color = gl_color_shadow (shadow_color, shadow_opacity, fill_color_node->color);
+ shadow_color = gl_color_set_opacity (shadow_color, shadow_opacity);
- cairo_rectangle (cr, 0.0, 0.0, w, h);
+ cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (shadow_color));
+ if ( GL_COLOR_F_ALPHA (fill_color) )
+ {
+ if ( GL_COLOR_F_ALPHA (line_color) )
+ {
+ /* Has FILL and OUTLINE: adjust size to account for line width. */
+ cairo_rectangle (cr,
+ -line_width/2, -line_width/2,
+ w+line_width, h+line_width);
- /* Draw fill shadow */
- cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (shadow_fill_color));
- cairo_fill_preserve (cr);
+ }
+ else
+ {
+ /* Has FILL but no OUTLINE. */
+ cairo_rectangle (cr, 0.0, 0.0, w, h);
+ }
- /* Draw outline shadow */
- cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (shadow_line_color));
- cairo_set_line_width (cr, line_width);
- cairo_stroke (cr);
+ /* Draw shadow */
+ cairo_fill (cr);
+ }
+ else
+ {
+ if ( GL_COLOR_F_ALPHA (line_color) )
+ {
+ /* Has only OUTLINE. */
+ cairo_rectangle (cr, 0.0, 0.0, w, h);
+
+ /* Draw shadow of outline */
+ cairo_set_line_width (cr, line_width);
+ cairo_stroke (cr);
+ }
+ }
gl_color_node_free (&line_color_node);
gl_color_node_free (&fill_color_node);
gl_color_node_free (&shadow_color_node);
+ cairo_restore (cr);
+
gl_debug (DEBUG_LABEL, "END");
}
diff --git a/src/label-ellipse.c b/src/label-ellipse.c
index 5de25a7..0d38e3e 100644
--- a/src/label-ellipse.c
+++ b/src/label-ellipse.c
@@ -410,11 +410,11 @@ draw_shadow (glLabelObject *object,
glColorNode *shadow_color_node;
guint shadow_color;
gdouble shadow_opacity;
- guint shadow_line_color;
- guint shadow_fill_color;
gl_debug (DEBUG_LABEL, "START");
+ cairo_save (cr);
+
gl_label_object_get_size (object, &w, &h);
line_width = gl_label_object_get_line_width (object);
@@ -439,27 +439,49 @@ draw_shadow (glLabelObject *object,
shadow_color = GL_COLOR_SHADOW_MERGE_DEFAULT;
}
shadow_opacity = gl_label_object_get_shadow_opacity (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);
+ shadow_color = gl_color_set_opacity (shadow_color, shadow_opacity);
- gl_cairo_ellipse_path (cr, w/2, h/2);
+ cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (shadow_color));
+ if ( GL_COLOR_F_ALPHA (fill_color) )
+ {
+ if ( GL_COLOR_F_ALPHA (line_color) )
+ {
+ /* Has FILL and OUTLINE: adjust size to account for line width. */
+ cairo_translate (cr, -line_width/2, -line_width/2);
+ gl_cairo_ellipse_path (cr, (w+line_width)/2, (h+line_width)/2);
- /* Draw fill shadow */
- cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (shadow_fill_color));
- cairo_fill_preserve (cr);
+ }
+ else
+ {
+ /* Has FILL but no OUTLINE. */
+ gl_cairo_ellipse_path (cr, w/2, h/2);
+ }
- /* Draw outline shadow */
- cairo_set_source_rgba (cr, GL_COLOR_RGBA_ARGS (shadow_line_color));
- cairo_set_line_width (cr, line_width);
- cairo_stroke (cr);
+ /* Draw shadow */
+ cairo_fill (cr);
+ }
+ else
+ {
+ if ( GL_COLOR_F_ALPHA (line_color) )
+ {
+ /* Has only OUTLINE. */
+ gl_cairo_ellipse_path (cr, w/2, h/2);
+
+ /* Draw shadow of outline */
+ cairo_set_line_width (cr, line_width);
+ cairo_stroke (cr);
+ }
+ }
gl_color_node_free (&line_color_node);
gl_color_node_free (&fill_color_node);
gl_color_node_free (&shadow_color_node);
+ cairo_restore (cr);
+
gl_debug (DEBUG_LABEL, "END");
}