]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/ottava-bracket.cc
* lily/paper-book.cc (output): call output-preview-framework
[lilypond.git] / lily / ottava-bracket.cc
index 2e991f7ec0924802105a4a68d9cf9413c3b7523e..8f86a03eff62b9ffb5cbf0c3e6d1c6f99e5cecbb 100644 (file)
@@ -7,14 +7,14 @@
 
  */
 
-#include "molecule.hh"
+#include "stencil.hh"
 #include "text-item.hh"
 #include "text-spanner.hh"
 #include "line-spanner.hh"
 #include "spanner.hh"
 #include "font-interface.hh"
 #include "dimensions.hh"
-#include "paper-def.hh"
+#include "output-def.hh"
 #include "warn.hh"
 #include "paper-column.hh"
 #include "staff-symbol-referencer.hh"
@@ -24,7 +24,7 @@
 
 struct Ottava_bracket
 {
-  DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM));
+  DECLARE_SCHEME_CALLBACK (print, (SCM));
   static bool has_interface (Grob*);
 };
 
@@ -39,9 +39,9 @@ struct Ottava_bracket
 
 */
 
-MAKE_SCHEME_CALLBACK (Ottava_bracket, brew_molecule, 1);
+MAKE_SCHEME_CALLBACK (Ottava_bracket, print, 1);
 SCM
-Ottava_bracket::brew_molecule (SCM smob)
+Ottava_bracket::print (SCM smob)
 {
   Spanner*me  = dynamic_cast<Spanner*> (unsmob_grob (smob));
   
@@ -49,7 +49,7 @@ Ottava_bracket::brew_molecule (SCM smob)
   Interval span_points;
   
   Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS);
-  Paper_def * paper = me->get_paper();
+  Output_def * paper = me->get_paper ();
 
   
   Drul_array<bool> broken;
@@ -61,19 +61,19 @@ Ottava_bracket::brew_molecule (SCM smob)
 
       if (Note_column::has_interface (b))
        {
-         common = common_refpoint_of_list (b->get_grob_property ("heads"), common, X_AXIS);
+         common = common_refpoint_of_list (b->get_property ("heads"), common, X_AXIS);
        }
     }
   while (flip (&d) != LEFT);
 
-  SCM properties = Font_interface::font_alist_chain (me);
-  SCM markup = me->get_grob_property ("text");
-  Molecule text;
+  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_molecule (Text_item::interpret_markup (paper->self_scm (), properties, markup));
+    text = *unsmob_stencil (Text_item::interpret_markup (paper->self_scm (), properties, markup));
 
 
-  Drul_array<Real> shorten = robust_scm2interval (me->get_grob_property ("shorten-pair"),
+  Drul_array<Real> shorten = robust_scm2interval (me->get_property ("shorten-pair"),
                                                  Interval (0,0));
 
 
@@ -88,13 +88,15 @@ Ottava_bracket::brew_molecule (SCM smob)
       Interval ext;
       if (Note_column::has_interface (b))
        {
-         for (SCM s = b->get_grob_property ("note-heads"); gh_pair_p (s); s =gh_cdr (s))
-           ext.unite (unsmob_grob (gh_car (s))->extent (common, X_AXIS));
+         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));
        }
 
       if (ext.is_empty ())
-       ext = Interval (0,0);
-      
+       {
+         Real x = b->relative_coordinate (common, X_AXIS);
+         ext = Interval (x,x);
+       }
       span_points[d] =  (broken [d]) ? b->extent (common, X_AXIS)[-d] : ext[d];
 
       if (broken[d])
@@ -111,16 +113,16 @@ Ottava_bracket::brew_molecule (SCM smob)
   
   span_points[LEFT] = span_points[LEFT]
     <? (span_points[RIGHT] - text_size
-       - robust_scm2double (me->get_grob_property ("minimum-length"), -1.0)); 
+       - robust_scm2double (me->get_property ("minimum-length"), -1.0)); 
   
   Interval bracket_span_points = span_points;
   bracket_span_points[LEFT] += text_size;
   
-  Drul_array<Real> edge_height = robust_scm2interval (me->get_grob_property ("edge-height"),
+  Drul_array<Real> edge_height = robust_scm2interval (me->get_property ("edge-height"),
                                                      Interval (1.0, 1.0));
 
   
-  Drul_array<Real> flare = robust_scm2interval (me->get_grob_property ("bracket-flare"),
+  Drul_array<Real> flare = robust_scm2interval (me->get_property ("bracket-flare"),
                                                Interval (0,0));
 
 
@@ -130,12 +132,13 @@ Ottava_bracket::brew_molecule (SCM smob)
   if (broken[RIGHT])
     edge_height[RIGHT] = 0.0;
   
-  Molecule b;
+  Stencil b;
+  Interval empty;
   if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001)
     b = Tuplet_bracket::make_bracket (me,
                                      Y_AXIS, Offset (bracket_span_points.length (), 0),
                                       edge_height,
-                                     0.0,
+                                     empty,
                                      flare, shorten);
 
   /*
@@ -146,16 +149,21 @@ Ottava_bracket::brew_molecule (SCM smob)
        |
        |
        
-   */
+
+    Just a small amount, yes.  In tight situations, it is even
+    possible to center the `8' directly below the note, dropping the
+    ottava line completely...
+
+  */
   
-  b = Molecule (Box (b.extent (X_AXIS),
+  b = Stencil (Box (b.extent (X_AXIS),
                     Interval (0.1,0.1)),
-               b.get_expr ());
+               b.expr ());
   
   b.translate_axis (bracket_span_points[LEFT], X_AXIS);
   text.translate_axis (span_points[LEFT], X_AXIS);
   text.align_to (Y_AXIS, CENTER);
-  b.add_molecule (text);
+  b.add_stencil (text);
   
   b.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);