diff options
| author | Tavmjong Bah <tavmjong@free.fr> | 2014-12-23 09:25:08 +0000 |
|---|---|---|
| committer | tavmjong-free <tavmjong@free.fr> | 2014-12-23 09:25:08 +0000 |
| commit | f01a18216e26fd87a53188018e03527c7fdf8a57 (patch) | |
| tree | e5fc50bfa2b278d007659dd0aa4c6587414731dd | |
| parent | Bug #1380413: make sure that the rect toolbar knows when and when not to update (diff) | |
| download | inkscape-f01a18216e26fd87a53188018e03527c7fdf8a57.tar.gz inkscape-f01a18216e26fd87a53188018e03527c7fdf8a57.zip | |
Use gray for 'context-fill' and 'context-stroke' in marker selector.
Fix rendering bug when elements with 'context-fill' and 'context-stroke' are inside groups.
(bzr r13822)
| -rw-r--r-- | share/markers/markers.svg | 3 | ||||
| -rw-r--r-- | src/display/nr-style.cpp | 18 | ||||
| -rw-r--r-- | src/sp-item-group.cpp | 14 | ||||
| -rw-r--r-- | src/sp-object.cpp | 1 | ||||
| -rw-r--r-- | src/sp-object.h | 5 | ||||
| -rw-r--r-- | src/sp-shape.cpp | 44 | ||||
| -rw-r--r-- | src/sp-use.cpp | 14 | ||||
| -rw-r--r-- | src/widgets/stroke-marker-selector.cpp | 8 |
8 files changed, 72 insertions, 35 deletions
diff --git a/share/markers/markers.svg b/share/markers/markers.svg index 825059fb0..91de99ed3 100644 --- a/share/markers/markers.svg +++ b/share/markers/markers.svg @@ -4,7 +4,8 @@ NOTE: this file is currently (0.48+) edited manually. Insert the new markers into the <defs>. --> <svg xmlns="http://www.w3.org/2000/svg" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"> + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + id="InkscapeMarkers"> <defs id="defs3"> <!-- Arrows --> diff --git a/src/display/nr-style.cpp b/src/display/nr-style.cpp index 9dadaf3f1..1740785e2 100644 --- a/src/display/nr-style.cpp +++ b/src/display/nr-style.cpp @@ -101,13 +101,14 @@ void NRStyle::set(SPStyle *style, SPStyle *context_style) if( context_style != NULL ) { style_fill = &(context_style->fill); } else { - std::cerr << "NRStyle::set: 'context-fill': 'context_style' is NULL" << std::endl; + // A marker in the defs section will result in ending up here. + //std::cerr << "NRStyle::set: 'context-fill': 'context_style' is NULL" << std::endl; } } else if ( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { if( context_style != NULL ) { style_fill = &(context_style->stroke); } else { - std::cerr << "NRStyle::set: 'context-stroke': 'context_style' is NULL" << std::endl; + //std::cerr << "NRStyle::set: 'context-stroke': 'context_style' is NULL" << std::endl; } } @@ -125,9 +126,10 @@ void NRStyle::set(SPStyle *style, SPStyle *context_style) } else if ( style_fill->isNone() ) { fill.clear(); } else if ( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { - std::cerr << "NRStyle::set: fill: context-fill: Double" << std::endl; + // A marker in the defs section will result in ending up here. + //std::cerr << "NRStyle::set: fill: context-fill: Double" << std::endl; } else if ( style_fill->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { - std::cerr << "NRStyle::set: fill: context-stroke: Double" << std::endl; + //std::cerr << "NRStyle::set: fill: context-stroke: Double" << std::endl; } else { g_assert_not_reached(); } @@ -150,13 +152,13 @@ void NRStyle::set(SPStyle *style, SPStyle *context_style) if( context_style != NULL ) { style_stroke = &(context_style->fill); } else { - std::cerr << "NRStyle::set: 'context-fill': 'context_style' is NULL" << std::endl; + //std::cerr << "NRStyle::set: 'context-fill': 'context_style' is NULL" << std::endl; } } else if ( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { if( context_style != NULL ) { style_stroke = &(context_style->stroke); } else { - std::cerr << "NRStyle::set: 'context-stroke': 'context_style' is NULL" << std::endl; + //std::cerr << "NRStyle::set: 'context-stroke': 'context_style' is NULL" << std::endl; } } @@ -174,9 +176,9 @@ void NRStyle::set(SPStyle *style, SPStyle *context_style) } else if ( style_stroke->isNone() ) { stroke.clear(); } else if ( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_FILL ) { - std::cerr << "NRStyle::set: stroke: context-fill: Double" << std::endl; + //std::cerr << "NRStyle::set: stroke: context-fill: Double" << std::endl; } else if ( style_stroke->paintOrigin == SP_CSS_PAINT_ORIGIN_CONTEXT_STROKE ) { - std::cerr << "NRStyle::set: stroke: context-stroke: Double" << std::endl; + //std::cerr << "NRStyle::set: stroke: context-stroke: Double" << std::endl; } else { g_assert_not_reached(); } diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index 026b1a11a..45e5747d6 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -159,6 +159,7 @@ void SPGroup::order_changed (Inkscape::XML::Node *child, Inkscape::XML::Node *ol } void SPGroup::update(SPCtx *ctx, unsigned int flags) { + // std::cout << "SPGroup::update(): " << (getId()?getId():"null") << std::endl; SPItemCtx *ictx, cctx; ictx = (SPItemCtx *) ctx; @@ -200,15 +201,15 @@ void SPGroup::update(SPCtx *ctx, unsigned int flags) { for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *group = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); if( this->parent ) { - group->setStyle(this->style, this->parent->style); - } else { - group->setStyle(this->style); + this->context_style = this->parent->context_style; } + group->setStyle(this->style, this->context_style); } } } void SPGroup::modified(guint flags) { + // std::cout << "SPGroup::modified(): " << (getId()?getId():"null") << std::endl; SPLPEItem::modified(flags); SPObject *child; @@ -356,15 +357,16 @@ void SPGroup::set(unsigned int key, gchar const* value) { } Inkscape::DrawingItem *SPGroup::show (Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + // std::cout << "SPGroup::show(): " << (getId()?getId():"null") << std::endl; Inkscape::DrawingGroup *ai; ai = new Inkscape::DrawingGroup(drawing); ai->setPickChildren(this->effectiveLayerMode(key) == SPGroup::LAYER); if( this->parent ) { - ai->setStyle(this->style, this->parent->style); - } else { - ai->setStyle(this->style); + this->context_style = this->parent->context_style; } + ai->setStyle(this->style, this->context_style); + this->_showChildren(drawing, ai, key, flags); return ai; } diff --git a/src/sp-object.cpp b/src/sp-object.cpp index 3b09d80e8..776b020d2 100644 --- a/src/sp-object.cpp +++ b/src/sp-object.cpp @@ -131,6 +131,7 @@ SPObject::SPObject() // polygon, text, tspan, tref, textPath, altGlyph, glyphRef, marker, linearGradient, radialGradient, // stop, pattern, clipPath, mask, filter, feImage, a, font, glyph, missing-glyph, foreignObject this->style = sp_style_new_from_object(this); + this->context_style = NULL; } SPObject::~SPObject() { diff --git a/src/sp-object.h b/src/sp-object.h index 669dfc713..ff80eaefc 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -267,6 +267,11 @@ public: */ SPStyle *style; + /** + * Represents the style that should be used to resolve 'context-fill' and 'context-stroke' + */ + SPStyle *context_style; + /// Switch containing next() method. struct ParentIteratorStrategy { static SPObject const *next(SPObject const *object) { diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 02b9969b3..16f9ec13b 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -126,6 +126,7 @@ Inkscape::XML::Node* SPShape::write(Inkscape::XML::Document *xml_doc, Inkscape:: } void SPShape::update(SPCtx* ctx, guint flags) { + // std::cout << "SPShape::update(): " << (getId()?getId():"null") << std::endl; SPLPEItem::update(ctx, flags); /* This stanza checks that an object's marker style agrees with @@ -146,10 +147,13 @@ void SPShape::update(SPCtx* ctx, guint flags) { for (SPItemView *v = ((SPItem *) (this))->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem); if (hasMarkers()) { - sh->setStyle(this->style, this->style); - sh->setChildrenStyle(style); // Resolve 'context-fill' and 'context-stroke' in children. - } else { - sh->setStyle(this->style, this->parent->style); + this->context_style = this->style; + sh->setStyle(this->style, this->context_style); + // Done at end: + // sh->setChildrenStyle(this->context_style); //Resolve 'context-xxx' in children. + } else if (this->parent) { + this->context_style = this->parent->context_style; + sh->setStyle(this->style, this->context_style); } } } @@ -188,6 +192,13 @@ void SPShape::update(SPCtx* ctx, guint flags) { for (SPItemView *v = this->display; v != NULL; v = v->next) { sp_shape_update_marker_view (this, v->arenaitem); } + + // Marker selector needs this here or marker previews are not rendered. + for (SPItemView *v = this->display; v != NULL; v = v->next) { + Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem); + + sh->setChildrenStyle(this->context_style); // Resolve 'context-xxx' in children. + } } } @@ -388,16 +399,22 @@ sp_shape_update_marker_view(SPShape *shape, Inkscape::DrawingItem *ai) } void SPShape::modified(unsigned int flags) { + // std::cout << "SPShape::modified(): " << (getId()?getId():"null") << std::endl; SPLPEItem::modified(flags); if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem); if (hasMarkers()) { - sh->setStyle(this->style, this->style); - sh->setChildrenStyle(style); // Resolve 'context-fill' and 'context-stroke' in children. - } else { - sh->setStyle(this->style, this->parent->style); + this->context_style = this->style; + sh->setStyle(this->style, this->context_style); + // Note: marker selector preview does not trigger SP_OBJECT_STYLE_MODIFIED_FLAG so + // this is not called when marker previews are generated, however there is code in + // SPShape::update() that calls this routine so we don't worry about it here. + sh->setChildrenStyle(this->context_style); // Resolve 'context-xxx' in children. + } else if (this->parent) { + this->context_style = this->parent->context_style; + sh->setStyle(this->style, this->context_style); } } } @@ -729,6 +746,7 @@ void SPShape::print(SPPrintContext* ctx) { } Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { + // std::cout << "SPShape::show(): " << (getId()?getId():"null") << std::endl; Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); bool has_markers = this->hasMarkers(); @@ -761,10 +779,12 @@ Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /* /* Update marker views */ sp_shape_update_marker_view (this, s); - s->setStyle(this->style,this->style); - s->setChildrenStyle(style); // Resolve 'context-fill' and 'context-stroke' in children. - } else { - s->setStyle(this->style, this->parent->style); + this->context_style = this->style; + s->setStyle(this->style, this->context_style); + s->setChildrenStyle(this->context_style); // Resolve 'context-xxx' in children. + } else if (this->parent) { + this->context_style = this->parent->context_style; + s->setStyle(this->style, this->context_style); } return s; } diff --git a/src/sp-use.cpp b/src/sp-use.cpp index cadd6a16c..ba3f4a9d7 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -281,10 +281,12 @@ gchar* SPUse::description() const { Inkscape::DrawingItem* SPUse::show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags) { + // std::cout << "SPUse::show: " << (getId()?getId():"null") << std::endl; Inkscape::DrawingGroup *ai = new Inkscape::DrawingGroup(drawing); ai->setPickChildren(false); - ai->setStyle(this->style, this->style); - + this->context_style = this->style; + ai->setStyle(this->style, this->context_style); + if (this->child) { Inkscape::DrawingItem *ac = this->child->invoke_show(drawing, key, flags); @@ -530,6 +532,7 @@ void SPUse::delete_self() { } void SPUse::update(SPCtx *ctx, unsigned flags) { + // std::cout << "SPUse::update: " << (getId()?getId():"null") << std::endl; SPItemCtx *ictx = (SPItemCtx *) ctx; SPItemCtx cctx = *ictx; @@ -580,7 +583,8 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); - g->setStyle(this->style, this->style); + this->context_style = this->style; + g->setStyle(this->style, this->context_style); } } @@ -593,6 +597,7 @@ void SPUse::update(SPCtx *ctx, unsigned flags) { } void SPUse::modified(unsigned int flags) { + // std::cout << "SPUse::modified: " << (getId()?getId():"null") << std::endl; if (flags & SP_OBJECT_MODIFIED_FLAG) { flags |= SP_OBJECT_PARENT_MODIFIED_FLAG; } @@ -602,7 +607,8 @@ void SPUse::modified(unsigned int flags) { if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) { for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingGroup *g = dynamic_cast<Inkscape::DrawingGroup *>(v->arenaitem); - g->setStyle(this->style, this->style); + this->context_style = this->style; + g->setStyle(this->style, this->context_style); } } diff --git a/src/widgets/stroke-marker-selector.cpp b/src/widgets/stroke-marker-selector.cpp index d5b43d132..e273faad7 100644 --- a/src/widgets/stroke-marker-selector.cpp +++ b/src/widgets/stroke-marker-selector.cpp @@ -578,25 +578,25 @@ gboolean MarkerComboBox::separator_cb (GtkTreeModel *model, GtkTreeIter *iter, g */ SPDocument *MarkerComboBox::ink_markers_preview_doc () { -gchar const *buffer = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" +gchar const *buffer = "<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" id=\"MarkerSample\">" " <defs id=\"defs\" />" " <g id=\"marker-start\">" -" <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:url(#sample);marker-mid:none;marker-end:none\"" +" <path style=\"fill:gray;stroke:darkgray;stroke-width:1.7;marker-start:url(#sample);marker-mid:none;marker-end:none\"" " d=\"M 12.5,13 L 25,13\" id=\"path1\" />" " <rect style=\"fill:none;stroke:none\" id=\"rect2\"" " width=\"25\" height=\"25\" x=\"0\" y=\"0\" />" " </g>" " <g id=\"marker-mid\">" -" <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:none;marker-mid:url(#sample);marker-end:none\"" +" <path style=\"fill:gray;stroke:darkgray;stroke-width:1.7;marker-start:none;marker-mid:url(#sample);marker-end:none\"" " d=\"M 0,113 L 12.5,113 L 25,113\" id=\"path11\" />" " <rect style=\"fill:none;stroke:none\" id=\"rect22\"" " width=\"25\" height=\"25\" x=\"0\" y=\"100\" />" " </g>" " <g id=\"marker-end\">" -" <path style=\"fill:none;stroke:black;stroke-width:1.7;marker-start:none;marker-mid:none;marker-end:url(#sample)\"" +" <path style=\"fill:gray;stroke:darkgray;stroke-width:1.7;marker-start:none;marker-mid:none;marker-end:url(#sample)\"" " d=\"M 0,213 L 12.5,213\" id=\"path111\" />" " <rect style=\"fill:none;stroke:none\" id=\"rect222\"" " width=\"25\" height=\"25\" x=\"0\" y=\"200\" />" |
