summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorbulia byak <buliabyak@gmail.com>2008-07-26 19:33:42 +0000
committerbuliabyak <buliabyak@users.sourceforge.net>2008-07-26 19:33:42 +0000
commitb88a23c68a87f46ece12322afca5019d3dbbd9e9 (patch)
tree32e3533f0bbd1a462a5abe471ec507980942b132 /src
parentBuild.xml now has a dist-cxxtests target (+ a fix for the linkinkview target ... (diff)
downloadinkscape-b88a23c68a87f46ece12322afca5019d3dbbd9e9.tar.gz
inkscape-b88a23c68a87f46ece12322afca5019d3dbbd9e9.zip
add optional bool* parameter to find out if the tool has color/opacity set in its style or not
(bzr r6426)
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp17
-rw-r--r--src/desktop-style.h4
2 files changed, 16 insertions, 5 deletions
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);