diff options
| author | Shlomi Fish <shlomif@shlomifish.org> | 2016-09-29 16:32:49 +0000 |
|---|---|---|
| committer | Shlomi Fish <shlomif@shlomifish.org> | 2016-09-29 16:32:49 +0000 |
| commit | f51ad5ea1ef1c96a93a64910cb263a360fc32d00 (patch) | |
| tree | 29626e107bf83f920304192ccacb3d538a4676e3 /src/ui/tools/mesh-tool.cpp | |
| parent | Remove "== true" and trailing whitespace. (diff) | |
| parent | fix tabs in src/main-cmdlineact (diff) | |
| download | inkscape-f51ad5ea1ef1c96a93a64910cb263a360fc32d00.tar.gz inkscape-f51ad5ea1ef1c96a93a64910cb263a360fc32d00.zip | |
Merged.
(bzr r15100.1.23)
Diffstat (limited to 'src/ui/tools/mesh-tool.cpp')
| -rw-r--r-- | src/ui/tools/mesh-tool.cpp | 35 |
1 files changed, 19 insertions, 16 deletions
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index f2cf8c4a2..aac8239f3 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -47,7 +47,7 @@ // Mesh specific #include "ui/tools/mesh-tool.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "display/sp-ctrlcurve.h" using Inkscape::DocumentUndo; @@ -161,9 +161,9 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) { // if (style && (style->fill.isPaintserver())) { // SPPaintServer *server = item->style->getFillPaintServer(); - // if ( SP_IS_MESH(server) ) { + // if ( SP_IS_MESHGRADIENT(server) ) { - // SPMesh *mg = SP_MESH(server); + // SPMeshGradient *mg = SP_MESHGRADIENT(server); // guint rows = 0;//mg->array.patches.size(); // for ( guint i = 0; i < rows; ++i ) { @@ -265,14 +265,18 @@ sp_mesh_context_select_prev (ToolBase *event_context) Returns true if mouse cursor over mesh edge. */ static bool -sp_mesh_context_is_over_line (MeshTool *rc, SPItem *item, Geom::Point event_p) +sp_mesh_context_is_over_line (MeshTool *rc, SPCtrlLine *line, Geom::Point event_p) { + if (!SP_IS_CTRLCURVE(line) ) { + return false; + } + SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop; //Translate mouse point into proper coord system rc->mousepoint_doc = desktop->w2d(event_p); - SPCtrlCurve *curve = SP_CTRLCURVE(item); + SPCtrlCurve *curve = SP_CTRLCURVE(line); Geom::BezierCurveN<3> b( curve->p0, curve->p1, curve->p2, curve->p3 ); Geom::Coord coord = b.nearestTime( rc->mousepoint_doc ); // Coord == double Geom::Point nearest = b( coord ); @@ -326,8 +330,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) SPDocument *doc = NULL; GrDrag *drag = rc->_grdrag; - std::map<SPMesh*, std::vector<guint> > points; - std::map<SPMesh*, SPItem*> items; + std::map<SPMeshGradient*, std::vector<guint> > points; + std::map<SPMeshGradient*, SPItem*> items; // Get list of selected draggers for each mesh. // For all selected draggers @@ -341,7 +345,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) if( d->point_type != POINT_MG_CORNER ) continue; // Find the gradient - SPMesh *gradient = SP_MESH( getGradient (d->item, d->fill_or_stroke) ); + SPMeshGradient *gradient = SP_MESHGRADIENT( getGradient (d->item, d->fill_or_stroke) ); // Collect points together for same gradient points[gradient].push_back( d->point_i ); @@ -350,8 +354,8 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) } // Loop over meshes. - for( std::map<SPMesh*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) { - SPMesh *mg = SP_MESH( iter->first ); + for( std::map<SPMeshGradient*, std::vector<guint> >::const_iterator iter = points.begin(); iter != points.end(); ++iter) { + SPMeshGradient *mg = SP_MESHGRADIENT( iter->first ); if( iter->second.size() > 0 ) { guint noperation = 0; switch (operation) { @@ -425,6 +429,7 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) /** Handles all keyboard and mouse input for meshs. +Note: node/handle events are take care of elsewhere. */ bool MeshTool::root_handler(GdkEvent* event) { static bool dragging; @@ -454,12 +459,10 @@ bool MeshTool::root_handler(GdkEvent* event) { if ( event->button.button == 1 ) { // Are we over a mesh line? bool over_line = false; - SPCtrlCurve *line = NULL; if (! drag->lines.empty()) { for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { - line = (SPCtrlCurve*) (*l); - over_line |= sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); + over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); } } @@ -594,7 +597,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (!drag->lines.empty()) { for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() ; ++l) { - over_line |= sp_mesh_context_is_over_line (this, (SPItem*)(*l), Geom::Point(event->motion.x, event->motion.y)); + over_line |= sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); } } @@ -625,8 +628,7 @@ bool MeshTool::root_handler(GdkEvent* event) { if (!drag->lines.empty()) { for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { - line = (SPCtrlLine*)(*l); - over_line = sp_mesh_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); + over_line = sp_mesh_context_is_over_line (this, *l, Geom::Point(event->motion.x, event->motion.y)); if (over_line) { break; @@ -925,6 +927,7 @@ bool MeshTool::root_handler(GdkEvent* event) { return ret; } +// Creates a new mesh gradient. static void sp_mesh_end_drag(MeshTool &rc) { SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop; Inkscape::Selection *selection = desktop->getSelection(); |
