diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2015-12-06 12:53:50 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marcjeanmougin@free.fr> | 2015-12-06 12:53:50 +0000 |
| commit | 049a747614778df4ee75bd07b71a8afe1688425f (patch) | |
| tree | 85fda527d6881a2f6cb27d33300537606cc37c3c /src/ui | |
| parent | cppification: GSList replaced by vectors (mostly related to guides and grids) (diff) | |
| download | inkscape-049a747614778df4ee75bd07b71a8afe1688425f.tar.gz inkscape-049a747614778df4ee75bd07b71a8afe1688425f.zip | |
cppification: GSList replaced by vectors (mostly related to gradients and meshes)
(bzr r14504.1.2)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/tools/gradient-tool.cpp | 38 | ||||
| -rw-r--r-- | src/ui/tools/mesh-tool.cpp | 32 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.cpp | 2 |
3 files changed, 35 insertions, 37 deletions
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp index bcb0b12b7..9d8101cc4 100644 --- a/src/ui/tools/gradient-tool.cpp +++ b/src/ui/tools/gradient-tool.cpp @@ -225,13 +225,13 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi std::vector<Geom::Point> coords; // for all selected draggers - for (GList *i = drag->selected; i != NULL; i = i->next) { - GrDragger *dragger = (GrDragger *) i->data; + for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end() ; ++i ) { + GrDragger *dragger = *i; // remember the coord of the dragger to reselect it later coords.push_back(dragger->point); // for all draggables of dragger - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *d = (GrDraggable *) j->data; + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { + GrDraggable *d = *j; // find the gradient SPGradient *gradient = getGradient(d->item, d->fill_or_stroke); @@ -315,9 +315,9 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc) if (g_slist_length(these_stops) == 0 && drag->numSelected() == 1) { // if a single stop is selected, add between that stop and the next one - GrDragger *dragger = (GrDragger *) drag->selected->data; - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *d = (GrDraggable *) j->data; + GrDragger *dragger = *(drag->selected.begin()); + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) { + GrDraggable *d = *j; if (d->point_type == POINT_RG_FOCUS) { /* * There are 2 draggables at the center (start) of a radial gradient @@ -482,9 +482,9 @@ bool GradientTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlLine *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlLine*) l->data; + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { + line = *l; over_line |= sp_gradient_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); } } @@ -588,9 +588,9 @@ bool GradientTool::root_handler(GdkEvent* event) { bool over_line = false; - if (drag->lines) { - for (GSList *l = drag->lines; l != NULL; l = l->next) { - over_line |= sp_gradient_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y)); + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end(); ++l) { + over_line |= sp_gradient_context_is_over_line (this, (SPItem*) (*l), Geom::Point(event->motion.x, event->motion.y)); } } @@ -613,12 +613,10 @@ bool GradientTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlLine *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlLine*) l->data; + if (!drag->lines.empty()) { + for (std::vector<SPCtrlLine *>::const_iterator l = drag->lines.begin(); l != drag->lines.end() && (!over_line); ++l) { + line = *l; over_line = sp_gradient_context_is_over_line (this, (SPItem*) line, Geom::Point(event->motion.x, event->motion.y)); - if (over_line) - break; } } @@ -663,7 +661,7 @@ bool GradientTool::root_handler(GdkEvent* event) { } } else { // click in an empty space; do the same as Esc - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { selection->clear(); @@ -719,7 +717,7 @@ bool GradientTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { Inkscape::SelectionHelper::selectNone(desktop); diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp index 794296329..e000307ee 100644 --- a/src/ui/tools/mesh-tool.cpp +++ b/src/ui/tools/mesh-tool.cpp @@ -332,11 +332,11 @@ sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation ) // Get list of selected draggers for each mesh. // For all selected draggers - for (GList *i = drag->selected; i != NULL; i = i->next) { - GrDragger *dragger = (GrDragger *) i->data; + for (std::set<GrDragger *>::const_iterator i = drag->selected.begin(); i != drag->selected.end(); ++i) { + GrDragger *dragger = *i; // For all draggables of dragger - for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { - GrDraggable *d = (GrDraggable *) j->data; + for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end() ; ++j) { + GrDraggable *d = *j; // Only mesh corners if( d->point_type != POINT_MG_CORNER ) continue; @@ -457,9 +457,9 @@ bool MeshTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlCurve *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlCurve*) l->data; + 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)); } } @@ -593,9 +593,9 @@ bool MeshTool::root_handler(GdkEvent* event) { // Change cursor shape if over line bool over_line = false; - if (drag->lines) { - for (GSList *l = drag->lines; l != NULL; l = l->next) { - over_line |= sp_mesh_context_is_over_line (this, (SPItem*) l->data, Geom::Point(event->motion.x, event->motion.y)); + 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)); } } @@ -624,9 +624,9 @@ bool MeshTool::root_handler(GdkEvent* event) { bool over_line = false; SPCtrlLine *line = NULL; - if (drag->lines) { - for (GSList *l = drag->lines; (l != NULL) && (!over_line); l = l->next) { - line = (SPCtrlLine*) l->data; + 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)); if (over_line) { @@ -678,7 +678,7 @@ bool MeshTool::root_handler(GdkEvent* event) { } } else { // click in an empty space; do the same as Esc - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { selection->clear(); @@ -724,7 +724,7 @@ bool MeshTool::root_handler(GdkEvent* event) { break; case GDK_KEY_Escape: - if (drag->selected) { + if (!drag->selected.empty()) { drag->deselectAll(); } else { selection->clear(); @@ -841,7 +841,7 @@ bool MeshTool::root_handler(GdkEvent* event) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - if ( drag->selected ) { + if ( !drag->selected.empty() ) { std::cout << "Deleting mesh stops not implemented yet" << std::endl; ret = TRUE; } diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp index bf7b61b61..abac2c091 100644 --- a/src/ui/tools/tool-base.cpp +++ b/src/ui/tools/tool-base.cpp @@ -924,7 +924,7 @@ void ToolBase::enableGrDrag(bool enable) { */ bool ToolBase::deleteSelectedDrag(bool just_one) { - if (_grdrag && _grdrag->selected) { + if (_grdrag && !_grdrag->selected.empty()) { _grdrag->deleteSelected(just_one); return TRUE; } |
