X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fsp-item.cpp;h=3d71443d63f6400055336c2bcea4314def8dbbaf;hb=8e75b1268dabafcba82b82a5e5d51c78b300a010;hp=6aae4609e6908add2bf5aa81780a1e93be2104ae;hpb=1bfbb0fab3f2c679155a3d9645d7cb6d0f2b5253;p=inkscape.git diff --git a/src/sp-item.cpp b/src/sp-item.cpp index 6aae4609e..3d71443d6 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -44,9 +44,11 @@ #include "sp-text.h" #include "sp-item-rm-unsatisfied-cns.h" #include "sp-pattern.h" +#include "sp-switch.h" #include "gradient-chemistry.h" #include "prefs-utils.h" #include "conn-avoid-ref.h" +#include "conditions.h" #include "libnr/nr-matrix-div.h" #include "libnr/nr-matrix-fns.h" @@ -130,34 +132,39 @@ sp_item_class_init(SPItemClass *klass) static void sp_item_init(SPItem *item) { - SPObject *object = SP_OBJECT(item); + item->init(); +} + +void SPItem::init() { + this->sensitive = TRUE; - item->sensitive = TRUE; + this->transform_center_x = 0; + this->transform_center_y = 0; - item->transform_center_x = 0; - item->transform_center_y = 0; + this->_is_evaluated = true; + this->_evaluated_status = StatusUnknown; - item->transform = NR::identity(); + this->transform = NR::identity(); - item->display = NULL; + this->display = NULL; - item->clip_ref = new SPClipPathReference(SP_OBJECT(item)); + this->clip_ref = new SPClipPathReference(this); { - sigc::signal cs1=item->clip_ref->changedSignal(); - sigc::slot2 sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), item); + sigc::signal cs1=this->clip_ref->changedSignal(); + sigc::slot2 sl1=sigc::bind(sigc::ptr_fun(clip_ref_changed), this); cs1.connect(sl1); } - item->mask_ref = new SPMaskReference(SP_OBJECT(item)); - sigc::signal cs2=item->mask_ref->changedSignal(); - sigc::slot2 sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), item); + this->mask_ref = new SPMaskReference(this); + sigc::signal cs2=this->mask_ref->changedSignal(); + sigc::slot2 sl2=sigc::bind(sigc::ptr_fun(mask_ref_changed), this); cs2.connect(sl2); - if (!object->style) object->style = sp_style_new_from_object(SP_OBJECT(item)); + if (!this->style) this->style = sp_style_new_from_object(this); - item->avoidRef = new SPAvoidRef(item); + this->avoidRef = new SPAvoidRef(this); - new (&item->_transformed_signal) sigc::signal(); + new (&this->_transformed_signal) sigc::signal(); } bool SPItem::isVisibleAndUnlocked() const { @@ -183,6 +190,8 @@ void SPItem::setLocked(bool locked) { } bool SPItem::isHidden() const { + if (!isEvaluated()) + return true; return style->display.computed == SP_CSS_DISPLAY_NONE; } @@ -195,6 +204,8 @@ void SPItem::setHidden(bool hide) { } bool SPItem::isHidden(unsigned display_key) const { + if (!isEvaluated()) + return true; for ( SPItemView *view(display) ; view ; view = view->next ) { if ( view->key == display_key ) { g_assert(view->arenaitem != NULL); @@ -211,6 +222,34 @@ bool SPItem::isHidden(unsigned display_key) const { return true; } +void SPItem::setEvaluated(bool evaluated) { + _is_evaluated = evaluated; + _evaluated_status = StatusSet; +} + +void SPItem::resetEvaluated() { + if ( StatusCalculated == _evaluated_status ) { + _evaluated_status = StatusUnknown; + bool oldValue = _is_evaluated; + if ( oldValue != isEvaluated() ) { + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); + } + } if ( StatusSet == _evaluated_status ) { + SPObject const *const parent = SP_OBJECT_PARENT(this); + if (SP_IS_SWITCH(parent)) { + SP_SWITCH(parent)->resetChildEvaluated(); + } + } +} + +bool SPItem::isEvaluated() const { + if ( StatusUnknown == _evaluated_status ) { + _is_evaluated = sp_item_evaluate(this); + _evaluated_status = StatusCalculated; + } + return _is_evaluated; +} + /** * Returns something suitable for the `Hide' checkbox in the Object Properties dialog box. * Corresponds to setExplicitlyHidden. @@ -466,6 +505,13 @@ sp_item_set(SPObject *object, unsigned key, gchar const *value) item->transform_center_y = 0; } break; + case SP_PROP_SYSTEM_LANGUAGE: + case SP_PROP_REQUIRED_FEATURES: + case SP_PROP_REQUIRED_EXTENSIONS: + { + item->resetEvaluated(); + // pass to default handler + } default: if (SP_ATTRIBUTE_IS_CSS(key)) { sp_style_read_from_object(object->style, object); @@ -665,6 +711,10 @@ sp_item_invoke_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transfor sp_item_invoke_bbox_full(item, bbox, transform, 0, clear); } +/** Calls \a item's subclass' bounding box method; clips it by the bbox of clippath, if any; and + * unions the resulting bbox with \a bbox. If \a clear is true, empties \a bbox first. Passes the + * transform and the flags to the actual bbox methods. Note that many of subclasses (e.g. groups, + * clones), in turn, call this function in their bbox methods. */ void sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsigned const flags, unsigned const clear) { @@ -677,15 +727,25 @@ sp_item_invoke_bbox_full(SPItem const *item, NRRect *bbox, NR::Matrix const &tra bbox->x1 = bbox->y1 = -1e18; } + NRRect this_bbox; + this_bbox.x0 = this_bbox.y0 = 1e18; + this_bbox.x1 = this_bbox.y1 = -1e18; + + // call the subclass method if (((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox) { - ((SPItemClass *) G_OBJECT_GET_CLASS(item))->bbox(item, bbox, transform, flags); + ((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()) { NRRect b; sp_clippath_get_bbox(SP_CLIPPATH(item->clip_ref->getObject()), &b, transform, flags); - nr_rect_d_intersect (bbox, bbox, &b); + nr_rect_d_intersect (&this_bbox, &this_bbox, &b); + } + + // if non-empty (with some tolerance - ?) union this_bbox with the bbox we've got passed + if ( fabs(this_bbox.x1-this_bbox.x0) > -0.00001 && fabs(this_bbox.y1-this_bbox.y0) > -0.00001 ) { + nr_rect_d_union (bbox, bbox, &this_bbox); } } @@ -727,7 +787,7 @@ sp_item_bbox_desktop(SPItem *item, NRRect *bbox) NR::Rect sp_item_bbox_desktop(SPItem *item) { NRRect ret; - sp_item_bbox_desktop(item, &ret); + sp_item_invoke_bbox(item, &ret, sp_item_i2d_affine(item), TRUE); return NR::Rect(ret); }