From: Han-Wen Nienhuys Date: Fri, 4 Feb 2005 19:49:08 +0000 (+0000) Subject: * lily/note-column.cc (translate_rests): call flush_extent_cache() X-Git-Tag: release/2.5.14~172 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=93b5b6bf5495d930fccd442dc402897f7f07b2de;p=lilypond.git * lily/note-column.cc (translate_rests): call flush_extent_cache() of parents when translating rests. Fixes: c-chord-rest.ly * lily/include/dimension-cache.hh (struct Dimension_cache): add dimension_callback_ member. * lily/grob.cc (flush_extent_cache): new function. Force recompute of extents. --- diff --git a/ChangeLog b/ChangeLog index 569d30dda6..f201fe63fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2005-02-04 Han-Wen Nienhuys + + * lily/note-column.cc (translate_rests): call flush_extent_cache() + of parents when translating rests. Fixes: c-chord-rest.ly + + * lily/include/dimension-cache.hh (struct Dimension_cache): add + dimension_callback_ member. + + * lily/grob.cc (flush_extent_cache): new function. Force recompute + of extents. + 2005-02-04 Jan Nieuwenhuizen * all but lily/*: The grand 2004/2005 replace. diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 5dcf4604e2..6a41e1eaff 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -98,9 +98,9 @@ Axis_group_interface::set_axes (Grob*me, Axis a1, Axis a2) why so convoluted ? (fixme/documentme?) */ if (me->has_extent_callback (Grob::stencil_extent_proc, a1)) - me->set_extent (Axis_group_interface::group_extent_callback_proc, a1); + me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a1); if (me->has_extent_callback (Grob::stencil_extent_proc, a2)) - me->set_extent (Axis_group_interface::group_extent_callback_proc, a2); + me->set_extent_callback (Axis_group_interface::group_extent_callback_proc, a2); } Link_array diff --git a/lily/dimension-cache.cc b/lily/dimension-cache.cc index 3d5a1a012c..b2d6330864 100644 --- a/lily/dimension-cache.cc +++ b/lily/dimension-cache.cc @@ -33,6 +33,7 @@ void Dimension_cache::init () { dimension_ = SCM_EOL; + dimension_callback_ = SCM_EOL; offsets_left_ = 0; offset_callbacks_ = SCM_EOL; diff --git a/lily/grob.cc b/lily/grob.cc index 2ba0e24317..e6299cf892 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -99,18 +99,23 @@ Grob::Grob (SCM basicprops, programming_error ("[XY]-offset-callbacks must be a list"); SCM cb = get_property (enames[a]); + if (cb == SCM_BOOL_F) + { + dim_cache_[a].dimension_ = SCM_BOOL_F; + } + SCM xt = get_property (xnames[a]); - - /* Should change default to empty? */ if (is_number_pair (xt)) - cb = xt; - else if (cb != SCM_BOOL_F - && !ly_c_procedure_p (cb) && !scm_is_pair (cb) - && ly_c_procedure_p (get_property ("print-function"))) - cb = stencil_extent_proc; - - dim_cache_[a].dimension_callback_ = cb; - dim_cache_[a].dimension_ = cb; + { + dim_cache_[a].dimension_ = xt; + } + else if (ly_c_procedure_p (cb)) + { + dim_cache_[a].dimension_callback_ = cb; + } + else if (cb == SCM_EOL + && ly_c_procedure_p (get_property ("print-function"))) + dim_cache_[a].dimension_callback_ = stencil_extent_proc; } } @@ -320,6 +325,9 @@ Grob::suicide () set_extent (SCM_EOL, Y_AXIS); set_extent (SCM_EOL, X_AXIS); + set_extent_callback (SCM_EOL, Y_AXIS); + set_extent_callback (SCM_EOL, X_AXIS); + for (int a = X_AXIS; a <= Y_AXIS; a++) { dim_cache_[a].offset_callbacks_ = SCM_EOL; @@ -400,8 +408,23 @@ Grob::get_offset (Axis a) const bool Grob::is_empty (Axis a) const { - return ! (scm_is_pair (dim_cache_[a].dimension_) - || ly_c_procedure_p (dim_cache_[a].dimension_)); + return !(scm_is_pair (dim_cache_[a].dimension_) + || ly_c_procedure_p (dim_cache_[a].dimension_callback_)); +} + +void +Grob::flush_extent_cache (Axis axis) +{ + Dimension_cache * d = &dim_cache_[axis]; + if (ly_c_procedure_p (d->dimension_callback_) + && scm_is_pair (d->dimension_)) + { + d->dimension_ = SCM_EOL; + + + if (get_parent (axis)) + get_parent(axis)->flush_extent_cache (axis); + } } Interval @@ -415,8 +438,9 @@ Grob::extent (Grob *refp, Axis a) const SCM dimpair = d->dimension_; if (scm_is_pair (dimpair)) ; - else if (ly_c_procedure_p (d->dimension_)) - d->dimension_ = scm_call_2 (d->dimension_, self_scm (), scm_int2num (a)); + else if (ly_c_procedure_p (d->dimension_callback_) + && d->dimension_ == SCM_EOL) + d->dimension_ = scm_call_2 (d->dimension_callback_, self_scm (), scm_int2num (a)); else return ext; @@ -514,9 +538,9 @@ Grob::add_offset_callback (SCM cb, Axis a) } bool -Grob::has_extent_callback (SCM cb, Axis a)const +Grob::has_extent_callback (SCM cb, Axis a) const { - return scm_equal_p (cb, dim_cache_[a].dimension_) == SCM_BOOL_T; + return scm_equal_p (cb, dim_cache_[a].dimension_callback_) == SCM_BOOL_T; } bool @@ -531,6 +555,12 @@ Grob::set_extent (SCM dc, Axis a) dim_cache_[a].dimension_ = dc; } +void +Grob::set_extent_callback (SCM dc, Axis a) +{ + dim_cache_[a].dimension_callback_ = dc; +} + void Grob::set_parent (Grob *g, Axis a) { diff --git a/lily/include/dimension-cache.hh b/lily/include/dimension-cache.hh index 970b33db9c..0abb7f6c37 100644 --- a/lily/include/dimension-cache.hh +++ b/lily/include/dimension-cache.hh @@ -28,6 +28,7 @@ struct Dimension_cache - else: empty */ SCM dimension_; + SCM dimension_callback_; /** The offset wrt. to the center of #parent_# diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 15ca5933af..150325bf2d 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -119,7 +119,9 @@ public: bool has_offset_callback (SCM callback, Axis) const; void add_offset_callback (SCM callback, Axis); bool has_extent_callback (SCM, Axis) const; + void flush_extent_cache (Axis); void set_extent (SCM, Axis); + void set_extent_callback (SCM, Axis); Real get_offset (Axis a) const; void set_parent (Grob* e, Axis); diff --git a/lily/note-column.cc b/lily/note-column.cc index 160c996d90..7e0b80d3f4 100644 --- a/lily/note-column.cc +++ b/lily/note-column.cc @@ -130,6 +130,8 @@ Note_column::translate_rests (Grob*me, int dy) if (r && !scm_is_number (r->get_property ("staff-position"))) { r->translate_axis (dy * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS); + Grob *p = r->get_parent (Y_AXIS); + p->flush_extent_cache (Y_AXIS); } }