summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp26
-rw-r--r--src/ui/clipboard.cpp44
-rw-r--r--src/ui/widget/selected-style.cpp12
-rw-r--r--src/ui/widget/selected-style.h12
4 files changed, 78 insertions, 16 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 6c8095d53..072a38eec 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -29,6 +29,7 @@
#include "object/sp-flowdiv.h"
#include "object/sp-flowregion.h"
#include "object/sp-flowtext.h"
+#include "object/sp-hatch.h"
#include "object/sp-linear-gradient.h"
#include "object/sp-path.h"
#include "object/sp-pattern.h"
@@ -184,7 +185,7 @@ sp_desktop_apply_css_recursive(SPObject *o, SPCSSAttr *css, bool skip_lines)
void sp_desktop_set_style(SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current){
return sp_desktop_set_style(desktop->getSelection(), desktop, css, change, write_current);
}
-
+
void
sp_desktop_set_style(Inkscape::ObjectSet *set, SPDesktop *desktop, SPCSSAttr *css, bool change, bool write_current)
{
@@ -533,7 +534,7 @@ objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_re
|| dynamic_cast<SPFlowtspan *>(parent) || dynamic_cast<SPFlowline*>(parent));
// 1. Bail out with QUERY_STYLE_MULTIPLE_DIFFERENT if necessary
-
+
// cppcheck-suppress comparisonOfBoolWithInt
if ((!paintImpossible) && (!paint->isSameType(*paint_res) || (paint_res->set != paint_effectively_set))) {
return QUERY_STYLE_MULTIPLE_DIFFERENT; // different types of paint
@@ -548,6 +549,8 @@ objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_re
SPLinearGradient *linear_res = dynamic_cast<SPLinearGradient *>(server_res);
SPRadialGradient *radial_res = linear_res ? nullptr : dynamic_cast<SPRadialGradient *>(server_res);
SPPattern *pattern_res = (linear_res || radial_res) ? nullptr : dynamic_cast<SPPattern *>(server_res);
+ SPHatch *hatch_res = (linear_res || radial_res || pattern_res) ? nullptr : dynamic_cast<SPHatch *>(server_res);
+
if (linear_res) {
SPLinearGradient *linear = dynamic_cast<SPLinearGradient *>(server);
if (!linear) {
@@ -581,6 +584,17 @@ objects_query_fillstroke (const std::vector<SPItem*> &objects, SPStyle *style_re
if (pat_res != pat) {
return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots
}
+ } else if (hatch_res) {
+ SPHatch *hatch = dynamic_cast<SPHatch *>(server);
+ if (!hatch) {
+ return QUERY_STYLE_MULTIPLE_DIFFERENT; // different kind of server
+ }
+
+ SPHatch *hat = SP_HATCH (server)->rootHatch();
+ SPHatch *hat_res = SP_HATCH (server_res)->rootHatch();
+ if (hat_res != hat) {
+ return QUERY_STYLE_MULTIPLE_DIFFERENT; // different pattern roots
+ }
}
}
@@ -1002,7 +1016,7 @@ objects_query_paintorder (const std::vector<SPItem*> &objects, SPStyle *style_re
}
}
-
+
g_free( style_res->paint_order.value );
style_res->paint_order.value= g_strdup( prev_order.c_str() );
style_res->paint_order.set = true;
@@ -1066,8 +1080,8 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
// Quick way of getting document scale. Should be same as:
// item->document->getDocumentScale().Affine().descrim()
double doc_scale = Geom::Affine(item->i2dt_affine()).descrim();
-
- double dummy = style->font_size.computed * doc_scale;
+
+ double dummy = style->font_size.computed * doc_scale;
if (!std::isnan(dummy)) {
size += dummy; /// \todo FIXME: we assume non-% units here
} else {
@@ -1199,7 +1213,7 @@ objects_query_fontnumbers (const std::vector<SPItem*> &objects, SPStyle *style_r
}
}
- // Used by text toolbar unset 'line-height'
+ // Used by text toolbar unset 'line-height'
style_res->line_height.set = lineheight_set;
if (texts > 1) {
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index b9b4ce605..dd1679dfc 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -54,6 +54,7 @@
#include "object/sp-clippath.h"
#include "object/sp-defs.h"
#include "object/sp-gradient-reference.h"
+#include "object/sp-hatch.h"
#include "object/sp-item-transform.h"
#include "object/sp-linear-gradient.h"
#include "object/sp-marker.h"
@@ -109,6 +110,7 @@ private:
void _copyUsedDefs(SPItem *);
void _copyGradient(SPGradient *);
void _copyPattern(SPPattern *);
+ void _copyHatch(SPHatch *);
void _copyTextPath(SPTextPath *);
Inkscape::XML::Node *_copyNode(Inkscape::XML::Node *, Inkscape::XML::Document *, Inkscape::XML::Node *);
@@ -324,7 +326,7 @@ void ClipboardManagerImpl::copySymbol(Inkscape::XML::Node* symbol, gchar const*
if (cmobj && !user_symbol) { // convert only stock symbols
if (!Geom::are_near(scale_units, 1.0, Geom::EPSILON)) {
dynamic_cast<SPGroup *>(cmobj)->scaleChildItemsRec(Geom::Scale(scale_units),
- Geom::Point(0, SP_ACTIVE_DESKTOP->getDocument()->getHeight().value("px")),
+ Geom::Point(0, SP_ACTIVE_DESKTOP->getDocument()->getHeight().value("px")),
false);
}
}
@@ -620,9 +622,9 @@ Glib::ustring ClipboardManagerImpl::getShapeOrTextObjectId(SPDesktop *desktop)
// https://bugs.launchpad.net/inkscape/+bug/1293979
// basically, when we do a depth-first search, we're stopping
// at the first object to be <svg:path> or <svg:text>.
- // but that could then return the id of the object's
+ // but that could then return the id of the object's
// clip path or mask, not the original path!
-
+
SPDocument *tempdoc = _retrieveClipboard(); // any target will do here
if ( tempdoc == nullptr ) {
_userWarn(desktop, _("Nothing on the clipboard."));
@@ -759,7 +761,7 @@ void ClipboardManagerImpl::_copySelection(ObjectSet *selection)
// write the complete accumulated transform passed to us
// (we're dealing with unattached representations, so we write to their attributes
// instead of using sp_item_set_transform)
-
+
SPUse *use=dynamic_cast<SPUse *>(item);
if( use && use->get_original() && use->get_original()->parent) {
if (selection->includes(use->get_original())){ //we are copying something whose parent is also copied (!)
@@ -823,6 +825,10 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
if ( pattern ) {
_copyPattern(pattern);
}
+ SPHatch *hatch = dynamic_cast<SPHatch *>(server);
+ if ( hatch ) {
+ _copyHatch(hatch);
+ }
}
if (style && (style->stroke.isPaintserver())) {
SPPaintServer *server = item->style->getStrokePaintServer();
@@ -833,6 +839,10 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
if ( pattern ) {
_copyPattern(pattern);
}
+ SPHatch *hatch = dynamic_cast<SPHatch *>(server);
+ if ( hatch ) {
+ _copyHatch(hatch);
+ }
}
// For shapes, copy all of the shape's markers
@@ -882,7 +892,7 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item)
}
}
}
-
+
// Copy filters
if (style->getFilter()) {
SPObject *filter = style->getFilter();
@@ -957,6 +967,30 @@ void ClipboardManagerImpl::_copyPattern(SPPattern *pattern)
}
}
+/**
+ * Copy a single hatch to the clipboard document's defs element.
+ */
+void ClipboardManagerImpl::_copyHatch(SPHatch *hatch)
+{
+ // climb up the references, copying each one in the chain
+ while (hatch) {
+ _copyNode(hatch->getRepr(), _doc, _defs);
+
+ for (auto& child: hatch->children) {
+ SPItem *childItem = dynamic_cast<SPItem *>(&child);
+ if (childItem) {
+ _copyUsedDefs(childItem);
+ }
+ }
+ if (hatch->ref){
+ hatch = hatch->ref->getObject();
+ }
+ else{
+ hatch = nullptr;
+ }
+ }
+}
+
/**
* Copy a text path to the clipboard's defs element.
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index 0adf7997e..53ec6c1a2 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -26,6 +26,7 @@
#include "include/gtkmm_version.h"
+#include "object/sp-hatch.h"
#include "object/sp-linear-gradient.h"
#include "object/sp-mesh-gradient.h"
#include "object/sp-namedview.h"
@@ -189,6 +190,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_pattern[i].show_all();
__pattern[i] = (i == SS_FILL)? (_("Pattern fill")) : (_("Pattern stroke"));
+ _hatch[i].set_markup (_("Hatch"));
+ sp_set_font_size_smaller (GTK_WIDGET(_hatch[i].gobj()));
+ _hatch[i].show_all();
+ __hatch[i] = (i == SS_FILL)? (_("Hatch fill")) : (_("Hatch stroke"));
+
_lgradient[i].set_markup (_("<b>L</b>"));
sp_set_font_size_smaller (GTK_WIDGET(_lgradient[i].gobj()));
_lgradient[i].show_all();
@@ -993,6 +999,10 @@ SelectedStyle::update()
place->add(_pattern[i]);
place->set_tooltip_text(__pattern[i]);
_mode[i] = SS_PATTERN;
+ } else if (SP_IS_HATCH (server)) {
+ place->add(_hatch[i]);
+ place->set_tooltip_text(__hatch[i]);
+ _mode[i] == SS_HATCH;
}
} else {
g_warning ("file %s: line %d: Unknown paint server", __FILE__, __LINE__);
@@ -1287,7 +1297,7 @@ RotateableSwatch::do_motion(double by, guint modifier) {
if (pixbuf != nullptr) {
cr = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 16, 16);
- g_object_unref(pixbuf);
+ g_object_unref(pixbuf);
gdk_window_set_cursor(gtk_widget_get_window(w), cr);
g_object_unref(cr);
cr = nullptr;
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index 2f76b7a11..5134b4ab3 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -52,7 +52,8 @@ enum {
SS_MGRADIENT,
#endif
SS_MANY,
- SS_COLOR
+ SS_COLOR,
+ SS_HATCH
};
enum {
@@ -62,7 +63,7 @@ enum {
class SelectedStyle;
-class RotateableSwatch: public Rotateable
+class RotateableSwatch: public Rotateable
{
public:
RotateableSwatch(SelectedStyle *parent, guint mode);
@@ -88,7 +89,7 @@ private:
bool cr_set;
};
-class RotateableStrokeWidth: public Rotateable
+class RotateableStrokeWidth: public Rotateable
{
public:
RotateableStrokeWidth(SelectedStyle *parent);
@@ -158,6 +159,9 @@ protected:
Gtk::Label _pattern[2];
Glib::ustring __pattern[2];
+ Gtk::Label _hatch[2];
+ Glib::ustring __hatch[2];
+
Gtk::Label _lgradient[2];
Glib::ustring __lgradient[2];
@@ -264,7 +268,7 @@ protected:
Gtk::MenuItem _popup_unset[2];
Gtk::MenuItem _popup_remove[2];
- Gtk::Menu _popup_sw;
+ Gtk::Menu _popup_sw;
Gtk::RadioButtonGroup _sw_group;
std::vector<Gtk::RadioMenuItem*> _unit_mis;
void on_popup_units(Inkscape::Util::Unit const *u);