]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/separation-item.cc
*** empty log message ***
[lilypond.git] / lily / separation-item.cc
index 81b3df8ced18cc06c91df83d2d15a9d75b82d71e..1c46854c5ce0d12eea616f4286f82abc4f102ccb 100644 (file)
@@ -3,20 +3,15 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
 #include "separation-item.hh"
 #include "paper-column.hh"
-#include "debug.hh"
+#include "warn.hh"
 #include "group-interface.hh"
-
-bool
-Separation_item::has_interface (Grob *g)
-{
-  return g->has_interface (ly_symbol2scm ("separation-item-interface"));
-}
+#include "accidental-placement.hh"
 
 void
 Separation_item::add_item (Grob*s,Item* i)
@@ -26,16 +21,71 @@ Separation_item::add_item (Grob*s,Item* i)
   s->add_dependency (i);
 }
 
-/*
-  DOCME:
+void
+Separation_item::add_conditional_item (Grob* me , Grob *e)
+{
+  Pointer_group_interface::add_grob (me, ly_symbol2scm ("conditional-elements"), e);
+}
 
-  why don't we use extent()
+/*
+  Return the width of ME given that we are considering the object on
+  the LEFT.
  */
 Interval
-Separation_item::my_width (Grob *me)
+Separation_item::conditional_width (Grob * me, Grob * left)
+{
+  Interval w = width (me);
+  
+  Item *item = dynamic_cast<Item*> (me);
+  Paper_column * pc = item->get_column ();
+  
+  
+  for (SCM s =  me->get_grob_property ("conditional-elements"); gh_pair_p (s); s = ly_cdr (s))
+    {
+      SCM elt = ly_car (s);
+      if (!unsmob_grob (elt))
+       continue;
+      
+      Item *il = unsmob_item (elt);
+      if (pc != il->get_column ())
+       {
+         /* this shouldn't happen, but let's continue anyway. */
+         programming_error (_ ("Separation_item:  I've been drinking too much"));
+         continue;             /*UGH UGH*/ 
+       }
+
+      if (to_boolean (il->get_grob_property ("no-spacing-rods")))
+       {
+         continue;
+       }
+
+      if (Accidental_placement::has_interface (il))
+       {
+         w.unite (Accidental_placement::get_relevant_accidental_extent (il, pc, left));
+       }
+    }
+
+  SCM pad = me->get_grob_property ("padding");
+
+  if (gh_number_p (pad))
+    {
+      w[RIGHT] += gh_scm2double (pad)/2;
+      w[LEFT] -= gh_scm2double (pad)/2;    
+    }
+  return w;
+}
+
+Interval
+Separation_item::width (Grob *me)
 {
+  SCM sw = me->get_grob_property ("X-extent");
+  if (ly_number_pair_p (sw))
+    {
+      return ly_scm2interval (sw);
+    }
+
   Item *item = dynamic_cast<Item*> (me);
-  Paper_column * pc = item->column_l ();
+  Paper_column * pc = item->get_column ();
   Interval w;
   
   for (SCM s =  me->get_grob_property ("elements"); gh_pair_p (s); s = ly_cdr (s))
@@ -45,7 +95,7 @@ Separation_item::my_width (Grob *me)
        continue;
 
       Item *il = unsmob_item (elt);
-      if (pc != il->column_l ())
+      if (pc != il->get_column ())
        {
          /* this shouldn't happen, but let's continue anyway. */
          programming_error (_ ("Separation_item:  I've been drinking too much"));
@@ -71,6 +121,10 @@ Separation_item::my_width (Grob *me)
     w[RIGHT] += gh_scm2double (pad)/2;
     w[LEFT] -= gh_scm2double (pad)/2;    
   }
+
+
+  me->set_grob_property ("X-extent", ly_interval2scm (w));
+  
   
   return w;
  // add this->offset_ ? this-> relative_coordinate ()? 
@@ -87,4 +141,4 @@ Calc dimensions for the Separating_group_spanner; this has to be
 an item to get dependencies correct.  It can't be an grob_group
 since these usually are in a different X_group
 ",
-  "elements");
+  "X-extent conditional-elements elements");