summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2014-04-24 12:53:30 +0000
committertavmjong-free <tavmjong@free.fr>2014-04-24 12:53:30 +0000
commit20452bbd40fe1d93b2093cb5dea8e4cb8ae967d3 (patch)
treece0ca88db9385121a88ce92d2b407ebb7e9734c7 /src
parentClean up of style code, removal of SPFontStyle. Step 2. (diff)
downloadinkscape-20452bbd40fe1d93b2093cb5dea8e4cb8ae967d3.tar.gz
inkscape-20452bbd40fe1d93b2093cb5dea8e4cb8ae967d3.zip
Clean up of style code: refactor marker properties. Step 3.
(bzr r13301)
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp8
-rw-r--r--src/graphlayout.cpp4
-rw-r--r--src/id-clash.cpp2
-rw-r--r--src/selection-chemistry.cpp6
-rw-r--r--src/sp-shape.cpp6
-rw-r--r--src/style-internal.h2
-rw-r--r--src/style.cpp48
-rw-r--r--src/style.h7
-rw-r--r--src/widgets/stroke-style.cpp7
9 files changed, 49 insertions, 41 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index a7097b4c9..37f537cc5 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -722,10 +722,10 @@ objects_query_strokewidth (GSList *objects, SPStyle *style_res)
}
if ( style->stroke.isNone() && !(
- style->marker[SP_MARKER_LOC].set || // stroke width affects markers, so if there's no stroke but only markers then we should
- style->marker[SP_MARKER_LOC_START].set || // still calculate the stroke width
- style->marker[SP_MARKER_LOC_MID].set ||
- style->marker[SP_MARKER_LOC_END].set))
+ style->marker.set || // stroke width affects markers, so if there's no
+ style->marker_start.set || // stroke but only markers then we should
+ style->marker_mid.set || // still calculate the stroke width
+ style->marker_end.set))
{
continue;
}
diff --git a/src/graphlayout.cpp b/src/graphlayout.cpp
index 7e10ccca1..18159cb41 100644
--- a/src/graphlayout.cpp
+++ b/src/graphlayout.cpp
@@ -195,8 +195,8 @@ void graphlayout(GSList const *const items) {
unsigned v=v_pair->second;
//cout << "Edge: (" << u <<","<<v<<")"<<endl;
es.push_back(make_pair(u,v));
- if(conn->style->marker[SP_MARKER_LOC_END].set) {
- if(directed && strcmp(conn->style->marker[SP_MARKER_LOC_END].value,"none")) {
+ if(conn->style->marker_end.set) {
+ if(directed && strcmp(conn->style->marker_end.value,"none")) {
scy.push_back(new SimpleConstraint(v, u,
(ideal_connector_length * directed_edge_height_modifier)));
}
diff --git a/src/id-clash.cpp b/src/id-clash.cpp
index 7a0bb9c4a..8d852315f 100644
--- a/src/id-clash.cpp
+++ b/src/id-clash.cpp
@@ -161,7 +161,7 @@ find_references(SPObject *elem, refmap_type *refmap)
/* check for url(#...) references in markers */
const gchar *markers[4] = { "", "marker-start", "marker-mid", "marker-end" };
for (unsigned i = SP_MARKER_LOC_START; i < SP_MARKER_LOC_QTY; i++) {
- const gchar *value = style->marker[i].value;
+ const gchar *value = style->marker_ptrs[i]->value;
if (value) {
gchar *uri = extract_uri(value);
if (uri && uri[0] == '#') {
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 5a981c6a0..868a9d743 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -2076,9 +2076,9 @@ GSList *sp_get_same_stroke_style(SPItem *sel, GSList *src, SPSelectStrokeStyleTy
match = true;
int len = sizeof(sel_style->marker)/sizeof(SPIString);
for (int i = 0; i < len; i++) {
- match = (sel_style->marker[i].set == iter_style->marker[i].set);
- if (sel_style->marker[i].set && iter_style->marker[i].set &&
- (strcmp(sel_style->marker[i].value, iter_style->marker[i].value))) {
+ match = (sel_style->marker_ptrs[i]->set == iter_style->marker_ptrs[i]->set);
+ if (sel_style->marker_ptrs[i]->set && iter_style->marker_ptrs[i]->set &&
+ (strcmp(sel_style->marker_ptrs[i]->value, iter_style->marker_ptrs[i]->value))) {
match = false;
break;
}
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index b3a331cba..61d35e6ff 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -77,7 +77,7 @@ void SPShape::build(SPDocument *document, Inkscape::XML::Node *repr) {
SPLPEItem::build(document, repr);
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
- sp_shape_set_marker (this, i, this->style->marker[i].value);
+ sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value);
}
}
@@ -136,7 +136,7 @@ void SPShape::update(SPCtx* ctx, guint flags) {
* match the style.
*/
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
- sp_shape_set_marker (this, i, this->style->marker[i].value);
+ sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value);
}
if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
@@ -723,7 +723,7 @@ Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*
* match the style.
*/
for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) {
- sp_shape_set_marker (this, i, this->style->marker[i].value);
+ sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value);
}
if (this->hasMarkers ()) {
diff --git a/src/style-internal.h b/src/style-internal.h
index 665c7abd4..131b77b77 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -137,7 +137,7 @@ class SPIBase {
// To do: make private
public:
- Glib::ustring name; // Make const when we switch to C++11 and change marker[] initializer
+ Glib::ustring name; // Make const
unsigned inherits : 1; // Property inherits by default from parent.
unsigned set : 1; // Property has been explicitly set (vs. inherited).
unsigned inherit : 1; // Property value set to 'inherit'.
diff --git a/src/style.cpp b/src/style.cpp
index fa99d278c..2d66284d4 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -165,9 +165,12 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
stroke_dasharray(), // SPIDashArray
stroke_dashoffset("stroke-dashoffset", 0.0 ), // SPILength for now
- stroke_opacity( "stroke-opacity", SP_SCALE24_MAX),
+ stroke_opacity( "stroke-opacity", SP_SCALE24_MAX ),
-// marker({ "marker", "marker-start", "marker-mid", "marker-end" }), C++11
+ marker( "marker" ), // SPIString
+ marker_start( "marker-start" ), // SPIString
+ marker_mid( "marker-mid" ), // SPIString
+ marker_end( "marker-end" ), // SPIString
// Filter properties
filter(),
@@ -252,10 +255,11 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
// for setting up signals... 'fill', 'stroke' already done
filter.setStylePointer( this );
- marker[SP_MARKER_LOC] = SPIString( "marker" );
- marker[SP_MARKER_LOC_START] = SPIString( "marker-start" );
- marker[SP_MARKER_LOC_MID] = SPIString( "marker-mid" );
- marker[SP_MARKER_LOC_END] = SPIString( "marker-end" );
+ // Used to iterate over markers
+ marker_ptrs[SP_MARKER_LOC] = &marker;
+ marker_ptrs[SP_MARKER_LOC_START] = &marker_start;
+ marker_ptrs[SP_MARKER_LOC_MID] = &marker_mid;
+ marker_ptrs[SP_MARKER_LOC_END] = &marker_end;
// This might be too resource hungary... but for now it possible to loop over properties
@@ -318,10 +322,10 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &stroke_dashoffset );
_properties.push_back( &stroke_opacity );
- _properties.push_back( &marker[SP_MARKER_LOC] );
- _properties.push_back( &marker[SP_MARKER_LOC_START] );
- _properties.push_back( &marker[SP_MARKER_LOC_MID] );
- _properties.push_back( &marker[SP_MARKER_LOC_END] );
+ _properties.push_back( &marker );
+ _properties.push_back( &marker_start );
+ _properties.push_back( &marker_mid );
+ _properties.push_back( &marker_end );
_properties.push_back( &paint_order );
@@ -397,10 +401,10 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
// _propmap.insert( std::make_pair( stroke_dashoffset.name, reinterpret_cast<SPIBasePtr>(&SPStyle::stroke_dashoffset ) ) );
// _propmap.insert( std::make_pair( stroke_opacity.name, reinterpret_cast<SPIBasePtr>(&SPStyle::stroke_opacity ) ) );
- // //_propmap.insert( std::make_pair( marker[SP_MARKER_LOC].name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker[SP_MARKER_LOC] ) ) );
- // //_propmap.insert( std::make_pair( marker[SP_MARKER_LOC_START].name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker[SP_MARKER_LOC_START] ) ) );
- // //_propmap.insert( std::make_pair( marker[SP_MARKER_LOC_MID].name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker[SP_MARKER_LOC_MID] ) ) );
- // //_propmap.insert( std::make_pair( marker[SP_MARKER_LOC_END].name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker[SP_MARKER_LOC_END] ) ) );
+ // _propmap.insert( std::make_pair( marker.name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker ) ) );
+ // _propmap.insert( std::make_pair( marker_start.name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker_start ) ) );
+ // _propmap.insert( std::make_pair( marker_mid.name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker_mid ) ) );
+ // _propmap.insert( std::make_pair( marker_end.name, reinterpret_cast<SPIBasePtr>(&SPStyle::marker_end ) ) );
// _propmap.insert( std::make_pair( paint_order.name, reinterpret_cast<SPIBasePtr>(&SPStyle::paint_order ) ) );
@@ -798,19 +802,19 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
break;
case SP_PROP_MARKER:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker[SP_MARKER_LOC].readIfUnset( val );
+ marker.readIfUnset( val );
break;
case SP_PROP_MARKER_START:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker[SP_MARKER_LOC_START].readIfUnset( val );
+ marker_start.readIfUnset( val );
break;
case SP_PROP_MARKER_MID:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker[SP_MARKER_LOC_MID].readIfUnset( val );
+ marker_mid.readIfUnset( val );
break;
case SP_PROP_MARKER_END:
/* TODO: Call sp_uri_reference_resolve(SPDocument *document, guchar const *uri) */
- marker[SP_MARKER_LOC_END].readIfUnset( val );
+ marker_end.readIfUnset( val );
break;
case SP_PROP_SHAPE_RENDERING:
shape_rendering.readIfUnset( val );
@@ -1572,16 +1576,16 @@ sp_style_unset_property_attrs(SPObject *o)
if (style->stroke_linejoin.set) {
repr->setAttribute("stroke-linejoin", NULL);
}
- if (style->marker[SP_MARKER_LOC].set) {
+ if (style->marker.set) {
repr->setAttribute("marker", NULL);
}
- if (style->marker[SP_MARKER_LOC_START].set) {
+ if (style->marker_start.set) {
repr->setAttribute("marker-start", NULL);
}
- if (style->marker[SP_MARKER_LOC_MID].set) {
+ if (style->marker_mid.set) {
repr->setAttribute("marker-mid", NULL);
}
- if (style->marker[SP_MARKER_LOC_END].set) {
+ if (style->marker_end.set) {
repr->setAttribute("marker-end", NULL);
}
if (style->stroke_opacity.set) {
diff --git a/src/style.h b/src/style.h
index 9784ee48d..9e592b78f 100644
--- a/src/style.h
+++ b/src/style.h
@@ -205,8 +205,11 @@ public:
SPIScale24 stroke_opacity;
/** Marker list */
- SPIString marker[SP_MARKER_LOC_QTY];
-
+ SPIString marker;
+ SPIString marker_start;
+ SPIString marker_mid;
+ SPIString marker_end;
+ SPIString* marker_ptrs[SP_MARKER_LOC_QTY];
/** Filter effect */
SPIFilter filter;
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index a4cca9472..0e0a4fd72 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -581,7 +581,8 @@ StrokeStyle::forkMarker(SPObject *marker, int loc, SPItem *item)
Glib::ustring urlId = Glib::ustring::format("url(#", marker->getRepr()->attribute("id"), ")");
unsigned int refs = 0;
for (int i = SP_MARKER_LOC_START; i < SP_MARKER_LOC_QTY; i++) {
- if (item->style->marker[i].set && !strcmp(urlId.c_str(), item->style->marker[i].value)) {
+ if (item->style->marker_ptrs[i]->set &&
+ !strcmp(urlId.c_str(), item->style->marker_ptrs[i]->value)) {
refs++;
}
}
@@ -1176,11 +1177,11 @@ StrokeStyle::updateAllMarkers(GSList const *objects)
combo->setDesktop(desktop);
- if (object->style->marker[keyloc[i].loc].value != NULL && !all_texts) {
+ if (object->style->marker_ptrs[keyloc[i].loc]->value != NULL && !all_texts) {
// If the object has this type of markers,
// Extract the name of the marker that the object uses
- SPObject *marker = getMarkerObj(object->style->marker[keyloc[i].loc].value, object->document);
+ SPObject *marker = getMarkerObj(object->style->marker_ptrs[keyloc[i].loc]->value, object->document);
// Scroll the combobox to that marker
combo->set_current(marker);