summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-03-07 21:10:20 +0000
committertavmjong-free <tavmjong@free.fr>2016-03-07 21:10:20 +0000
commita3f684fa5156f66fdcd3d15cc469d84258807201 (patch)
tree11325ff3c5e14bb30f49c108e0861098b67a7a75 /src
parentdoes not zoom in to selection box if holding shift to zoom out (diff)
downloadinkscape-a3f684fa5156f66fdcd3d15cc469d84258807201.tar.gz
inkscape-a3f684fa5156f66fdcd3d15cc469d84258807201.zip
Add GUI for 'paint-order' property.
(bzr r14693)
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp76
-rw-r--r--src/desktop-style.h1
-rw-r--r--src/widgets/stroke-style.cpp107
-rw-r--r--src/widgets/stroke-style.h11
4 files changed, 184 insertions, 11 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index a81cbdd1f..c36bcee44 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -881,8 +881,7 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res
return QUERY_STYLE_NOTHING;
}
- int cap = -1;
- gdouble prev_cap = -1;
+ int prev_cap = -1;
bool same_cap = true;
int n_stroked = 0;
@@ -905,11 +904,9 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res
if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
same_cap = false;
prev_cap = style->stroke_linecap.value;
-
- cap = style->stroke_linecap.value;
}
- style_res->stroke_linecap.value = cap;
+ style_res->stroke_linecap.value = prev_cap;
style_res->stroke_linecap.set = true;
if (n_stroked == 0) {
@@ -935,8 +932,7 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
return QUERY_STYLE_NOTHING;
}
- int join = -1;
- gdouble prev_join = -1;
+ int prev_join = -1;
bool same_join = true;
int n_stroked = 0;
@@ -960,11 +956,9 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
same_join = false;
}
prev_join = style->stroke_linejoin.value;
-
- join = style->stroke_linejoin.value;
}
- style_res->stroke_linejoin.value = join;
+ style_res->stroke_linejoin.value = prev_join;
style_res->stroke_linejoin.set = true;
if (n_stroked == 0) {
@@ -980,6 +974,62 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
}
/**
+ * Write to style_res the paint order of a list of objects.
+ */
+int
+objects_query_paintorder (const std::vector<SPItem*> &objects, SPStyle *style_res)
+{
+ if (objects.empty()) {
+ /* No objects, set empty */
+ return QUERY_STYLE_NOTHING;
+ }
+
+ std::string prev_order;
+ bool same_order = true;
+ int n_order = 0;
+
+ for (std::vector<SPItem*>::const_iterator i = objects.begin(); i != objects.end(); ++i) {
+ SPObject *obj = *i;
+ if (!dynamic_cast<SPItem *>(obj)) {
+ continue;
+ }
+ SPStyle *style = obj->style;
+ if (!style) {
+ continue;
+ }
+
+ if ( style->stroke.isNone() ) {
+ continue;
+ }
+
+ n_order ++;
+
+ if (!prev_order.empty() && prev_order.compare( style->paint_order.value ) != 0) {
+ same_order = false;
+ }
+ if (style->paint_order.set) {
+ prev_order = style->paint_order.value;
+ }
+ }
+
+
+ g_free( style_res->paint_order.value );
+ style_res->paint_order.value= g_strdup( prev_order.c_str() );
+ style_res->paint_order.set = true;
+
+ if (n_order == 0) {
+ return QUERY_STYLE_NOTHING;
+ } else if (n_order == 1) {
+ return QUERY_STYLE_SINGLE;
+ } else {
+ if (same_order)
+ return QUERY_STYLE_MULTIPLE_SAME;
+ else
+ return QUERY_STYLE_MULTIPLE_DIFFERENT;
+ }
+}
+
+/**
* Write to style_res the average font size and spacing of objects.
*/
int
@@ -1763,6 +1813,8 @@ sp_desktop_query_style_from_list (const std::vector<SPItem*> &list, SPStyle *sty
} else if (property == QUERY_STYLE_PROPERTY_STROKEJOIN) {
return objects_query_strokejoin (list, style);
+ } else if (property == QUERY_STYLE_PROPERTY_PAINTORDER) {
+ return objects_query_paintorder (list, style);
} else if (property == QUERY_STYLE_PROPERTY_MASTEROPACITY) {
return objects_query_opacity (list, style);
@@ -1829,6 +1881,9 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
int result_strokemiterlimit = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
int result_strokecap = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKECAP);
int result_strokejoin = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_STROKEJOIN);
+
+ int result_paintorder = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_PAINTORDER);
+
int result_opacity = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_MASTEROPACITY);
int result_blur = sp_desktop_query_style (desktop, query, QUERY_STYLE_PROPERTY_BLUR);
@@ -1842,6 +1897,7 @@ sp_desktop_query_style_all (SPDesktop *desktop, SPStyle *query)
result_strokemiterlimit != QUERY_STYLE_NOTHING ||
result_strokecap != QUERY_STYLE_NOTHING ||
result_strokejoin != QUERY_STYLE_NOTHING ||
+ result_paintorder != QUERY_STYLE_NOTHING ||
result_blur != QUERY_STYLE_NOTHING);
}
diff --git a/src/desktop-style.h b/src/desktop-style.h
index bf05adadf..f3d6775a4 100644
--- a/src/desktop-style.h
+++ b/src/desktop-style.h
@@ -43,6 +43,7 @@ enum { // which property was queried (add when you need more)
QUERY_STYLE_PROPERTY_STROKEJOIN, // stroke join
QUERY_STYLE_PROPERTY_STROKECAP, // stroke cap
QUERY_STYLE_PROPERTY_STROKESTYLE, // markers, dasharray, miterlimit, stroke-width, stroke-cap, stroke-join
+ QUERY_STYLE_PROPERTY_PAINTORDER, // paint-order
QUERY_STYLE_PROPERTY_FONT_SPECIFICATION, //-inkscape-font-specification
QUERY_STYLE_PROPERTY_FONTFAMILY, // font-family
QUERY_STYLE_PROPERTY_FONTSTYLE, // font style
diff --git a/src/widgets/stroke-style.cpp b/src/widgets/stroke-style.cpp
index 43dffec56..e1e5ecc17 100644
--- a/src/widgets/stroke-style.cpp
+++ b/src/widgets/stroke-style.cpp
@@ -381,6 +381,46 @@ StrokeStyle::StrokeStyle() :
hb->pack_start(*endMarkerCombo, true, true, 0);
+ i++;
+
+ /* Paint order */
+ // TRANSLATORS: Paint order determines the order the 'fill', 'stroke', and 'markers are painted.
+ spw_label(table, _("Order:"), 0, i, NULL);
+
+ hb = spw_hbox(table, 4, 1, i);
+
+ Gtk::RadioButtonGroup paintOrderGrp;
+
+ paintOrderFSM = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-fsm"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "normal");
+ paintOrderFSM->set_tooltip_text(_("Fill, Stroke, Markers"));
+
+ paintOrderSFM = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-sfm"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "stroke fill markers");
+ paintOrderSFM->set_tooltip_text(_("Stroke, Fill, Markers"));
+
+ paintOrderFMS = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-fms"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "fill markers stroke");
+ paintOrderFMS->set_tooltip_text(_("Fill, Markers, Stroke"));
+
+ i++;
+
+ hb = spw_hbox(table, 4, 1, i);
+
+ paintOrderMFS = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-mfs"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "markers fill stroke");
+ paintOrderMFS->set_tooltip_text(_("Markers, Fill, Stroke"));
+
+ paintOrderSMF = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-smf"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "stroke markers fill");
+ paintOrderSMF->set_tooltip_text(_("Stroke, Markers, Fill"));
+
+ paintOrderMSF = makeRadioButton(paintOrderGrp, INKSCAPE_ICON("paint-order-msf"),
+ hb, STROKE_STYLE_BUTTON_ORDER, "markers stroke fill");
+ paintOrderMSF->set_tooltip_text(_("Markers, Stroke, Fill"));
+
+ i++;
+
setDesktop(desktop);
updateLine();
@@ -802,6 +842,43 @@ StrokeStyle::setCapType (unsigned const captype)
}
/**
+ * Sets the cap type for a line, and updates the stroke style widget's buttons
+ */
+void
+StrokeStyle::setPaintOrder (gchar const *paint_order)
+{
+ Gtk::RadioButton *tb = paintOrderFSM;
+
+ SPIPaintOrder temp;
+ temp.read( paint_order );
+
+ if (temp.layer[0] != SP_CSS_PAINT_ORDER_NORMAL) {
+
+ if (temp.layer[0] == SP_CSS_PAINT_ORDER_FILL) {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) {
+ tb = paintOrderFSM;
+ } else {
+ tb = paintOrderFMS;
+ }
+ } else if (temp.layer[0] == SP_CSS_PAINT_ORDER_STROKE) {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_FILL) {
+ tb = paintOrderSFM;
+ } else {
+ tb = paintOrderSMF;
+ }
+ } else {
+ if (temp.layer[1] == SP_CSS_PAINT_ORDER_STROKE) {
+ tb = paintOrderMSF;
+ } else {
+ tb = paintOrderMFS;
+ }
+ }
+
+ }
+ setPaintOrderButtons(tb);
+}
+
+/**
* Callback for when stroke style widget is updated, including markers, cap type,
* join type, etc.
*/
@@ -825,6 +902,9 @@ StrokeStyle::updateLine()
int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT);
int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKECAP);
int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_STROKEJOIN);
+
+ int result_order = sp_desktop_query_style (SP_ACTIVE_DESKTOP, &query, QUERY_STYLE_PROPERTY_PAINTORDER);
+
SPIPaint &targPaint = (kind == FILL) ? query.fill : query.stroke;
if (!sel || sel->isEmpty()) {
@@ -902,6 +982,13 @@ StrokeStyle::updateLine()
setCapButtons(NULL);
}
+ if (result_order != QUERY_STYLE_MULTIPLE_DIFFERENT &&
+ result_order != QUERY_STYLE_NOTHING ) {
+ setPaintOrder (query.paint_order.value);
+ } else {
+ setPaintOrder (NULL);
+ }
+
if (!sel || sel->isEmpty())
return;
@@ -1109,6 +1196,11 @@ void StrokeStyle::buttonToggledCB(StrokeStyleButton *tb, StrokeStyle *spw)
sp_repr_css_set_property(css, "stroke-linecap", tb->get_stroke_style());
sp_desktop_set_style (spw->desktop, css);
spw->setCapButtons(tb);
+ break;
+ case STROKE_STYLE_BUTTON_ORDER:
+ sp_repr_css_set_property(css, "paint-order", tb->get_stroke_style());
+ sp_desktop_set_style (spw->desktop, css);
+ //spw->setPaintButtons(tb);
}
sp_repr_css_attr_unref(css);
@@ -1143,6 +1235,21 @@ StrokeStyle::setCapButtons(Gtk::ToggleButton *active)
/**
+ * Updates the paint order style toggle buttons
+ */
+void
+StrokeStyle::setPaintOrderButtons(Gtk::ToggleButton *active)
+{
+ paintOrderFSM->set_active(active == paintOrderFSM);
+ paintOrderSFM->set_active(active == paintOrderSFM);
+ paintOrderFMS->set_active(active == paintOrderFMS);
+ paintOrderMFS->set_active(active == paintOrderMFS);
+ paintOrderSMF->set_active(active == paintOrderSMF);
+ paintOrderMSF->set_active(active == paintOrderMSF);
+}
+
+
+/**
* Updates the marker combobox to highlight the appropriate marker and scroll to
* that marker.
*/
diff --git a/src/widgets/stroke-style.h b/src/widgets/stroke-style.h
index 2605e1acf..d83067a4a 100644
--- a/src/widgets/stroke-style.h
+++ b/src/widgets/stroke-style.h
@@ -127,7 +127,8 @@ private:
/** List of valid types for the stroke-style radio-button widget */
enum StrokeStyleButtonType {
STROKE_STYLE_BUTTON_JOIN, ///< A button to set the line-join style
- STROKE_STYLE_BUTTON_CAP ///< A button to set the line-cap style
+ STROKE_STYLE_BUTTON_CAP, ///< A button to set the line-cap style
+ STROKE_STYLE_BUTTON_ORDER ///< A button to set the paint-order style
};
/**
@@ -158,8 +159,10 @@ private:
void setDashSelectorFromStyle(SPDashSelector *dsel, SPStyle *style);
void setJoinType (unsigned const jointype);
void setCapType (unsigned const captype);
+ void setPaintOrder (gchar const *paint_order);
void setJoinButtons(Gtk::ToggleButton *active);
void setCapButtons(Gtk::ToggleButton *active);
+ void setPaintOrderButtons(Gtk::ToggleButton *active);
void scaleLine();
void setScaledDash(SPCSSAttr *css, int ndash, double *dash, double offset, double scale);
void setMarkerColor(SPObject *marker, int loc, SPItem *item);
@@ -204,6 +207,12 @@ private:
StrokeStyleButton *capButt;
StrokeStyleButton *capRound;
StrokeStyleButton *capSquare;
+ StrokeStyleButton *paintOrderFSM;
+ StrokeStyleButton *paintOrderSFM;
+ StrokeStyleButton *paintOrderFMS;
+ StrokeStyleButton *paintOrderMFS;
+ StrokeStyleButton *paintOrderSMF;
+ StrokeStyleButton *paintOrderMSF;
SPDashSelector *dashSelector;
gboolean update;