Commit 32442aec authored by Tavmjong Bah's avatar Tavmjong Bah Committed by Tavmjong Bah

Implement copying of objects with mesh gradients.

(bzr r15171)
parent 5cb63d6c
This diff is collapsed.
...@@ -1096,7 +1096,7 @@ static SPColor default_color( SPItem *item ) { ...@@ -1096,7 +1096,7 @@ static SPColor default_color( SPItem *item ) {
color = paint.value.color; color = paint.value.color;
} else if ( paint.isPaintserver() ) { } else if ( paint.isPaintserver() ) {
SPObject const *server = item->style->getFillPaintServer(); SPObject const *server = item->style->getFillPaintServer();
if ( SP_IS_GRADIENT(server) ) { if ( SP_IS_GRADIENT(server) && SP_GRADIENT(server)->getVector() ) {
SPStop *firstStop = SP_GRADIENT(server)->getVector()->getFirstStop(); SPStop *firstStop = SP_GRADIENT(server)->getVector()->getFirstStop();
if ( firstStop ) { if ( firstStop ) {
color = firstStop->getEffectiveColor(); color = firstStop->getEffectiveColor();
......
...@@ -59,7 +59,7 @@ namespace Inkscape { ...@@ -59,7 +59,7 @@ namespace Inkscape {
namespace UI { namespace UI {
namespace Tools { namespace Tools {
static void sp_mesh_end_drag(MeshTool &rc); static void sp_mesh_new_default(MeshTool &rc);
const std::string& MeshTool::getPrefsPath() { const std::string& MeshTool::getPrefsPath() {
return MeshTool::prefsPath; return MeshTool::prefsPath;
...@@ -474,24 +474,25 @@ bool MeshTool::root_handler(GdkEvent* event) { ...@@ -474,24 +474,25 @@ bool MeshTool::root_handler(GdkEvent* event) {
// always resets selection to the single object under cursor // 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); sp_mesh_context_split_near_point(this, selection->items().front(), this->mousepoint_doc, event->button.time);
} else { } else {
sp_mesh_new_default(*this);
// Create a new gradient with default coordinates. // Create a new gradient with default coordinates.
auto items= selection->items(); // auto items= selection->items();
for(auto i=items.begin();i!=items.end();++i){ // for(auto i=items.begin();i!=items.end();++i){
SPItem *item = *i; // SPItem *item = *i;
SPGradientType new_type = SP_GRADIENT_TYPE_MESH; // SPGradientType new_type = SP_GRADIENT_TYPE_MESH;
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE; // Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
#ifdef DEBUG_MESH // #ifdef DEBUG_MESH
std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl; // std::cout << "sp_mesh_context_root_handler: creating new mesh on: " << (fsmode == Inkscape::FOR_FILL ? "Fill" : "Stroke") << std::endl;
#endif // #endif
SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode); // SPGradient *vector = sp_gradient_vector_for_object(desktop->getDocument(), desktop, item, fsmode);
SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode); // SPGradient *priv = sp_item_set_gradient(item, vector, new_type, fsmode);
sp_gradient_reset_to_userspace(priv, item); // sp_gradient_reset_to_userspace(priv, item);
} // }
DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH, // DocumentUndo::done(desktop->getDocument(), SP_VERB_CONTEXT_MESH,
_("Create default mesh")); // _("Create default mesh"));
} }
ret = TRUE; ret = TRUE;
...@@ -666,7 +667,7 @@ bool MeshTool::root_handler(GdkEvent* event) { ...@@ -666,7 +667,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
} }
} else { } else {
// Create a new mesh gradient // Create a new mesh gradient
sp_mesh_end_drag(*this); sp_mesh_new_default(*this);
} }
} else if (this->item_to_select) { } else if (this->item_to_select) {
if (over_line && line) { if (over_line && line) {
...@@ -931,7 +932,7 @@ bool MeshTool::root_handler(GdkEvent* event) { ...@@ -931,7 +932,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
} }
// Creates a new mesh gradient. // Creates a new mesh gradient.
static void sp_mesh_end_drag(MeshTool &rc) { static void sp_mesh_new_default(MeshTool &rc) {
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
Inkscape::Selection *selection = desktop->getSelection(); Inkscape::Selection *selection = desktop->getSelection();
SPDocument *document = desktop->getDocument(); SPDocument *document = desktop->getDocument();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment