]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/script-column.cc (before_line_breaking): use stable sorting
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 30 Aug 2002 23:47:17 +0000 (23:47 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 30 Aug 2002 23:47:17 +0000 (23:47 +0000)
algorithm to preserve script ordering.
(grob_script_priority_less): new function

* lily/script-engraver.cc (process_music):
* lily/text-engraver.cc (process_acknowledged_grobs):
* lily/fingering-engraver.cc (make_script): don't use direction
for script-priority.

* scripts/ly2dvi.py (run_lilypond): don't exit if LilyPond fails,
but try to assemble the files anyway.

* input/regression/prefatory-empty-spacing.ly: new file.

ChangeLog
input/regression/prefatory-empty-spacing.ly [new file with mode: 0644]
input/regression/script-stacked.ly
lily/fingering-engraver.cc
lily/script-column.cc
lily/script-engraver.cc
lily/text-engraver.cc
scripts/ly2dvi.py

index d33ae4dd69f9fc78bca44d507977f7307a52ee47..605691784488d19cb5fc6138b3e535728811362b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2002-08-31  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * lily/script-column.cc (before_line_breaking): use stable sorting
+       algorithm to preserve script ordering.
+       (grob_script_priority_less): new function
+
+       * lily/script-engraver.cc (process_music): 
+       * lily/text-engraver.cc (process_acknowledged_grobs): 
+       * lily/fingering-engraver.cc (make_script): don't use direction
+       for script-priority.
+
+       * scripts/ly2dvi.py (run_lilypond): don't exit if LilyPond fails,
+       but try to assemble the files anyway.
+
+       * input/regression/prefatory-empty-spacing.ly: new file.
+
        * lily/break-align-interface.cc (do_alignment): translate last
        break-align-group if it is invisible/empty.
 
diff --git a/input/regression/prefatory-empty-spacing.ly b/input/regression/prefatory-empty-spacing.ly
new file mode 100644 (file)
index 0000000..2c3fb67
--- /dev/null
@@ -0,0 +1,13 @@
+
+\header {
+
+texidoc =" The A is atop an invisible barline. The barline
+although invisible, is also translated because it is the last one of
+the break alignment."
+    
+}
+
+\score{ \notes {
+a a a a \break
+\mark A
+a a a a}}
index aabf7a0236896b725722a7b4cb50f460ebdd5810..70e7e370575f9cb7d5425b5e35a1a407e846616f 100644 (file)
@@ -1,6 +1,7 @@
 \version "1.5.68"
 
 \header { 
-texidoc = "Scripts may b4e stacked."
+texidoc = "Scripts may be stacked."
 }
-\score { \notes { c''->-. } }
+
+\score { \notes { c'''->-. } }
index 120b580e28f961b95d8f6683a6b7d4ab01f79b1b..ee6612cc4e14724a3b2ea121eeb78f607d3a446e 100644 (file)
@@ -192,8 +192,8 @@ Fingering_engraver::make_script (Direction d, Music *r,Axis a,  int i)
   if (gh_number_p (s))
     priority = gh_scm2int (s);
   
-  /* Make sure they're in order of user input by adding index i. */
-  priority += d*i;
+  /* See script-engraver.cc */
+  priority += i;
 
   fingering->set_grob_property ("script-priority", gh_int2scm (priority));
 
index deab16f0266f46a6c48f5b58fd3fa1a4824a649d..2a6e38bea4702759aa816f233518768928e0aa45 100644 (file)
@@ -23,55 +23,59 @@ Script_column::add_staff_sided (Grob *me, Item *i)
   me->add_dependency (i);
 }
 
-static int
-staff_side_compare (Grob * const &i1,
-                   Grob * const &i2)
+LY_DEFINE(grob_script_priority_less,
+         "ly-grob-script-priority-less", 2, 0, 0, 
+         (SCM a, SCM b),
+         "Compare two grobs by script priority. For internal use.")
 {
+  Grob * i1 = unsmob_grob (a);
+  Grob* i2 = unsmob_grob (b);
+
   SCM p1 = i1->get_grob_property ("script-priority");
   SCM p2 = i2->get_grob_property ("script-priority");
 
-  return gh_scm2int (p1) - gh_scm2int (p2);
+  return gh_scm2int (p1) < gh_scm2int (p2) ? SCM_BOOL_T : SCM_BOOL_F;
 }
 
-MAKE_SCHEME_CALLBACK (Script_column,before_line_breaking,1);
 
+
+MAKE_SCHEME_CALLBACK (Script_column,before_line_breaking,1);
 SCM
 Script_column::before_line_breaking (SCM smob)
 {
   Grob* me = unsmob_grob (smob);
-  Drul_array<Link_array<Grob> > arrs;
+  Drul_array<SCM> scripts (SCM_EOL, SCM_EOL);
   Link_array<Grob> staff_sided 
     = Pointer_group_interface__extract_grobs (me, (Grob*)0, "scripts");
                                     
   for (int i=0; i < staff_sided.size (); i++)
     {
-      Direction d = Side_position_interface::get_direction (staff_sided[i]);
+      Grob* g = staff_sided[i];
+      Direction d = Side_position_interface::get_direction (g);
       if (!d)
        {
          programming_error ( "No direction for script?");
          d = DOWN;
-         staff_sided[i]->set_grob_property ("direction", gh_int2scm (d));
+         g->set_grob_property ("direction", gh_int2scm (d));
        }
       
-      arrs[d].push (staff_sided[i]);
+      scripts[d] = scm_cons (g->self_scm(), scripts[d]);
     }
 
   Direction d = DOWN;
   do {
-    Link_array<Grob> &arr
-      (arrs[d]);
+    SCM ss = scm_reverse_x (scripts[d], SCM_EOL);
     
-    arr.sort (staff_side_compare);
+    ss = scm_stable_sort_x (ss,  grob_script_priority_less_proc);
 
     Grob * last = 0;
-    for (int i=0; i < arr.size (); i++)
+    for (SCM s = ss; gh_pair_p (s); s = gh_cdr (s))
       {
-
+       Grob* g = unsmob_grob (gh_car (s));
        if (last)
-         Side_position_interface::add_support (arr[i],last);
-           
-       arr[i]->set_grob_property ("script-priority", SCM_EOL);
-       last = arr[i];
+         Side_position_interface::add_support (g,last);
+
+       last = g;
       }
     
   } while (flip (&d) != DOWN);
index 455ab600eb0861ef37485174f169ae98387d877f..aa16108eddc2fc43d4e73751415402d712ae82d8 100644 (file)
@@ -89,8 +89,11 @@ Script_engraver::process_music ()
       if (gh_number_p (s))
        priority = gh_scm2int (s);
 
-      /* Make sure they're in order of user input by adding index i. */
-      priority += i * (to_dir (force_dir) ? to_dir (force_dir) : 1);
+      /* Make sure they're in order of user input by adding index i.
+      Don't use the direction in this priority. Smaller means closer
+      to the head.
+      */
+      priority += i;
 
       if (ly_dir_p (force_dir) && to_dir (force_dir))
        p->set_grob_property ("direction", force_dir);
index a448d15ef820b7972cd97a1efae7e250183746fd..723e111741e04760f4bac5cde99403b68eb8f5cf 100644 (file)
@@ -105,8 +105,8 @@ Text_engraver::process_acknowledged_grobs ()
       if (gh_number_p (s))
        priority = gh_scm2int (s);
       
-      /* Make sure they're in order of user input by adding index i. */
-      priority += i * (r->get_direction () ? r->get_direction () : 1);
+      /* see script-engraver.cc */
+      priority += i;
       
       text->set_grob_property ("script-priority", gh_int2scm (priority));
 
index e8c871ec36d1852d72b0dce41db36f6ff2dd5a62..6428188e1fa0706073f602cc1d7c2fe47a48d915 100644 (file)
@@ -509,8 +509,10 @@ def run_lilypond (files, dep_prefix):
                       + _ ("Please submit a bug report to bug-lilypond@gnu.org") + "\n")
 
        if status:
-               error ( "\n" \
-                       + _ ("LilyPond failed on the input file (exit status %d).") % exit_status + "\n")
+               sys.stderr.write ( "\n" \
+                       + _ ("LilyPond failed on an input file (exit status %d).") % exit_status + "\n")
+               sys.stderr.write (_("Trying to salvage the rest.") +'\n\n')
+               
                
 
 def analyse_lilypond_output (filename, extra):