diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-16 11:28:09 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-16 11:28:09 +0000 |
| commit | 98e1dc69d91ecb2deb2ae66980b2398b30f33c7e (patch) | |
| tree | c9e25675de64b36691b3615d1a377824f92cc2a3 | |
| parent | when inserting a node, the endpoints cannot be symmetric nodes. (Bug 1367443) (diff) | |
| download | inkscape-98e1dc69d91ecb2deb2ae66980b2398b30f33c7e.tar.gz inkscape-98e1dc69d91ecb2deb2ae66980b2398b30f33c7e.zip | |
Read 'context-fill' and 'context-stroke' keywords.
(bzr r13801)
| -rw-r--r-- | src/desktop-style.cpp | 2 | ||||
| -rw-r--r-- | src/display/nr-style.cpp | 35 | ||||
| -rw-r--r-- | src/style-internal.cpp | 38 | ||||
| -rw-r--r-- | src/style-internal.h | 20 |
4 files changed, 71 insertions, 24 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp index 30869d87d..3eb11bea6 100644 --- a/src/desktop-style.cpp +++ b/src/desktop-style.cpp @@ -626,7 +626,7 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill paintImpossible = false; paint_res->colorSet = paint->colorSet; - paint_res->currentcolor = paint->currentcolor; + paint_res->paintOrigin = paint->paintOrigin; if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server gchar const *string = NULL; // memory leak results if style->get* called inside sp_style_set_to_uri_string. if (isfill) { diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 96d16bf06..70382ef50 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -95,22 +95,37 @@ NRStyle::~NRStyle() void NRStyle::set(SPStyle *style) { - if ( style->fill.isPaintserver() ) { + // Handle 'context-fill' and 'context-stroke': Work in progress + SPIPaint &style_fill = style->fill; + if( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + // std::cout << "NRStyle::set: fill: context-fill" << std::endl; + // style_fill = context_fill; + } else if ( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + //std::cout << "NRStyle::set: fill: context-stroke" << std::endl; + // style_fill = context_stroke; + } + + if ( style_fill.isPaintserver() ) { SPPaintServer* server = style->getFillPaintServer(); if ( server && server->isValid() ) { fill.set(server); - } else if ( style->fill.colorSet ) { - fill.set(style->fill.value.color); + } else if ( style_fill.colorSet ) { + fill.set(style_fill.value.color); } else { fill.clear(); } - } else if ( style->fill.isColor() ) { - fill.set(style->fill.value.color); - } else if ( style->fill.isNone() ) { + } else if ( style_fill.isColor() ) { + fill.set(style_fill.value.color); + } else if ( style_fill.isNone() ) { fill.clear(); + } else if ( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + // std::cout << "NRStyle::set: fill: context-fill DOUBLE" << std::endl; + } else if ( style_fill.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + // std::cout << "NRStyle::set: fill: context-stroke DOUBLE" << std::endl; } else { g_assert_not_reached(); } + fill.opacity = SP_SCALE24_TO_FLOAT(style->fill_opacity.value); switch (style->fill_rule.computed) { @@ -137,6 +152,10 @@ void NRStyle::set(SPStyle *style) stroke.set(style->stroke.value.color); } else if ( style->stroke.isNone() ) { stroke.clear(); + } else if ( style->stroke.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + // std::cout << "NRStyle::set: stroke: context-fill" << std::endl; + } else if ( style->stroke.paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + // std::cout << "NRStyle::set: stroke: context-stroke" << std::endl; } else { g_assert_not_reached(); } @@ -266,7 +285,7 @@ void NRStyle::set(SPStyle *style) } else if ( style_td->fill.isNone() ) { text_decoration_fill.clear(); } else { - g_assert_not_reached(); + //g_assert_not_reached(); } if ( style_td->stroke.isPaintserver() ) { @@ -276,7 +295,7 @@ void NRStyle::set(SPStyle *style) } else if ( style_td->stroke.isNone() ) { text_decoration_stroke.clear(); } else { - g_assert_not_reached(); + //g_assert_not_reached(); } } diff --git a/src/style-internal.cpp b/src/style-internal.cpp index b858e5cb6..915282301 100644 --- a/src/style-internal.cpp +++ b/src/style-internal.cpp @@ -984,7 +984,7 @@ SPIPaint::read( gchar const *str ) { if (streq(str, "currentColor")) { set = true; - currentcolor = true; + paintOrigin = SP_CSS_PAINT_ORIGIN_CURRENT_COLOR; if (style) { setColor( style->color.value.color ); } else { @@ -995,6 +995,12 @@ SPIPaint::read( gchar const *str ) { std::cerr << "SPIPaint::read(): value is 'currentColor' but 'color' not available." << std::endl; setColor( 0 ); } + } else if (streq(str, "context-fill")) { + set = true; + paintOrigin = SP_CSS_PAINT_ORIGIN_CONTEXT_FILL; + } else if (streq(str, "context-stroke")) { + set = true; + paintOrigin = SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE; } else if (streq(str, "none")) { set = true; noneSet = true; @@ -1058,14 +1064,28 @@ SPIPaint::write( guint const flags, SPIBase const *const base) const { css << "none"; } - if ( this->currentcolor ) { + if ( this->paintOrigin == SP_CSS_PAINT_ORIGIN_CURRENT_COLOR ) { if ( !css.str().empty() ) { css << " "; } css << "currentColor"; } - if ( this->colorSet && !this->currentcolor ) { + if ( this->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { + if ( !css.str().empty() ) { + css << " "; + } + css << "context-fill"; + } + + if ( this->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { + if ( !css.str().empty() ) { + css << " "; + } + css << "context-stroke"; + } + + if ( this->colorSet && this->paintOrigin == SP_CSS_PAINT_ORIGIN_NORMAL ) { if ( !css.str().empty() ) { css << " "; } @@ -1074,7 +1094,7 @@ SPIPaint::write( guint const flags, SPIBase const *const base) const { css << color_buf; } - if (this->value.color.icc && !this->currentcolor) { + if ( this->value.color.icc && this->paintOrigin == SP_CSS_PAINT_ORIGIN_NORMAL ) { if ( !css.str().empty() ) { css << " "; } @@ -1107,7 +1127,7 @@ SPIPaint::reset( bool init ) { // std::cout << "SPIPaint::reset(): " << name << " " << init << std::endl; SPIBase::clear(); - currentcolor = false; + paintOrigin = SP_CSS_PAINT_ORIGIN_NORMAL; colorSet = false; noneSet = false; value.color.set( false ); @@ -1147,8 +1167,8 @@ SPIPaint::cascade( const SPIBase* const parent ) { setColor( p->value.color ); } else if( p->isNoneSet() ) { noneSet = true; - } else if( p->currentcolor ) { - currentcolor = true; + } else if( p->paintOrigin == SP_CSS_PAINT_ORIGIN_CURRENT_COLOR ) { + paintOrigin = SP_CSS_PAINT_ORIGIN_CURRENT_COLOR; setColor( style->color.value.color ); } else if( isNone() ) { // @@ -1156,7 +1176,7 @@ SPIPaint::cascade( const SPIBase* const parent ) { g_assert_not_reached(); } } else { - if( currentcolor ) { + if( paintOrigin == SP_CSS_PAINT_ORIGIN_CURRENT_COLOR ) { // Update in case color value changed. setColor( style->color.value.color ); } @@ -1187,7 +1207,7 @@ SPIPaint::operator==(const SPIBase& rhs) { if ( (this->isColor() != r->isColor() ) || (this->isPaintserver() != r->isPaintserver() ) || - (this->currentcolor != r->currentcolor ) ) { + (this->paintOrigin != r->paintOrigin ) ) { return false; } diff --git a/src/style-internal.h b/src/style-internal.h index faae76ac5..a8f0c5096 100644 --- a/src/style-internal.h +++ b/src/style-internal.h @@ -628,6 +628,15 @@ public: #define SP_STYLE_FILL_SERVER(s) ((const_cast<SPStyle *> (s))->getFillPaintServer()) #define SP_STYLE_STROKE_SERVER(s) ((const_cast<SPStyle *> (s))->getStrokePaintServer()) +// SVG 2 +enum SPPaintOrigin { + SP_CSS_PAINT_ORIGIN_NORMAL, + SP_CSS_PAINT_ORIGIN_CURRENT_COLOR, + SP_CSS_PAINT_ORIGIN_CONTEXT_FILL, + SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE +}; + + /// Paint type internal to SPStyle. class SPIPaint : public SPIBase { @@ -635,7 +644,7 @@ class SPIPaint : public SPIBase public: SPIPaint() : SPIBase( "anonymous_paint" ), - currentcolor(false), + paintOrigin( SP_CSS_PAINT_ORIGIN_NORMAL ), colorSet(false), noneSet(false) { value.href = NULL; @@ -644,7 +653,6 @@ public: SPIPaint( Glib::ustring const &name ) : SPIBase( name ), - currentcolor(false), colorSet(false), noneSet(false) { value.href = NULL; @@ -663,7 +671,7 @@ public: SPIPaint& operator=(const SPIPaint& rhs) { SPIBase::operator=(rhs); - currentcolor = rhs.currentcolor; + paintOrigin = rhs.paintOrigin; colorSet = rhs.colorSet; noneSet = rhs.noneSet; value.color = rhs.value.color; @@ -677,7 +685,7 @@ public: } bool isSameType( SPIPaint const & other ) const { - return (isPaintserver() == other.isPaintserver()) && (colorSet == other.colorSet) && (currentcolor == other.currentcolor); + return (isPaintserver() == other.isPaintserver()) && (colorSet == other.colorSet) && (paintOrigin == other.paintOrigin); } bool isNoneSet() const { @@ -685,7 +693,7 @@ public: } bool isNone() const { - return !currentcolor && !colorSet && !isPaintserver(); + return (paintOrigin == SP_CSS_PAINT_ORIGIN_NORMAL) && !colorSet && !isPaintserver(); } // TODO refine bool isColor() const { @@ -712,7 +720,7 @@ public: // To do: make private public: - bool currentcolor : 1; + SPPaintOrigin paintOrigin : 2; bool colorSet : 1; bool noneSet : 1; struct { |
