X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fdimension-cache.cc;h=08074b2dab105761f17c03942ac232f0a2103277;hb=6325404202da7fa5e067326439c095bec5629d8e;hp=6fc99bde284f48bee45184eeb3a604d4ffaa5edf;hpb=07d4d05df6479d58c3c5152c07d7c86b94ee98b4;p=lilypond.git diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 6fc99bde28..08074b2dab 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -3,142 +3,46 @@ source file of the GNU LilyPond music typesetter - (c) 1998--1999 Han-Wen Nienhuys + (c) 1998--2004 Han-Wen Nienhuys */ - +#include +#include "warn.hh" #include "dimension-cache.hh" #include "parray.hh" +#include "grob.hh" -Dimension_cache::Dimension_cache (Dimension_cache const &d) -{ - init(); - callback_l_ = d.callback_l_; - empty_b_ = d.empty_b_; - offset_ = d.offset_; //let's hope others will copy the refpoint appropriately. -} - -Dimension_cache::Dimension_cache () -{ - init(); -} -void -Dimension_cache::init() -{ - callback_l_ =0; - offset_ =0.0; - elt_l_ = 0; - dim_.set_empty (); - parent_l_ =0; - valid_b_ = false; - empty_b_ = false; -} - - -void -Dimension_cache::invalidate () +Dimension_cache::Dimension_cache (Dimension_cache const &d) { - valid_b_ = false; - invalidate_dependencies (); -} + init (); + dimension_ = d.dimension_; -void -Dimension_cache::invalidate_dependencies () -{ - for (int i=0; i < dependencies_l_arr_.size (); i++) - { - Dimension_cache * g = dependencies_l_arr_[i]; - if (g->valid_b_) - { - g->invalidate (); - } - } + offset_ = d.offset_; + offset_callbacks_ = d.offset_callbacks_; + offsets_left_ = d.offsets_left_; + parent_ = d.parent_; } -void -Dimension_cache::set_offset (Real x) +Dimension_cache::Dimension_cache () { - invalidate_dependencies (); - offset_ = x; + init (); } void -Dimension_cache::translate (Real x) -{ - invalidate_dependencies (); - offset_ += x; -} - -Real -Dimension_cache::relative_coordinate (Dimension_cache *refp) const +Dimension_cache::init () { - if (refp == this) - return 0.0; + dimension_ = SCM_EOL; - /* - We catch PARENT_L_ == nil case with this, but we crash if we did - not ask for the absolute coordinate (ie. REFP == nil.) - - */ - if (refp == parent_l_) - return offset_; - else - return offset_ + parent_l_->relative_coordinate (refp); -} - -Dimension_cache * -Dimension_cache::common_refpoint (Dimension_cache const* s) const -{ - Link_array my_groups; - for (Dimension_cache const *c = this; c ; c = c->parent_l_) - my_groups.push ((Dimension_cache*)c); - - Dimension_cache const *common=0; + offsets_left_ = 0; + offset_callbacks_ = SCM_EOL; + offset_ =0.0; - for (Dimension_cache const * d = s; !common && d; d = d->parent_l_) - common = (Dimension_cache const*)my_groups.find_l (d); - - return (Dimension_cache*) common; + parent_ =0; } -void -Dimension_cache::set_empty (bool b) -{ - if (empty_b_ != b) - { - empty_b_ = b; - if (!empty_b_) - invalidate (); - } -} -Interval -Dimension_cache::get_dim () const -{ - Interval r; - if (empty_b_) - { - r.set_empty (); - return r; - } - - if (!valid_b_) - { - Dimension_cache *nc = ((Dimension_cache*)this); - nc->dim_= (*callback_l_ ) (nc); - nc->valid_b_ = true; - } - r=dim_; - return r; -} - -void -Dimension_cache::set_callback (Dim_cache_callback c) -{ - callback_l_ =c; -}