X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-item.cpp;h=338a70c4ed4b838866151848821a4ce8b81ced9e;hb=03a65c733a473cd92d50132961d02c3910417f72;hp=27f6e4ce38d31dcedfd4920ac143774b82b41d6f;hpb=33ccd5ed608830b9fb48c9ab756bf1920e220f51;p=inkscape.git diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 27f6e4ce3..338a70c4e 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -50,6 +50,7 @@ #include "prefs-utils.h" #include "conn-avoid-ref.h" #include "conditions.h" +#include "sp-filter-reference.h" #include "libnr/nr-matrix-div.h" #include "libnr/nr-matrix-fns.h" @@ -61,6 +62,7 @@ #include "util/reverse-list.h" #include "xml/repr.h" +#include "extract-uri.h" #define noSP_ITEM_DEBUG_IDLE @@ -296,7 +298,7 @@ bool SPItem::isCenterSet() { return (transform_center_x != 0 || transform_center_y != 0); } -NR::Point SPItem::getCenter() { +NR::Point SPItem::getCenter() const { NR::Maybe bbox = getBounds(sp_item_i2d_affine(this)); if (bbox) { return bbox->midpoint() + NR::Point (this->transform_center_x, this->transform_center_y); @@ -447,7 +449,7 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value) break; } case SP_PROP_CLIP_PATH: { - gchar *uri = Inkscape::parse_css_url(value); + gchar *uri = extract_uri(value); if (uri) { try { item->clip_ref->attach(Inkscape::URI(uri)); @@ -463,7 +465,7 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value) break; } case SP_PROP_MASK: { - gchar *uri=Inkscape::parse_css_url(value); + gchar *uri = extract_uri(value); if (uri) { try { item->mask_ref->attach(Inkscape::URI(uri)); @@ -621,6 +623,13 @@ sp_item_update(SPObject *object, SPCtx *ctx, guint flags) } } + if (item->display && item->display->arenaitem) { + NRRect item_bbox; + sp_item_invoke_bbox(item, &item_bbox, NR::identity(), TRUE, SPItem::GEOMETRIC_BBOX); + NR::Maybe i_bbox = item_bbox; + nr_arena_item_set_item_bbox(item->display->arenaitem, i_bbox); + } + // Update libavoid with item geometry (for connector routing). item->avoidRef->handleSettingChange(); } @@ -674,9 +683,9 @@ NR::Maybe SPItem::getBounds(NR::Matrix const &transform, } void -sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const clear) +sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const clear, SPItem::BBoxType type) { - sp_item_invoke_bbox_full(item, bbox, transform, 0, clear); + sp_item_invoke_bbox_full(item, bbox, transform, type, clear); } /** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and @@ -704,8 +713,8 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &tra ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, &this_bbox, transform, flags); } - // crop the bbox by clip path, if any - if (item->clip_ref->getObject()) { + // unless this is geometric bbox, crop the bbox by clip path, if any + if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX && item->clip_ref->getObject()) { NRRect b; sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); nr_rect_d_intersect (&this_bbox, &this_bbox, &b); @@ -743,31 +752,36 @@ unsigned sp_item_pos_in_parent(SPItem *item) } void -sp_item_bbox_desktop(SPItem *item, NRRect *bbox) +sp_item_bbox_desktop(SPItem *item, NRRect *bbox, SPItem::BBoxType type) { g_assert(item != NULL); g_assert(SP_IS_ITEM(item)); g_assert(bbox != NULL); - sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE); + sp_item_invoke_bbox(item, bbox, sp_item_i2d_affine(item), TRUE, type); } -NR::Maybe sp_item_bbox_desktop(SPItem *item) +NR::Maybe sp_item_bbox_desktop(SPItem *item, SPItem::BBoxType type) { NRRect ret; - sp_item_invoke_bbox(item, &ret, sp_item_i2d_affine(item), TRUE); + sp_item_invoke_bbox(item, &ret, sp_item_i2d_affine(item), TRUE, type); return ret.upgrade(); } static void sp_item_private_snappoints(SPItem const *item, SnapPointsIter p) { NR::Maybe bbox = item->getBounds(sp_item_i2d_affine(item)); - /* Just a pair of opposite corners of the bounding box suffices given that we don't yet + /* Just the corners of the bounding box suffices given that we don't yet support angled guide lines. */ if (bbox) { - *p = bbox->min(); - *p = bbox->max(); + NR::Point p1, p2; + p1 = bbox->min(); + p2 = bbox->max(); + *p = p1; + *p = NR::Point(p1[NR::X], p2[NR::Y]); + *p = p2; + *p = NR::Point(p1[NR::Y], p2[NR::X]); } } @@ -910,6 +924,10 @@ sp_item_invoke_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) SP_OBJECT(mask)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } NR_ARENA_ITEM_SET_DATA(ai, item); + NRRect item_bbox; + sp_item_invoke_bbox(item, &item_bbox, NR::identity(), TRUE, SPItem::GEOMETRIC_BBOX); + NR::Maybe i_bbox = item_bbox; + nr_arena_item_set_item_bbox(ai, i_bbox); } return ai; @@ -1060,6 +1078,10 @@ sp_item_adjust_stroke_width_recursive(SPItem *item, double expansion) { sp_item_adjust_stroke (item, expansion); +// A clone's child is the ghost of its original - we must not touch it, skip recursion + if (item && SP_IS_USE(item)) + return; + for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) sp_item_adjust_stroke_width_recursive(SP_ITEM(o), expansion); @@ -1088,18 +1110,16 @@ sp_item_adjust_rects_recursive(SPItem *item, NR::Matrix advertized_transform) void sp_item_adjust_paint_recursive (SPItem *item, NR::Matrix advertized_transform, NR::Matrix t_ancestors, bool is_pattern) { -// A clone must not touch the style (it's that of its parent!) and has no children, so quit now - if (item && SP_IS_USE(item)) - return; - // _Before_ full pattern/gradient transform: t_paint * t_item * t_ancestors // _After_ full pattern/gradient transform: t_paint_new * t_item * t_ancestors * advertised_transform // By equating these two expressions we get t_paint_new = t_paint * paint_delta, where: NR::Matrix t_item = sp_item_transform_repr (item); NR::Matrix paint_delta = t_item * t_ancestors * advertized_transform * t_ancestors.inverse() * t_item.inverse(); -// Within text, we do not fork gradients, and so must not recurse to avoid double compensation - if (!(item && SP_IS_TEXT(item))) { +// Within text, we do not fork gradients, and so must not recurse to avoid double compensation; +// also we do not recurse into clones, because a clone's child is the ghost of its original - +// we must not touch it + if (!(item && (SP_IS_TEXT(item) || SP_IS_USE(item)))) { for (SPObject *o = SP_OBJECT(item)->children; o != NULL; o = o->next) { if (SP_IS_ITEM(o)) { // At the level of the transformed item, t_ancestors is identity; @@ -1193,7 +1213,7 @@ sp_item_write_transform(SPItem *item, Inkscape::XML::Node *repr, NR::Matrix cons !preserve && // user did not chose to preserve all transforms !item->clip_ref->getObject() && // the object does not have a clippath !item->mask_ref->getObject() && // the object does not have a mask - !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->filter.filter) + !(!transform.is_translation() && SP_OBJECT_STYLE(item) && SP_OBJECT_STYLE(item)->getFilter()) // the object does not have a filter, or the transform is translation (which is supposed to not affect filters) ) { transform_attr = ((SPItemClass *) G_OBJECT_GET_CLASS(item))->set_transform(item, transform);