]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/ottava-bracket.cc
Run `make grand-replace'.
[lilypond.git] / lily / ottava-bracket.cc
index e5d04bb1d111da141d0d636ede8714e3d3e58cda..70757d91588da33b3aee287883e8e2e26756c9a4 100644 (file)
@@ -3,11 +3,10 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2004--2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
+  (c) 2004--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 
-#include "text-item.hh"
-#include "line-spanner.hh"
+#include "text-interface.hh"
 #include "spanner.hh"
 #include "font-interface.hh"
 #include "dimensions.hh"
 #include "directional-element-interface.hh"
 #include "tuplet-bracket.hh"
 #include "rhythmic-head.hh"
+#include "pointer-group-interface.hh"
 
 struct Ottava_bracket
 {
   DECLARE_SCHEME_CALLBACK (print, (SCM));
-  static bool has_interface (Grob *);
+  DECLARE_GROB_INTERFACE ();
 };
 
 /*
@@ -41,7 +41,7 @@ Ottava_bracket::print (SCM smob)
   Interval span_points;
 
   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
-  Output_def *layout = me->get_layout ();
+  Output_def *layout = me->layout ();
 
   Drul_array<bool> broken;
   Direction d = LEFT;
@@ -52,11 +52,11 @@ Ottava_bracket::print (SCM smob)
 
       if (Note_column::has_interface (b))
        {
-         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))
+         extract_grob_set (b, "note-heads", heads);
+         common = common_refpoint_of_array (heads, common, X_AXIS);
+         for (vsize i = 0; i < heads.size (); i++)
            {
-             Grob *h = unsmob_grob (scm_car (s));
+             Grob *h = heads[i];
              Grob *dots = Rhythmic_head::get_dots (h);
              if (dots)
                common = dots->common_refpoint (common, X_AXIS);
@@ -68,8 +68,9 @@ Ottava_bracket::print (SCM smob)
   SCM properties = Font_interface::text_font_alist_chain (me);
   SCM markup = me->get_property ("text");
   Stencil text;
-  if (Text_interface::markup_p (markup))
-    text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (), properties, markup));
+  if (Text_interface::is_markup (markup))
+    text = *unsmob_stencil (Text_interface::interpret_markup (layout->self_scm (),
+                                                             properties, markup));
 
   Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
                                                  Interval (0, 0));
@@ -85,23 +86,20 @@ Ottava_bracket::print (SCM smob)
       Interval ext;
       if (Note_column::has_interface (b))
        {
-         for (SCM s = b->get_property ("note-heads"); scm_is_pair (s); s = scm_cdr (s))
+         extract_grob_set (b, "note-heads", heads);
+         for (vsize i = 0; i < heads.size (); i++)
            {
-             Grob *h = unsmob_grob (scm_car (s));
+             Grob *h = heads[i];
              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));
-               }
+               ext.unite (dots->extent (common, X_AXIS));
            }
        }
 
       if (ext.is_empty ())
-       {
-         ext = robust_relative_extent (b, common, X_AXIS);
-       }
+       ext = robust_relative_extent (b, common, X_AXIS);
 
       if (broken[d])
        {
@@ -120,10 +118,10 @@ Ottava_bracket::print (SCM smob)
   Real text_size = text.extent (X_AXIS).is_empty ()
     ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3;
 
-  span_points[LEFT] =
-    min (span_points[LEFT],
-        (span_points[RIGHT] - text_size
-         - robust_scm2double (me->get_property ("minimum-length"), -1.0)));
+  span_points[LEFT]
+    min (span_points[LEFT],
+          (span_points[RIGHT] - text_size
+           - robust_scm2double (me->get_property ("minimum-length"), -1.0)));
 
   Interval bracket_span_points = span_points;
   bracket_span_points[LEFT] += text_size;
@@ -134,10 +132,13 @@ Ottava_bracket::print (SCM smob)
   Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
                                                Interval (0, 0));
 
-  edge_height[LEFT] = 0.0;
-  edge_height[RIGHT] *= -get_grob_direction (me);
-  if (broken[RIGHT])
-    edge_height[RIGHT] = 0.0;
+  do
+    {
+      edge_height[d] *= -get_grob_direction (me);
+      if (broken[d])
+       edge_height[d] = 0.0;
+    }
+  while (flip(&d) != LEFT);
 
   Stencil b;
   Interval empty;
@@ -177,7 +178,13 @@ Ottava_bracket::print (SCM smob)
   return b.smobbed_copy ();
 }
 
-ADD_INTERFACE (Ottava_bracket, "ottava-bracket-interface",
-              "An ottava bracket",
-              "edge-height bracket-flare shorten-pair minimum-length");
+ADD_INTERFACE (Ottava_bracket,
+              "An ottava bracket.",
+
+              /* properties */
+              "edge-height "
+              "bracket-flare "
+              "shorten-pair "
+              "minimum-length "
+              );