diff options
| author | Joshua L. Blocher <verbalshadow@gmail.com> | 2006-05-13 21:07:48 +0000 |
|---|---|---|
| committer | verbalshadow <verbalshadow@users.sourceforge.net> | 2006-05-13 21:07:48 +0000 |
| commit | 724f9656c1736189f82900a8d5a5b30ebb5af115 (patch) | |
| tree | 1110ccf02098911cdb1b5cd3217b5ad183717470 /src | |
| parent | added packaging/win32/italian.nsh and czech.nsh to distribution (diff) | |
| download | inkscape-724f9656c1736189f82900a8d5a5b30ebb5af115.tar.gz inkscape-724f9656c1736189f82900a8d5a5b30ebb5af115.zip | |
Calligraphy tool now draws in the last used color or tool style depending on the preferences setting.
(bzr r823)
Diffstat (limited to 'src')
| -rw-r--r-- | src/desktop-style.cpp | 26 | ||||
| -rw-r--r-- | src/desktop-style.h | 1 | ||||
| -rw-r--r-- | src/dyna-draw-context.cpp | 5 |
3 files changed, 29 insertions, 3 deletions
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); |
