index 9695d58e91dd6ed8ac25f8dab61e3b8137025f23..114ed9c645a67470811fe9d9502201820303eab0 100644 (file)
}
/** Finds out the minimum common bbox of the selected items. */
-static NR::Maybe<NR::Rect>
+static boost::optional<NR::Rect>
enclose_items(GSList const *items)
{
g_assert(items != NULL);
- NR::Maybe<NR::Rect> r = NR::Nothing();
+ boost::optional<NR::Rect> r;
for (GSList const *i = items; i; i = i->next) {
r = NR::union_bounds(r, sp_item_bbox_desktop((SPItem *) i->data));
}
rev = g_slist_sort(rev, (GCompareFunc) sp_item_repr_compare_position);
// Determine the common bbox of the selected items.
- NR::Maybe<NR::Rect> selected = enclose_items(items);
+ boost::optional<NR::Rect> selected = enclose_items(items);
// Iterate over all objects in the selection (starting from top).
if (selected) {
for (SPObject *newref = child->next; newref; newref = newref->next) {
// if the sibling is an item AND overlaps our selection,
if (SP_IS_ITEM(newref)) {
- NR::Maybe<NR::Rect> newref_bbox = sp_item_bbox_desktop(SP_ITEM(newref));
+ boost::optional<NR::Rect> newref_bbox = sp_item_bbox_desktop(SP_ITEM(newref));
if ( newref_bbox && selected->intersects(*newref_bbox) ) {
// AND if it's not one of our selected objects,
if (!g_slist_find((GSList *) items, newref)) {
Inkscape::XML::Node *grepr = SP_OBJECT_REPR(group);
// Determine the common bbox of the selected items.
- NR::Maybe<NR::Rect> selected = enclose_items(items);
+ boost::optional<NR::Rect> selected = enclose_items(items);
/* Construct direct-ordered list of selected children. */
GSList *rev = g_slist_copy((GSList *) items);
for (SPObject *newref = prev_sibling(child); newref; newref = prev_sibling(newref)) {
// if the sibling is an item AND overlaps our selection,
if (SP_IS_ITEM(newref)) {
- NR::Maybe<NR::Rect> ref_bbox = sp_item_bbox_desktop(SP_ITEM(newref));
+ boost::optional<NR::Rect> ref_bbox = sp_item_bbox_desktop(SP_ITEM(newref));
if ( ref_bbox && selected->intersects(*ref_bbox) ) {
// AND if it's not one of our selected objects,
if (!g_slist_find((GSList *) items, newref)) {
if (selection->isEmpty())
return;
- NR::Maybe<NR::Rect> const bbox(selection->bounds());
+ boost::optional<NR::Rect> const bbox(selection->bounds());
if ( !bbox || bbox->isEmpty() ) {
return;
}
@@ -1270,7 +1270,7 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, NR::Point const
if (selection->isEmpty())
return;
- NR::Maybe<NR::Rect> const bbox(selection->bounds());
+ boost::optional<NR::Rect> const bbox(selection->bounds());
if ( !bbox || bbox->isEmpty() ) {
return;
@@ -1379,7 +1379,7 @@ sp_selection_rotate(Inkscape::Selection *selection, gdouble const angle_degrees)
if (selection->isEmpty())
return;
- NR::Maybe<NR::Point> center = selection->center();
+ boost::optional<NR::Point> center = selection->center();
if (!center) {
return;
}
if (selection->isEmpty())
return;
- NR::Maybe<NR::Rect> const bbox(selection->bounds());
- NR::Maybe<NR::Point> center = selection->center();
+ boost::optional<NR::Rect> const bbox(selection->bounds());
+ boost::optional<NR::Point> center = selection->center();
if ( !bbox || !center ) {
return;
if (selection->isEmpty())
return;
- NR::Maybe<NR::Rect> const bbox(selection->bounds());
+ boost::optional<NR::Rect> const bbox(selection->bounds());
if (!bbox) {
return;
}
if (selection->isEmpty())
return;
- NR::Maybe<NR::Rect> sel_bbox = selection->bounds();
+ boost::optional<NR::Rect> sel_bbox = selection->bounds();
if (!sel_bbox) {
return;
}
ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
- shape_editor->set_item(SP_ITEM(child));
+ // TODO: should we set the item for nodepath or knotholder or both? seems to work with both.
+ shape_editor->set_item(SP_ITEM(child), SH_NODEPATH);
+ shape_editor->set_item(SP_ITEM(child), SH_KNOTHOLDER);
Inkscape::NodePath::Path *np = shape_editor->get_nodepath();
if (np) {
// take colors from prefs (same as used in outline mode)
void scroll_to_show_item(SPDesktop *desktop, SPItem *item)
{
NR::Rect dbox = desktop->get_display_area();
- NR::Maybe<NR::Rect> sbox = sp_item_bbox_desktop(item);
+ boost::optional<NR::Rect> sbox = sp_item_bbox_desktop(item);
if ( sbox && dbox.contains(*sbox) == false ) {
NR::Point const s_dt = sbox->midpoint();
}
sp_document_ensure_up_to_date(doc);
- NR::Maybe<NR::Rect> r = selection->bounds();
- NR::Maybe<NR::Point> c = selection->center();
+ boost::optional<NR::Rect> r = selection->bounds();
+ boost::optional<NR::Point> c = selection->center();
if ( !r || !c || r->isEmpty() ) {
return;
}
}
sp_document_ensure_up_to_date(doc);
- NR::Maybe<NR::Rect> r = selection->bounds();
+ boost::optional<NR::Rect> r = selection->bounds();
if ( !r || r->isEmpty() ) {
return;
}
sp_document_ensure_up_to_date(doc);
gchar const *attributeName = apply_clip_path ? "clip-path" : "mask";
- std::map<SPObject*,SPItem*> referenced_objects;
+ std::map<SPObject*,SPItem*> referenced_objects;
+ // SPObject* refers to a group containing the clipped path or mask itself,
+ // whereas SPItem* refers to the item being clipped or masked
for (GSList const *i = selection->itemList(); NULL != i; i = i->next) {
if (remove_original) {
// remember referenced mask/clippath, so orphaned masks can be moved back to document
// restore mask objects into a document
for ( std::map<SPObject*,SPItem*>::iterator it = referenced_objects.begin() ; it != referenced_objects.end() ; ++it) {
- SPObject *obj = (*it).first;
+ SPObject *obj = (*it).first; // Group containing the clipped paths or masks
GSList *items_to_move = NULL;
for (SPObject *child = sp_object_first_child(obj) ; child != NULL; child = SP_OBJECT_NEXT(child) ) {
+ // Collect all clipped paths and masks within a single group
Inkscape::XML::Node *copy = SP_OBJECT_REPR(child)->duplicate(xml_doc);
items_to_move = g_slist_prepend (items_to_move, copy);
}
Inkscape::XML::Node *parent = SP_OBJECT_REPR((*it).second)->parent();
gint pos = SP_OBJECT_REPR((*it).second)->position();
+ // Iterate through all clipped paths / masks
for (GSList *i = items_to_move; NULL != i; i = i->next) {
Inkscape::XML::Node *repr = (Inkscape::XML::Node *)i->data;
desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Select <b>object(s)</b> to fit canvas to."));
return false;
}
- NR::Maybe<NR::Rect> const bbox(desktop->selection->bounds());
+ boost::optional<NR::Rect> const bbox(desktop->selection->bounds());
if (bbox && !bbox->isEmpty()) {
doc->fitToRect(*bbox);
return true;
sp_document_ensure_up_to_date(doc);
SPItem const *const root = SP_ITEM(doc->root);
- NR::Maybe<NR::Rect> const bbox(root->getBounds(from_2geom(sp_item_i2r_affine(root))));
+ boost::optional<NR::Rect> const bbox(root->getBounds(from_2geom(sp_item_i2r_affine(root))));
if (bbox && !bbox->isEmpty()) {
doc->fitToRect(*bbox);
return true;