From: buliabyak Date: Sat, 26 Jul 2008 19:33:42 +0000 (+0000) Subject: add optional bool* parameter to find out if the tool has color/opacity set in its... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b1de495260e5096494a86c58155e1c568898dab6;p=inkscape.git add optional bool* parameter to find out if the tool has color/opacity set in its style or not --- diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 4f4344f9b..5eaa902fd 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -243,10 +243,12 @@ sp_desktop_get_color(SPDesktop *desktop, bool is_fill) } double -sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool) +sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool, bool *has_opacity) { SPCSSAttr *css = NULL; gfloat value = 1.0; // default if nothing else found + if (has_opacity) + *has_opacity = false; if (prefs_get_double_attribute(tool, "usecurrent", 0) != 0) { css = sp_desktop_get_style(desktop, true); } else { @@ -262,6 +264,9 @@ sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool) 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 + } else { + if (has_opacity) + *has_opacity = false; } } @@ -298,11 +303,14 @@ sp_desktop_get_opacity_tool(SPDesktop *desktop, char const *tool, bool is_fill) return value; } + guint32 -sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill) +sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill, bool *has_color) { SPCSSAttr *css = NULL; guint32 r = 0; // if there's no color, return black + if (has_color) + *has_color = false; if (prefs_get_int_attribute(tool, "usecurrent", 0) != 0) { css = sp_desktop_get_style(desktop, true); } else { @@ -316,9 +324,11 @@ sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill) 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, + if (strncmp(property, "url", 3) && strncmp(property, "none", 4)) { // and if it's not url or none, // read it r = sp_svg_read_color(property, r); + if (has_color) + *has_color = true; } } @@ -327,6 +337,7 @@ sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill) return r | 0xff; } + /** * Apply the desktop's current style or the tool style to repr. */ diff --git a/src/desktop-style.h b/src/desktop-style.h index b99f12fde..57d8e0ae1 100644 --- a/src/desktop-style.h +++ b/src/desktop-style.h @@ -57,9 +57,9 @@ 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_master_opacity_tool(SPDesktop *desktop, char const *tool); +double sp_desktop_get_master_opacity_tool(SPDesktop *desktop, char const *tool, bool* has_opacity = NULL); 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); +guint32 sp_desktop_get_color_tool(SPDesktop *desktop, char const *tool, bool is_fill, bool* has_color = NULL); 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);