]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/note-column.cc (translate_rests): call flush_extent_cache()
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 4 Feb 2005 19:49:08 +0000 (19:49 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 4 Feb 2005 19:49:08 +0000 (19:49 +0000)
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.

ChangeLog
lily/axis-group-interface.cc
lily/dimension-cache.cc
lily/grob.cc
lily/include/dimension-cache.hh
lily/include/grob.hh
lily/note-column.cc

index 569d30dda625e2f9f6dafa5cfa46ffda204e2f9c..f201fe63fcd8f8c282220a2651e16d4a369b9e26 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2005-02-04  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * 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  <janneke@gnu.org>
 
        * all but lily/*: The grand 2004/2005 replace.
index 5dcf4604e21330dfa2db1e10efd967bd3454e35b..6a41e1eaffae3088cb4c67e4ac5edaf51282ed6e 100644 (file)
@@ -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<Grob> 
index 3d5a1a012c2b88020ef37621035d418e5b3e3657..b2d6330864af384a708a5308773d738fa2cd46b2 100644 (file)
@@ -33,6 +33,7 @@ void
 Dimension_cache::init ()
 {
   dimension_ = SCM_EOL;
+  dimension_callback_ = SCM_EOL; 
 
   offsets_left_ = 0;
   offset_callbacks_ = SCM_EOL;
index 2ba0e243170d1546ee916d0166ced2247aff057d..e6299cf8926cfc7a24f8d6e3dbd7ea17991ed2a7 100644 (file)
@@ -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)
 {
index 970b33db9c00eb26242f9519050cb01955444ce4..0abb7f6c37ef5f8f546b37deedde6e9ce5242f5a 100644 (file)
@@ -28,6 +28,7 @@ struct Dimension_cache
      - else: empty
    */
   SCM dimension_;
+  SCM dimension_callback_;
 
   /**
     The offset wrt. to the center of #parent_#
index 15ca5933af3559f73932f34e648d3c799fcb37e7..150325bf2d52631ae697df7494be471740625ec2 100644 (file)
@@ -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);
index 160c996d90682d79d3df607aa9937de7632d5808..7e0b80d3f461d60b3d34852d3ae5122592a7bdcc 100644 (file)
@@ -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);
     }
 }