2 dimension-cache.cc -- implement Dimension_cache
4 source file of the GNU LilyPond music typesetter
6 (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "dimension-cache.hh"
11 #include "score-element.hh"
14 Dimension_cache::Dimension_cache (Dimension_cache const &d)
17 callback_l_ = d.callback_l_;
18 basic_offset_ = d.basic_offset_;
19 extra_offset_ = d.extra_offset_;
20 off_valid_b_ = d.off_valid_b_;
21 off_callbacks_ = d.off_callbacks_;
22 parent_l_ = d.parent_l_;
25 Dimension_cache::Dimension_cache ()
31 Dimension_cache::init()
46 Dimension_cache::translate (Real x)
52 Dimension_cache::relative_coordinate (Dimension_cache *refp) const
58 We catch PARENT_L_ == nil case with this, but we crash if we did
59 not ask for the absolute coordinate (ie. REFP == nil.)
62 if (refp == parent_l_)
65 return get_offset () + parent_l_->relative_coordinate (refp);
69 Dimension_cache::axis () const
71 if (elt_l_-> dim_cache_[X_AXIS] == this)
78 Dimension_cache::get_offset () const
80 Dimension_cache *me = (Dimension_cache*) this;
81 while (off_callbacks_.size ())
83 Offset_cache_callback c = me->off_callbacks_[0];
84 me->off_callbacks_.del (0);
85 me->basic_offset_ += (*c) (me);
87 return basic_offset_ + extra_offset_;
91 Dimension_cache::common_refpoint (Dimension_cache const* s) const
93 Link_array<Dimension_cache> my_groups;
94 for (Dimension_cache const *c = this; c ; c = c->parent_l_)
95 my_groups.push ((Dimension_cache*)c);
97 Dimension_cache const *common=0;
99 for (Dimension_cache const * d = s; !common && d; d = d->parent_l_)
100 common = (Dimension_cache const*)my_groups.find_l (d);
102 return (Dimension_cache*) common;
106 Dimension_cache::point_dimension_callback (Dimension_cache const* )
108 return Interval (0,0);
112 Dimension_cache::get_dim () const
115 Dimension_cache *nc = ((Dimension_cache*)this);
118 nc->dim_.set_empty ();
122 nc->dim_= (*callback_l_ ) (nc);
131 Dimension_cache::set_callback (Dim_cache_callback c)