From: acspike Date: Thu, 18 May 2006 15:36:46 +0000 (+0000) Subject: adding fill-opacity to dyna-draw X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=088a050d74b4595bab9e5de85fc4dfc26b7a849f;p=inkscape.git adding fill-opacity to dyna-draw --- diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index cf8f67442..062607fbf 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -222,7 +222,7 @@ sp_desktop_get_color(SPDesktop *desktop, bool is_fill) } double -sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool) +sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool) { SPCSSAttr *css = NULL; gfloat value = 1.0; // default if nothing else found @@ -247,6 +247,32 @@ sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool) return value; } +double +sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill) +{ + SPCSSAttr *css = NULL; + gfloat value = 1.0; // default if nothing else found + if (prefs_get_double_attribute(tool, "usecurrent", 0) != 0) { + css = sp_desktop_get_style(desktop, true); + } else { + Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool); + css = sp_repr_css_attr_inherited(tool_repr, "style"); + } + + gchar const *property = css ? sp_repr_css_property(css, is_fill ? "fill-opacity": "stroke-opacity", "1.000") : 0; + + if (desktop->current && property) { // if there is style and the property in it, + if ( !sp_svg_number_read_f(property, &value) ) { + value = 1.0; // things failed. set back to the default + } + } + + if (css) { + sp_repr_css_attr_unref(css); + } + + return value; +} guint32 sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill) { diff --git a/src/desktop-style.h b/src/desktop-style.h index 5171ae627..8f8388289 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -54,7 +54,8 @@ void sp_desktop_set_color(SPDesktop *desktop, ColorRGBA const &color, bool is_re void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change = true, bool write_current = true); SPCSSAttr *sp_desktop_get_style(SPDesktop *desktop, bool with_text); guint32 sp_desktop_get_color (SPDesktop *desktop, bool is_fill); -double sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool); +double sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool); +double sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill); guint32 sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill); double sp_desktop_get_font_size_tool (SPDesktop *desktop); void sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, char const *tool, bool with_text); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index ff570fb62..f1128c492 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -809,8 +809,13 @@ fit_and_split_calligraphics(SPDynaDrawContext *dc, gboolean release) sp_curve_unref(curve); guint32 fillColor = sp_desktop_get_color_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", true); - double opacity = sp_desktop_get_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic"); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), ((fillColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity)), SP_WIND_RULE_EVENODD); + //guint32 strokeColor = sp_desktop_get_color_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", false); + double opacity = sp_desktop_get_master_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic"); + double fillOpacity = sp_desktop_get_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", true); + //double strokeOpacity = sp_desktop_get_opacity_tool (SP_ACTIVE_DESKTOP, "tools.calligraphic", false); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), ((fillColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*fillOpacity)), SP_WIND_RULE_EVENODD); + //on second thougtht don't do stroke yet because we don't have stoke-width yet and because stoke appears between segments while drawing + //sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), ((strokeColor & 0xffffff00) | SP_COLOR_F_TO_U(opacity*strokeOpacity)), 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); /* fixme: Cannot we cascade it to root more clearly? */ g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), SP_EVENT_CONTEXT(dc)->desktop);