summaryrefslogtreecommitdiffstats
path: root/src/ui/tools/mesh-tool.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-11-08 14:05:30 +0000
committertavmjong-free <tavmjong@free.fr>2016-11-08 14:05:30 +0000
commit430533b9a259eb3dac44755306dfb0fddb34951d (patch)
tree95e0798b76202cee71aa0c0b866b0c443eaa66f7 /src/ui/tools/mesh-tool.cpp
parent[Bug #1574561] Italian translation update. (diff)
downloadinkscape-430533b9a259eb3dac44755306dfb0fddb34951d.tar.gz
inkscape-430533b9a259eb3dac44755306dfb0fddb34951d.zip
Improve mesh handling in Fill and Stroke dialog.
Create new meshes with alternating color/white pattern (makes it more obvious a mesh has been created). (bzr r15229)
Diffstat (limited to 'src/ui/tools/mesh-tool.cpp')
-rw-r--r--src/ui/tools/mesh-tool.cpp70
1 files changed, 24 insertions, 46 deletions
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index c6983b94a..87cbeef16 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -456,38 +456,33 @@ sp_mesh_context_fit_mesh_in_bbox (MeshTool *rc)
SPItem *item = *i;
SPStyle *style = item->style;
- if (style && (style->fill.isPaintserver())) {
- SPPaintServer *server = item->style->getFillPaintServer();
- if ( SP_IS_MESHGRADIENT(server) ) {
-
- SPMeshGradient *gradient = SP_MESHGRADIENT(server);
- SPCurve * outline = gradient->array.outline_path();
- Geom::OptRect mesh_bbox = outline->get_pathvector().boundsExact();
- outline->unref();
- Geom::OptRect item_bbox = item->geometricBounds();
-
- if ((*mesh_bbox).width() == 0) {
- continue;
- }
- if ((*mesh_bbox).height() == 0) {
- continue;
+ if (style) {
+
+ if (style->fill.isPaintserver()) {
+ SPPaintServer *server = item->style->getFillPaintServer();
+ if ( SP_IS_MESHGRADIENT(server) ) {
+
+ Geom::OptRect item_bbox = item->geometricBounds();
+ SPMeshGradient *gradient = SP_MESHGRADIENT(server);
+ if (gradient->array.fill_box( item_bbox )) {
+ changed = true;
+ }
}
- double scale_x = (*item_bbox).width() /(*mesh_bbox).width() ;
- double scale_y = (*item_bbox).height()/(*mesh_bbox).height();
-
- Geom::Translate t1(-(*mesh_bbox).min());
- Geom::Scale scale(scale_x,scale_y);
- Geom::Translate t2((*item_bbox).min());
- Geom::Affine transform = t1 * scale * t2;
- if (!transform.isIdentity() ) {
- gradient->array.transform(transform);
- gradient->array.write( gradient );
- gradient->requestModified(SP_OBJECT_MODIFIED_FLAG);
- changed = true;
+ }
+
+ if (style->stroke.isPaintserver()) {
+ SPPaintServer *server = item->style->getStrokePaintServer();
+ if ( SP_IS_MESHGRADIENT(server) ) {
+
+ Geom::OptRect item_bbox = item->visualBounds();
+ SPMeshGradient *gradient = SP_MESHGRADIENT(server);
+ if (gradient->array.fill_box( item_bbox )) {
+ changed = true;
+ }
}
}
+
}
-
}
if (changed) {
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
@@ -540,25 +535,8 @@ bool MeshTool::root_handler(GdkEvent* event) {
// always resets selection to the single object under cursor
sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time);
} else {
- sp_mesh_new_default(*this);
// Create a new gradient with default coordinates.
-// auto items= selection->items();
-// for(auto i=items.begin();i!=items.end();++i){
-// SPItem *item = *i;
-// SPGradientType new_type = SP_GRADIENT_TYPE_MESH;
-// Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
-
-// #ifdef DEBUG_MESH
-// std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl;
-// #endif
-// SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode);
-
-// SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode);
-// sp_gradient_reset_to_userspace(priv, item);
-// }
-
-// DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
-// _("Create default mesh"));
+ sp_mesh_new_default(*this);
}
ret = TRUE;