]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/separation-item.cc
2003 -> 2004
[lilypond.git] / lily / separation-item.cc
index 5255b65c028a1db675347246dc4d72aa8794a908..b3e7c8a368853dff23513410745d41d838e0d056 100644 (file)
@@ -3,7 +3,7 @@
   
   source file of the GNU LilyPond music typesetter
   
-  (c) 1998--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1998--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
   
  */
 
@@ -67,11 +67,7 @@ Separation_item::conditional_width (Grob * me, Grob * 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;    
-    }
+  w.widen (robust_scm2double (pad, 0.0));
   return w;
 }
 
@@ -79,7 +75,7 @@ Interval
 Separation_item::width (Grob *me)
 {
   SCM sw = me->get_grob_property ("X-extent");
-  if (ly_number_pair_p (sw))
+  if (is_number_pair (sw))
     {
       return ly_scm2interval (sw);
     }
@@ -108,7 +104,7 @@ Separation_item::width (Grob *me)
        }
 
       Interval iv (il->extent (pc, X_AXIS));
-      if (!iv.empty_b ())
+      if (!iv.is_empty ())
        {
          w.unite (iv);
        }
@@ -116,17 +112,56 @@ Separation_item::width (Grob *me)
 
   SCM pad = me->get_grob_property ("padding");
 
-  if (gh_number_p (pad))
-  {
-    w[RIGHT] += gh_scm2double (pad)/2;
-    w[LEFT] -= gh_scm2double (pad)/2;    
-  }
+  w.widen (robust_scm2double (pad, 0.0));
 
   me->set_grob_property ("X-extent", ly_interval2scm (w));
   
   return w;
 }
 
+Interval
+Separation_item::relative_width (Grob * me, Grob * common)
+{
+  Interval iv = width (me);
+
+  return dynamic_cast<Item*>(me)->get_column ()->relative_coordinate (common, X_AXIS) + iv ;
+}
+
+
+/*
+  Try to find the break-aligned symbol in SEPARATION_ITEM that is
+  sticking out at direction D. The x size is put in LAST_EXT
+*/
+Grob*
+Separation_item::extremal_break_aligned_grob (Grob *separation_item, Direction d,
+                                           Interval * last_ext)
+{
+  Grob *col = dynamic_cast<Item*> (separation_item)->get_column ();
+  last_ext->set_empty ();
+  Grob *last_grob = 0;
+  for (SCM s = separation_item->get_grob_property ("elements");
+       gh_pair_p (s); s = gh_cdr (s))
+    {
+      Grob * break_item = unsmob_grob (gh_car (s));
+      
+      if (!gh_symbol_p (break_item->get_grob_property ("break-align-symbol")))
+       continue;
+
+      Interval ext = break_item->extent (col, X_AXIS);
+
+      if (ext.is_empty ())
+       continue;
+      if (!last_grob
+         || (last_grob && d * (ext[d]- (*last_ext)[d]) > 0) )
+       {
+         *last_ext = ext;
+         last_grob = break_item; 
+       }
+    }
+
+  return last_grob;  
+}
+
 
 
 
@@ -136,4 +171,4 @@ ADD_INTERFACE (Separation_item,"separation-item-interface",
 "\n"
 "Calculate dimensions for the Separating_group_spanner; this has to be "
 "an item to get dependencies correct.  "
-  "padding X-extent conditional-elements elements");
+, "padding X-extent conditional-elements elements");