]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/ottava-bracket.cc
*** empty log message ***
[lilypond.git] / lily / ottava-bracket.cc
index 8f86a03eff62b9ffb5cbf0c3e6d1c6f99e5cecbb..985fa41120e16d7c09f722812f5e246fc80b6f2e 100644 (file)
@@ -7,9 +7,7 @@
 
  */
 
-#include "stencil.hh"
 #include "text-item.hh"
-#include "text-spanner.hh"
 #include "line-spanner.hh"
 #include "spanner.hh"
 #include "font-interface.hh"
@@ -21,6 +19,7 @@
 #include "note-column.hh"
 #include "directional-element-interface.hh"
 #include "tuplet-bracket.hh"
+#include "rhythmic-head.hh"
 
 struct Ottava_bracket
 {
@@ -31,26 +30,21 @@ struct Ottava_bracket
 
 /*
   TODO: the string for ottava shoudl depend on the available space, ie.
-
   
   Long: 15ma        Short: 15ma    Empty: 15
          8va                8va            8
          8va bassa          8ba            8
 
 */
-
 MAKE_SCHEME_CALLBACK (Ottava_bracket, print, 1);
 SCM
 Ottava_bracket::print (SCM smob)
 {
   Spanner*me  = dynamic_cast<Spanner*> (unsmob_grob (smob));
-  
-  
   Interval span_points;
   
   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
-  Output_def * paper = me->get_paper ();
-
+  Output_def * layout = me->get_layout ();
   
   Drul_array<bool> broken;
   Direction d = LEFT;
@@ -61,7 +55,15 @@ Ottava_bracket::print (SCM smob)
 
       if (Note_column::has_interface (b))
        {
-         common = common_refpoint_of_list (b->get_property ("heads"), common, X_AXIS);
+         SCM heads = b->get_property ("note-heads");
+         common = common_refpoint_of_list (heads, common, X_AXIS);
+         for (SCM s = heads; scm_is_pair (s); s = scm_cdr (s))
+           {
+             Grob * h = unsmob_grob (scm_car (s));
+             Grob * dots = Rhythmic_head::get_dots (h);
+             if (dots)
+               common = dots->common_refpoint (common, X_AXIS);
+           }
        }
     }
   while (flip (&d) != LEFT);
@@ -69,8 +71,8 @@ Ottava_bracket::print (SCM smob)
   SCM properties = Font_interface::text_font_alist_chain (me);
   SCM markup = me->get_property ("text");
   Stencil text;
-  if (Text_item::markup_p (markup)) 
-    text = *unsmob_stencil (Text_item::interpret_markup (paper->self_scm (), properties, markup));
+  if (Text_interface::markup_p (markup)) 
+    text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, markup));
 
 
   Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
@@ -88,19 +90,32 @@ Ottava_bracket::print (SCM smob)
       Interval ext;
       if (Note_column::has_interface (b))
        {
-         for (SCM s = b->get_property ("note-heads"); ly_c_pair_p (s); s =ly_cdr (s))
-           ext.unite (unsmob_grob (ly_car (s))->extent (common, X_AXIS));
+         for (SCM s = b->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s))
+           {
+             Grob * h = unsmob_grob (scm_car (s));
+             ext.unite (h->extent (common, X_AXIS));
+             Grob * dots = Rhythmic_head::get_dots (h);
+
+             if (dots && d == RIGHT)
+               {
+                 ext.unite (dots->extent (common, X_AXIS));  
+               }
+           }
        }
-
+      
       if (ext.is_empty ())
        {
-         Real x = b->relative_coordinate (common, X_AXIS);
-         ext = Interval (x,x);
+         ext = robust_relative_extent (b, common, X_AXIS);
        }
-      span_points[d] =  (broken [d]) ? b->extent (common, X_AXIS)[-d] : ext[d];
 
       if (broken[d])
-       shorten [d] = 0.0; 
+       {
+         span_points[d] = b->extent (common, X_AXIS)[RIGHT];
+         shorten[d] = 0.;
+       }
+           
+      else
+       span_points[d] = ext[d];
     }
   while (flip (&d) != LEFT);