summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--share/attributes/css_defaults4
-rw-r--r--share/attributes/cssprops4
-rwxr-xr-xshare/attributes/genMapDataCSS.pl10
-rwxr-xr-xshare/attributes/genMapDataSVG.pl6
-rw-r--r--share/attributes/svgprops6
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Makefile_insert1
-rw-r--r--src/attributes.cpp2
-rw-r--r--src/attributes.h2
-rw-r--r--src/sp-solid-color.cpp97
-rw-r--r--src/sp-solid-color.h46
-rw-r--r--src/style.cpp23
-rw-r--r--src/style.h5
13 files changed, 202 insertions, 6 deletions
diff --git a/share/attributes/css_defaults b/share/attributes/css_defaults
index 5675c6a3b..1f8e8835b 100644
--- a/share/attributes/css_defaults
+++ b/share/attributes/css_defaults
@@ -94,6 +94,10 @@
"shape-rendering" - "auto" - "yes"
+"solid-color" - "#000000" - "no"
+
+"solid-opacity" - "1.0" - "no"
+
"stop-color" - "black" - "no"
"stop-opacity" - "1" - "no"
diff --git a/share/attributes/cssprops b/share/attributes/cssprops
index a4bc8a398..aefb60cc1 100644
--- a/share/attributes/cssprops
+++ b/share/attributes/cssprops
@@ -94,6 +94,10 @@
"shape-rendering" - "path","rect","circle","ellipse","line","polyline","polygon","a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use"
+"solid-color" - "a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use","circle","ellipse","image","line","path","polygon","polyline","rect","text","use"
+
+"solid-opacity" - "a","defs","glyph","g","marker","mask","missing-glyph","pattern","svg","switch","symbol","use","circle","ellipse","image","line","path","polygon","polyline","rect","text","use"
+
"stop-color" - "stop"
"stop-opacity" - "stop"
diff --git a/share/attributes/genMapDataCSS.pl b/share/attributes/genMapDataCSS.pl
index 4a32f96c7..9b013c758 100755
--- a/share/attributes/genMapDataCSS.pl
+++ b/share/attributes/genMapDataCSS.pl
@@ -200,6 +200,16 @@ push @{$properties{ "paint-order" }->{elements}}, @graphics_elements;
$properties{ "paint-order" }->{default} = "normal";
$properties{ "paint-order" }->{inherit} = "yes";
+push @{$properties{ "solid-color" }->{elements}}, @container_elements;
+push @{$properties{ "solid-color" }->{elements}}, @graphics_elements;
+$properties{ "solid-color" }->{default} = "#000000";
+$properties{ "solid-color" }->{inherit} = "no";
+
+push @{$properties{ "solid-opacity" }->{elements}}, @container_elements;
+push @{$properties{ "solid-opacity" }->{elements}}, @graphics_elements;
+$properties{ "solid-opacity" }->{default} = "1.0";
+$properties{ "solid-opacity" }->{inherit} = "no";
+
# Output
diff --git a/share/attributes/genMapDataSVG.pl b/share/attributes/genMapDataSVG.pl
index 8cd18128e..f3d84d2c5 100755
--- a/share/attributes/genMapDataSVG.pl
+++ b/share/attributes/genMapDataSVG.pl
@@ -78,9 +78,9 @@ while( my $t = $p->get_token ) {
# Adjustments
push @{$attributes{ "in" }->{elements}}, "feMergeNode";
-push @{$attributes{ "class" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion";
-push @{$attributes{ "id" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion";
-push @{$attributes{ "style" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion";
+push @{$attributes{ "class" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor";
+push @{$attributes{ "id" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor";
+push @{$attributes{ "style" }->{elements}}, "flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor";
push @{$attributes{ "xml:space" }->{elements}}, "flowRoot","flowPara","flowSpan";
push @{$attributes{ "transform" }->{elements}}, "flowRoot","flowPara","flowSpan";
diff --git a/share/attributes/svgprops b/share/attributes/svgprops
index 3e72fc65f..6e8925177 100644
--- a/share/attributes/svgprops
+++ b/share/attributes/svgprops
@@ -34,7 +34,7 @@
"cap-height" - "font-face"
-"class" - "a","altGlyph","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","font","foreignObject","g","glyph","glyphRef","image","line","linearGradient","marker","mask","missing-glyph","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tref","tspan","use","flowRoot","flowPara","flowSpan","flowRect","flowRegion"
+"class" - "a","altGlyph","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","font","foreignObject","g","glyph","glyphRef","image","line","linearGradient","marker","mask","missing-glyph","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tref","tspan","use","flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor"
"clipPathUnits" - "clipPath"
@@ -118,7 +118,7 @@
"horiz-origin-y" - "font"
-"id" - "a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern","flowRoot","flowPara","flowSpan","flowRect","flowRegion"
+"id" - "a","altGlyph","altGlyphDef","altGlyphItem","animate","animateColor","animateMotion","animateTransform","circle","clipPath","color-profile","cursor","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence","filter","font","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignObject","g","glyph","glyphRef","hkern","image","line","linearGradient","marker","mask","metadata","missing-glyph","mpath","path","pattern","polygon","polyline","radialGradient","rect","script","set","stop","style","svg","switch","symbol","text","textPath","title","tref","tspan","use","view","vkern","flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor"
"ideographic" - "font-face"
@@ -320,7 +320,7 @@
"string" - "font-face-format"
-"style" - "a","altGlyph","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","font","foreignObject","g","glyph","glyphRef","image","line","linearGradient","marker","mask","missing-glyph","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tref","tspan","use","flowRoot","flowPara","flowSpan","flowRect","flowRegion"
+"style" - "a","altGlyph","circle","clipPath","defs","desc","ellipse","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","filter","font","foreignObject","g","glyph","glyphRef","image","line","linearGradient","marker","mask","missing-glyph","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","switch","symbol","text","textPath","title","tref","tspan","use","flowRoot","flowPara","flowSpan","flowRect","flowRegion","solidColor"
"surfaceScale" - "feDiffuseLighting","feSpecularLighting"
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index d40aad802..4a792af6b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -63,6 +63,7 @@ set(sp_SRC
sp-root.cpp
sp-script.cpp
sp-shape.cpp
+ sp-solid-color.cpp
sp-spiral.cpp
sp-star.cpp
sp-stop.cpp
@@ -147,6 +148,7 @@ set(sp_SRC
sp-root.h
sp-script.h
sp-shape.h
+ sp-solid-color.h
sp-spiral.h
sp-star.h
sp-stop.h
diff --git a/src/Makefile_insert b/src/Makefile_insert
index 6d0d6b08c..f191839a1 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -192,6 +192,7 @@ ink_common_sources += \
sp-root.cpp sp-root.h \
sp-script.cpp sp-script.h \
sp-shape.cpp sp-shape.h \
+ sp-solid-color.cpp sp-solid-color.h \
sp-spiral.cpp sp-spiral.h \
sp-star.cpp sp-star.h \
sp-stop.cpp sp-stop.h \
diff --git a/src/attributes.cpp b/src/attributes.cpp
index ee2a80fd3..da7b25f03 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -475,6 +475,8 @@ static SPStyleProp const props[] = {
{SP_PROP_MARKER_START, "marker-start"},
{SP_PROP_PAINT_ORDER, "paint-order" },
{SP_PROP_SHAPE_RENDERING, "shape-rendering"},
+ {SP_PROP_SOLID_COLOR, "solid-color"},
+ {SP_PROP_SOLID_OPACITY, "solid-opacity"},
{SP_PROP_STROKE, "stroke"},
{SP_PROP_STROKE_DASHARRAY, "stroke-dasharray"},
{SP_PROP_STROKE_DASHOFFSET, "stroke-dashoffset"},
diff --git a/src/attributes.h b/src/attributes.h
index b8843fcb7..82e7ca8a6 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -476,6 +476,8 @@ enum SPAttributeEnum {
SP_PROP_MARKER_START,
SP_PROP_PAINT_ORDER, /* SVG2 */
SP_PROP_SHAPE_RENDERING,
+ SP_PROP_SOLID_COLOR,
+ SP_PROP_SOLID_OPACITY,
SP_PROP_STROKE,
SP_PROP_STROKE_DASHARRAY,
SP_PROP_STROKE_DASHOFFSET,
diff --git a/src/sp-solid-color.cpp b/src/sp-solid-color.cpp
new file mode 100644
index 000000000..1f606d176
--- /dev/null
+++ b/src/sp-solid-color.cpp
@@ -0,0 +1,97 @@
+/** @file
+ * @solid color class.
+ */
+/* Authors:
+ * Tavmjong Bah <tavjong@free.fr>
+ *
+ * Copyright (C) 2014 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+#include "sp-solid-color.h"
+
+#include "attributes.h"
+#include "style.h"
+#include "xml/repr.h"
+
+#include "sp-factory.h"
+#include "sp-item.h"
+#include "style-internal.h"
+
+namespace {
+ SPObject* createSolidColor() {
+ return new SPSolidColor();
+ }
+
+ bool solidColorRegistered = SPFactory::instance().registerObject("svg:solidColor", createSolidColor);
+}
+
+
+/*
+ * Solid Color
+ */
+SPSolidColor::SPSolidColor() : SPPaintServer() {
+}
+
+SPSolidColor::~SPSolidColor() {
+}
+
+void SPSolidColor::build(SPDocument* doc, Inkscape::XML::Node* repr) {
+ SPPaintServer::build(doc, repr);
+
+ this->readAttr( "style" );
+ this->readAttr( "solid-color" );
+ this->readAttr( "solid-opacity" );
+}
+
+/**
+ * Virtual build: set solidcolor attributes from its associated XML node.
+ */
+
+void SPSolidColor::set(unsigned int key, const gchar* value) {
+
+ if (SP_ATTRIBUTE_IS_CSS(key)) {
+ sp_style_read_from_object(this->style, this);
+ this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
+ } else {
+ SPPaintServer::set(key, value);
+ }
+}
+
+/**
+ * Virtual set: set attribute to value.
+ */
+
+Inkscape::XML::Node* SPSolidColor::write(Inkscape::XML::Document* xml_doc, Inkscape::XML::Node* repr, guint flags) {
+ if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
+ repr = xml_doc->createElement("svg:solidColor");
+ }
+
+ SPObject::write(xml_doc, repr, flags);
+
+ return repr;
+}
+
+cairo_pattern_t* SPSolidColor::pattern_new(cairo_t * /*ct*/, Geom::OptRect const &bbox, double opacity) {
+
+ SPIColor *c = &(this->style->solid_color);
+ cairo_pattern_t *cp = cairo_pattern_create_rgba ( c->value.color.v.c[0], c->value.color.v.c[1], c->value.color.v.c[2], SP_SCALE24_TO_FLOAT(this->style->solid_opacity.value) * opacity );
+
+ return cp;
+}
+
+
+/**
+ * Virtual write: write object attributes to repr.
+ */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/sp-solid-color.h b/src/sp-solid-color.h
new file mode 100644
index 000000000..0ff09762e
--- /dev/null
+++ b/src/sp-solid-color.h
@@ -0,0 +1,46 @@
+#ifndef SEEN_SP_SOLIDCOLOR_H
+#define SEEN_SP_SOLIDCOLOR_H
+
+/** \file
+ * SPSolidColor: SVG <solidColor> implementation.
+ */
+/*
+ * Authors: Tavmjong Bah
+ * Copyright (C) 2012 Tavmjong Bah
+ *
+ * Released under GNU GPL, read the file 'COPYING' for more information
+ */
+
+#include <glib.h>
+#include "color.h"
+#include "sp-paint-server.h"
+
+#define SP_SOLIDCOLOR(obj) (dynamic_cast<SPSolidColor*>((SPObject*)obj))
+#define SP_IS_SOLIDCOLOR(obj) (dynamic_cast<const SPSolidColor*>((SPObject*)obj) != NULL)
+
+/** Gradient SolidColor. */
+class SPSolidColor : public SPPaintServer {
+public:
+ SPSolidColor();
+ virtual ~SPSolidColor();
+
+ virtual cairo_pattern_t* pattern_new(cairo_t *ct, Geom::OptRect const &bbox, double opacity);
+
+protected:
+ virtual void build(SPDocument* doc, Inkscape::XML::Node* repr);
+ virtual void set(unsigned int key, const gchar* value);
+ virtual Inkscape::XML::Node* write(Inkscape::XML::Document* doc, Inkscape::XML::Node* repr, guint flags);
+};
+
+#endif /* !SEEN_SP_SOLIDCOLOR_H */
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/style.cpp b/src/style.cpp
index 222155a0c..f0710e404 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -153,6 +153,10 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
color_interpolation( "color-interpolation", enum_color_interpolation, SP_CSS_COLOR_INTERPOLATION_SRGB),
color_interpolation_filters("color-interpolation-filters", enum_color_interpolation, SP_CSS_COLOR_INTERPOLATION_LINEARRGB),
+ // Solid color properties
+ solid_color( "solid-color" ), // SPIColor
+ solid_opacity( "solid-opacity", SP_SCALE24_MAX ),
+
// Fill properties
fill( "fill" ), // SPIPaint
fill_opacity( "fill-opacity", SP_SCALE24_MAX ),
@@ -306,6 +310,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &color_interpolation );
_properties.push_back( &color_interpolation_filters );
+ _properties.push_back( &solid_color );
+ _properties.push_back( &solid_opacity );
+
_properties.push_back( &fill );
_properties.push_back( &fill_opacity );
_properties.push_back( &fill_rule );
@@ -385,10 +392,14 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
// _propmap.insert( std::make_pair( color_interpolation.name, reinterpret_cast<SPIBasePtr>(&SPStyle::color_interpolation ) ) );
// _propmap.insert( std::make_pair( color_interpolation_filters.name, reinterpret_cast<SPIBasePtr>(&SPStyle::color_interpolation_filters ) ) );
+ // _propmap.insert( std::make_pair( solid_color.name, reinterpret_cast<SPIBasePtr>(&SPStyle::solid_color ) ) );
+ // _propmap.insert( std::make_pair( solid_opacity.name, reinterpret_cast<SPIBasePtr>(&SPStyle::solid_opacity ) ) );
+
// _propmap.insert( std::make_pair( fill.name, reinterpret_cast<SPIBasePtr>(&SPStyle::fill ) ) );
// _propmap.insert( std::make_pair( fill_opacity.name, reinterpret_cast<SPIBasePtr>(&SPStyle::fill_opacity ) ) );
// _propmap.insert( std::make_pair( fill_rule.name, reinterpret_cast<SPIBasePtr>(&SPStyle::fill_rule ) ) );
+
// _propmap.insert( std::make_pair( stroke.name, reinterpret_cast<SPIBasePtr>(&SPStyle::stroke ) ) );
// _propmap.insert( std::make_pair( stroke_width.name, reinterpret_cast<SPIBasePtr>(&SPStyle::stroke_width ) ) );
// _propmap.insert( std::make_pair( stroke_linecap.name, reinterpret_cast<SPIBasePtr>(&SPStyle::stroke_linecap ) ) );
@@ -779,6 +790,12 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
case SP_PROP_COLOR_RENDERING:
color_rendering.readIfUnset( val );
break;
+ case SP_PROP_SOLID_COLOR:
+ solid_color.readIfUnset( val );
+ break;
+ case SP_PROP_SOLID_OPACITY:
+ solid_opacity.readIfUnset( val );
+ break;
case SP_PROP_FILL:
fill.readIfUnset( val );
break;
@@ -1546,6 +1563,12 @@ sp_style_unset_property_attrs(SPObject *o)
if (style->color_interpolation_filters.set) {
repr->setAttribute("color-interpolation-filters", NULL);
}
+ if (style->solid_color.set) {
+ repr->setAttribute("solid-color", NULL);
+ }
+ if (style->solid_opacity.set) {
+ repr->setAttribute("solid-opacity", NULL);
+ }
if (style->fill.set) {
repr->setAttribute("fill", NULL);
}
diff --git a/src/style.h b/src/style.h
index 931dcc90e..eb8a3ed91 100644
--- a/src/style.h
+++ b/src/style.h
@@ -180,6 +180,11 @@ public:
/** color-interpolation-filters */
SPIEnum color_interpolation_filters;
+ /** solid-color */
+ SPIColor solid_color;
+ /** solid-opacity */
+ SPIScale24 solid_opacity;
+
/** fill */
SPIPaint fill;
/** fill-opacity */