summaryrefslogtreecommitdiffstats
path: root/src/sp-stop.cpp
diff options
context:
space:
mode:
authorJon A. Cruz <jon@joncruz.org>2010-07-18 00:24:31 +0000
committerJon A. Cruz <jon@joncruz.org>2010-07-18 00:24:31 +0000
commit481d61d14a18ea012527b6b93590bff6ad75ba33 (patch)
tree9756e34b45c5527155c81f80864919b5d7b5cd27 /src/sp-stop.cpp
parentSimplify code related to snapping while rotating (diff)
downloadinkscape-481d61d14a18ea012527b6b93590bff6ad75ba33.tar.gz
inkscape-481d61d14a18ea012527b6b93590bff6ad75ba33.zip
Correct behavior of gradient stops to extract color from swatch when color is drag-n-drop'ed or selected.
(bzr r9620)
Diffstat (limited to 'src/sp-stop.cpp')
-rw-r--r--src/sp-stop.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/sp-stop.cpp b/src/sp-stop.cpp
index 740cfef78..71f937927 100644
--- a/src/sp-stop.cpp
+++ b/src/sp-stop.cpp
@@ -15,7 +15,7 @@
#include "sp-stop.h"
-
+#include "style.h"
// A stop might have some non-stop siblings
SPStop* SPStop::getNextStop()
@@ -52,6 +52,34 @@ SPStop* SPStop::getPrevStop()
return result;
}
+SPColor SPStop::readStopColor( Glib::ustring const &styleStr, guint32 dfl )
+{
+ SPColor color(dfl);
+ SPStyle* style = sp_style_new(0);
+ SPIPaint paint;
+ paint.read( styleStr.c_str(), *style );
+ if ( paint.isColor() ) {
+ color = paint.value.color;
+ }
+ sp_style_unref(style);
+ return color;
+}
+
+SPColor SPStop::getEffectiveColor() const
+{
+ SPColor ret;
+ if (currentColor) {
+ char const *str = sp_object_get_style_property(this, "color", NULL);
+ /* Default value: arbitrarily black. (SVG1.1 and CSS2 both say that the initial
+ * value depends on user agent, and don't give any further restrictions that I can
+ * see.) */
+ ret = readStopColor( str, 0 );
+ } else {
+ ret = specified_color;
+ }
+ return ret;
+}
+
/*