From 724f9656c1736189f82900a8d5a5b30ebb5af115 Mon Sep 17 00:00:00 2001 From: "Joshua L. Blocher" Date: Sat, 13 May 2006 21:07:48 +0000 Subject: Calligraphy tool now draws in the last used color or tool style depending on the preferences setting. (bzr r823) --- src/desktop-style.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/desktop-style.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); } } -- cgit v1.2.3