From: buliabyak Date: Wed, 17 May 2006 06:57:31 +0000 (+0000) Subject: do calligraphic draw opacity correctly X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bd451b50eef039baac8a5674942d4ea7e34ba179;p=inkscape.git do calligraphic draw opacity correctly --- diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index afb3a1045..cf8f67442 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -222,12 +222,12 @@ sp_desktop_get_color(SPDesktop *desktop, bool is_fill) } double -sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool op) +sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool) { 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, op); + 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"); @@ -240,6 +240,11 @@ sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool op) value = 1.0; // things failed. set back to the default } } + + if (css) { + sp_repr_css_attr_unref(css); + } + return value; } guint32 @@ -247,10 +252,8 @@ sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill) { SPCSSAttr *css = NULL; guint32 r = 0; // if there's no color, return black - bool op = true; - double opacity = sp_desktop_get_opacity_tool(SP_ACTIVE_DESKTOP, "tools.calligraphic", op); if (prefs_get_int_attribute(tool, "usecurrent", 0) != 0) { - css = sp_desktop_get_style(desktop, is_fill); + 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"); @@ -264,7 +267,12 @@ sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill) r = sp_svg_read_color(property, r); } } - return r | SP_COLOR_F_TO_U( opacity ); // return RGBA color + + if (css) { + sp_repr_css_attr_unref(css); + } + + return r | 0xff; } /** * Apply the desktop's current style or the tool style to repr. @@ -283,7 +291,8 @@ sp_desktop_apply_style_tool(SPDesktop *desktop, Inkscape::XML::Node *repr, char sp_repr_css_attr_unref(css); } } - if (css_current) {sp_repr_css_attr_unref(css_current); + if (css_current) { + sp_repr_css_attr_unref(css_current); } } diff --git a/src/desktop-style.h b/src/desktop-style.h index cec36aca5..5171ae627 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -54,7 +54,7 @@ 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, bool op); +double sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool); 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 ebabeef31..ff570fb62 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -46,6 +46,7 @@ #include "context-fns.h" #include "sp-item.h" #include "inkscape.h" +#include "color.h" #define DDC_RED_RGBA 0xff0000ff @@ -806,9 +807,10 @@ fit_and_split_calligraphics(SPDynaDrawContext *dc, gboolean release) SPCurve *curve = sp_curve_copy(dc->currentcurve); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH (cbp), curve); sp_curve_unref(curve); - guint32 fillColor = sp_desktop_get_color_tool(SP_ACTIVE_DESKTOP, "tools.calligraphic", true); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), fillColor , SP_WIND_RULE_EVENODD); + 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); 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);