]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/text-spanner.cc (brew_molecule): clean up function. This
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 25 May 2003 23:11:52 +0000 (23:11 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 25 May 2003 23:11:52 +0000 (23:11 +0000)
fixes bugs with broken 8va spanners.

* lily/simple-spacer.cc (solve): also compute force for raggedright.
This prevents spurious line-breaks with raggedright

ChangeLog
input/regression/ottava-broken.ly [new file with mode: 0644]
lily/gourlay-breaking.cc
lily/simple-spacer.cc
lily/spanner.cc
lily/text-spanner.cc
scm/define-grobs.scm

index 61d67494e99baea58458b3685d3260e212d6fa80..321a3d2cf9842559ed25f9053f173e6128161f72 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,12 @@
-2003-05-25  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+2003-05-26  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
+
+       * lily/text-spanner.cc (brew_molecule): clean up function. This
+       fixes bugs with broken 8va spanners.
 
-       * lily/gourlay-breaking.cc (combine_demerits): add epsilon term to
-       force unique solution in zero-force case.
+       * lily/simple-spacer.cc (solve): also compute force for raggedright.
+       This prevents spurious line-breaks with raggedright
+       
+2003-05-25  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
        * lily/key-performer.cc (create_audio_elements): always use major
        key
diff --git a/input/regression/ottava-broken.ly b/input/regression/ottava-broken.ly
new file mode 100644 (file)
index 0000000..7a65990
--- /dev/null
@@ -0,0 +1,23 @@
+
+\header
+{
+    
+texidoc = "Ottava brackets behave properly at line breaks: no vertical
+line, and the horizontal line doesn't stick out."
+
+
+}
+\version "1.7.19"
+
+
+\paper { raggedright = ##t} 
+\score {
+  \notes\relative c''' \notes {
+  a2 b
+  #(set-octavation 1)
+  a2 b \break c a
+  #(set-octavation 0)
+  a b c a 
+}
+}
+
index 157fda61605a6dbcf785ca2d55c8627c7c4ef2aa..17cd71a5a2014bcc0c8b180a78e9a45b4bc542e4 100644 (file)
@@ -236,13 +236,6 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
    */
   Real demerit = abs (this_one.force_) +  abs (prev.force_ - this_one.force_)
     + break_penalties;
-
-  /*
-    This is rather ugly (not scale free), but we have to put a
-    penalty breaking two zero-force lines. Otherwise, we don't get a
-    unique solution (i.e.: line-breaks in short raggedright
-    fragments.)
-  */
   
   if (!this_one.satisfies_constraints_b_)
      {
index 893b8cb0fd7e25c2f4ebccfb44dcb50cf81b614a..a44e9f8d7546d8262d7a74af30fae5226a9f82c9 100644 (file)
@@ -342,6 +342,10 @@ Simple_spacer::solve (Column_x_positions *positions, bool ragged)
       */
     }
 
+  /*
+    For raggedright, we must have a measure of music density: this is
+    to prevent lots of short lines (which all have force = 0).
+    */
   if (ragged && line_len_ > 0)
     {
       Real len = positions->config_.top ();
@@ -351,10 +355,8 @@ Simple_spacer::solve (Column_x_positions *positions, bool ragged)
 
   positions->cols_ = spaced_cols_;
   positions->loose_cols_ = loose_cols_;
-  
   positions->satisfies_constraints_b_ = (line_len_ < 0) || active_b ();
 
-
   /*
     Check if breaking constraints are met.
    */
index fdd02cc3e0149184db7b9e2fe3090257a9baa2f0..5882795d0a25e29b51efc9545c04975aed34ee56 100644 (file)
@@ -274,7 +274,7 @@ Spanner::get_broken_left_end_align () const
 
   // Relevant only if left span point is first column in line
   if (sc != NULL &&
-     sc->break_status_dir () == RIGHT)
+      sc->break_status_dir () == RIGHT)
     {
       /*
        
index 0864d55a3d244126cd4b0ebd77a9940325da3793..792b52f86e3686f78e4c8a947eab26ef6ae98376 100644 (file)
@@ -50,51 +50,42 @@ Text_spanner::brew_molecule (SCM smob)
   SCM itp= me->get_grob_property ("if-text-padding");
   if (gh_number_p (itp))
     padding = gh_scm2double (itp);
-  
-  Real broken_left =  spanner->get_broken_left_end_align ();
-  Real width = spanner->spanner_length ();
-  width -= broken_left;
 
+  Grob *common = spanner->get_bound (LEFT)->common_refpoint (spanner->get_bound (RIGHT), X_AXIS);
+  
+  Interval span_points;
   Drul_array<bool> broken;
-  Drul_array<Real> extra_off;
   Direction d = LEFT;
   do
     {
-      extra_off [d]=0;
       Item *b = spanner->get_bound (d);
       broken[d] = b->break_status_dir () != CENTER;
 
-      if (!broken [d])
+      if (broken[d])
        {
-
-         Interval e = b->extent (b, X_AXIS);
-         Real r = 0.0;
-         if (!e.empty_b ())
-           r = e[-d] + padding;
-
-         /* Text spanners such as ottava, should span from outer limits of
-            noteheads, iso (de)cresc. spanners that span the inner space */
-         if (me->get_grob_property ("enclose-bounds") != SCM_EOL)
-           {
-             width -= d * r;
-           }
-         else
-           {
-             width += d * r;
-             extra_off[d] = r;
-           }
+       if (d == LEFT)
+         span_points[d] = spanner->get_broken_left_end_align ();
+       else
+         span_points[d] = b->relative_coordinate (common, X_AXIS);
        }
+      else
+         {
+           bool encl = to_boolean (me->get_grob_property ("enclose-bounds"));
+           span_points[d] = b->extent (common, X_AXIS)[encl ? d : -d];
+         }
     }
   while (flip (&d) != LEFT);
 
+
+#if 0
+  /*
+    FIXME. - this switch   sucks. --hwn
+   */
   // FIXME: ecs tells us -- only for (de)cresc. spanners
   width += gh_scm2double (me->get_grob_property ("width-correct"));
-  /* /Ugh */
-
-  // who is ecs? --hwn
+#endif
 
   SCM properties = Font_interface::font_alist_chain (me);
-
   SCM edge_text = me->get_grob_property ("edge-text");
   Drul_array<Molecule> edge;
   if (gh_pair_p (edge_text))
@@ -103,18 +94,17 @@ Text_spanner::brew_molecule (SCM smob)
       do
        {
          /*  Don't repeat edge text for broken end */
-         if (!broken[d])
-           {
-             SCM text = index_get_cell (edge_text, d);
-             edge[d] = Text_item::text2molecule (me, text, properties);
-             if (!edge[d].empty_b ())
-               edge[d].align_to (Y_AXIS, CENTER);
-           }
+         if (broken[d])
+           continue;
+         
+         SCM text = index_get_cell (edge_text, d);
+         edge[d] = Text_item::text2molecule (me, text, properties);
+         if (!edge[d].empty_b ())
+           edge[d].align_to (Y_AXIS, CENTER);
        }
       while (flip (&d) != LEFT);
     }
-  width -= edge[LEFT].extent (X_AXIS).length ()
-    + edge[RIGHT].extent (X_AXIS).length ();
+
 
   Drul_array<Real> shorten;
   shorten[LEFT] = 0;
@@ -123,28 +113,16 @@ Text_spanner::brew_molecule (SCM smob)
   SCM s = me->get_grob_property ("shorten-pair");
   if (gh_pair_p (s))
     {
-      shorten[LEFT] = gh_scm2double (ly_car (s));
-      shorten[RIGHT] = gh_scm2double (ly_cdr (s));
-    }
-
-  width -= shorten[LEFT] + shorten[RIGHT];
-  
-  if (width < 0)
-    {
-      me->warning (_ ("Text_spanner too small"));
-      width = 0;
+      span_points[LEFT] += gh_scm2double (ly_car (s));
+      span_points[RIGHT] -= gh_scm2double (ly_cdr (s));
     }
-
-  /* ugh */
   
   Real thick = me->get_paper ()->get_var ("linethickness");  
   SCM st = me->get_grob_property ("thickness");
   if (gh_number_p (st))
     {
       thick *=  gh_scm2double (st);
-
     }
-  Molecule line = Line_spanner::line_molecule (me, thick, width, 0);
   
   Drul_array<Molecule> edge_line;
   s = me->get_grob_property ("edge-height");
@@ -155,9 +133,12 @@ Text_spanner::brew_molecule (SCM smob)
       int dir = to_dir (me->get_grob_property ("direction"));
       do
        {
-         Real dx = ( gh_pair_p (ew)  ? 
-                     gh_scm2double (index_get_cell (ew, d)) * d :  
-                     0 );
+         if (broken[d])
+           continue;
+         
+         Real dx = (gh_pair_p (ew)  ? 
+                    gh_scm2double (index_get_cell (ew, d)) * d :  
+                    0);
          Real dy = gh_scm2double (index_get_cell (s, d)) * - dir;
          if (dy)
            {
@@ -168,20 +149,25 @@ Text_spanner::brew_molecule (SCM smob)
     }
   
   Molecule m;
-  if (!edge[LEFT].empty_b ())
-    m = edge[LEFT];
-
-  if (!edge_line[LEFT].empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, edge_line[LEFT], 0,0);
-  if (!line.empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, line,
-                  edge_line[LEFT].empty_b () ? 0 : -thick/2, 0);
-  if (!edge_line[RIGHT].empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, edge_line[RIGHT], -thick/2, 0);
-  if (!edge[RIGHT].empty_b ())
-    m.add_at_edge (X_AXIS, RIGHT, edge[RIGHT], 0, 0);
-  m.translate_axis (broken_left + extra_off[LEFT] + shorten[LEFT], X_AXIS);
+  do
+    {
+      Interval ext = edge[d].extent (X_AXIS);
+
+      edge[d].translate_axis (span_points[d], X_AXIS);
+      m.add_molecule (edge[d]);
+      edge_line[d].translate_axis (span_points[d], X_AXIS);
+      m.add_molecule (edge_line[d]);
+      if (!ext.empty_b ())
+       span_points[d] += -d *  ext[-d];
+    }
+  while (flip (&d) != LEFT);
+
+  Molecule l =Line_spanner::line_molecule (me, thick,
+                                          span_points.length (), 0);
+  l.translate_axis (span_points[LEFT], X_AXIS); 
+  m.add_molecule (l);
 
+  m.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS);
   return m.smobbed_copy ();
 }
 
index c08e3f955c5a3d1d7829b9f08a381e904345bff2..c7ebdc2c4d4e9f39b88791a7c818e53cd09f2548 100644 (file)
        (font-family . roman)
        (enclose-bounds . #t)
        (width-correct . 0.0)
-       (type . dotted-line)
+       (type . dashed-line)
        (edge-height . (0 . 1.5))
        (direction . 1)
        (meta . ((interfaces . (text-spanner-interface side-position-interface font-interface spanner-interface))))