From: verbalshadow Date: Sat, 13 May 2006 21:07:48 +0000 (+0000) Subject: Calligraphy tool now draws in the last used color or tool style depending on the... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2d5f45472d142796f87b8b737cc0b56fc9de3bf7;p=inkscape.git Calligraphy tool now draws in the last used color or tool style depending on the preferences setting. --- diff --git a/ChangeLog b/ChangeLog index a0afe6c27..0a8cf3e92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-05-13 verbalshadow + + * src/dyna-draw-context.cpp, src/desktop-style.cpp, + src/desktop-style.h: + + Calligraphy tool now draws in the last used color or the + tool style depending on the Preference setting. + 2006-05-11 Michael Wybrow * src/selection-chemistry.cpp, src/sp-conn-end-pair.cpp: diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 77fcb4823..f680988f8 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -218,6 +218,29 @@ sp_desktop_get_color(SPDesktop *desktop, bool is_fill) return r; } +guint32 +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 + if (prefs_get_int_attribute(tool, "usecurrent", 0) != 0) { + css = sp_desktop_get_style(desktop, is_fill); + } + else { + Inkscape::XML::Node *tool_repr = inkscape_get_repr(INKSCAPE, tool); + css = sp_repr_css_attr_inherited(tool_repr, "style"); + } + + gchar const *property = sp_repr_css_property(css, is_fill ? "fill" : "stroke", "#000"); + + if (desktop->current && property) { // if there is style and the property in it, + if (strncmp(property, "url", 3)) { // and if it's not url, + // read it + r = sp_svg_read_color(property, r); + } + } + return r | 0xff; +} /** * Apply the desktop's current style or the tool style to repr. */ @@ -235,8 +258,7 @@ 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 3ebf4f238..9f080648a 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -53,6 +53,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); +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 05e445086..99cea177b 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -45,6 +45,7 @@ #include "xml/repr.h" #include "context-fns.h" #include "sp-item.h" +#include "inkscape.h" #define DDC_RED_RGBA 0xff0000ff @@ -800,7 +801,9 @@ 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); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(cbp), 0x000000ff, SP_WIND_RULE_EVENODD); + 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); + 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);