]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/accidental-placement.cc (stagger_apes): try to arrange accs
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Jul 2002 21:40:40 +0000 (21:40 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 21 Jul 2002 21:40:40 +0000 (21:40 +0000)
in a C form, with the top accidental closet to the chord.

* lily/stem.cc (get_default_stem_end_position): don't crash if
lengths not set.
(get_default_stem_end_position): idem for stem-shorten.

* mf/feta-toevallig.mf: enlarge flat bbox.

* input/regression/lyrics-extender.ly: new file.

ChangeLog
input/regression/accidental-placement.ly
input/regression/lyrics-extender.ly [new file with mode: 0644]
lily/accidental-placement.cc
lily/include/lily-guile.hh
lily/lily-guile.cc
lily/stem.cc
mf/feta-toevallig.mf
scm/grob-property-description.scm

index cc86db65d5c55fbe3277df7093210b73eebff572..b86cb4cacad1684524dbf1ef04dd3c3a0b7721b4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2002-07-21  Han-Wen  <hanwen@cs.uu.nl>
 
+       * lily/accidental-placement.cc (stagger_apes): try to arrange accs
+       in a C form, with the top accidental closet to the chord.
+
+       * lily/stem.cc (get_default_stem_end_position): don't crash if
+       lengths not set.
+       (get_default_stem_end_position): idem for stem-shorten.
+
+       * mf/feta-toevallig.mf: enlarge flat bbox.
+
+       * input/regression/lyrics-extender.ly: new file.
+
        * lily/lyric-extender.cc (brew_molecule): don't add
        right-trim-amount if extender is broken.
 
index 3653addaef965c5a0d91fcb9c9eb352689e37086..6011fcc201ae88b2da723fb6ba747afd7ef426a7 100644 (file)
@@ -1,11 +1,21 @@
 \header {
     texidoc ="Accidentals are placed as closely as possible.
-Accidentals in corresponding octaves are aligned."
+Accidentals in corresponding octaves are aligned.
+The top accidental should be nearest to the chord. The
+flats in a sixth shoudl be staggered.  "
 }
 
 
 \score { \notes \context Voice \relative c' {
     cis4
+    c4
+ \transpose c'' {    
+  <bis4 es gis>
+  <es! as!>
+  <gis! cis!>
+  <g! des!>
+  <ges! es'!>
+}    
     <cis4 d es fis gis ases bes ces d dis >
     <bes'! fis!>     
     <bes! cis!>
diff --git a/input/regression/lyrics-extender.ly b/input/regression/lyrics-extender.ly
new file mode 100644 (file)
index 0000000..42966ad
--- /dev/null
@@ -0,0 +1,27 @@
+\header{
+    texidoc =
+
+    "Extenders that end a staff should not extend past the staff.
+Also shown: a trick to get an extender at the end of the staff.
+"
+
+}
+
+sopran = \notes \relative c'' {
+\time 3/4 a2.( | \break
+)g2 < g4 { s8 s8 } > |
+}
+
+text = \lyrics {
+vielt __ Zeit. __ " " 
+}
+
+\score {
+<
+\addlyrics
+  \context Staff \sopran
+  \context Lyrics \text
+>
+\paper { linewidth = 5.0\cm
+}
+}
index 9a0ab1fec317539dbc79556be67644ce3f892c02..1f102415c5f9538b66080bd6690870111171810d 100644 (file)
@@ -104,16 +104,7 @@ struct Accidental_placement_entry
 static Interval all_accidental_vertical_extent;
 Real ape_priority (Accidental_placement_entry const * a)
 {
-  Real c = a->vertical_extent_.center();
-
-  /*
-    far from center means we can fold more. Hopefully.
-   */
-  Real center_distance =
-    fabs(c - all_accidental_vertical_extent[LEFT]) >?
-    fabs(c - all_accidental_vertical_extent[RIGHT]);
-  
-  return 20 * a->vertical_extent_.length  ()  + center_distance;
+  return a->vertical_extent_[UP];
 }
 
   
@@ -124,6 +115,52 @@ int ape_compare (Accidental_placement_entry *const &a,
   return sign (ape_priority (a) - ape_priority(b));
 }
 
+int ape_rcompare (Accidental_placement_entry *const &a,
+                Accidental_placement_entry *const &b)
+{
+  return -sign (ape_priority (a) - ape_priority(b));
+}
+
+
+/*
+
+TODO: should favor
+
+  b
+ b
+
+placement
+*/
+void
+stagger_apes (Link_array<Accidental_placement_entry> *apes)
+{
+  Link_array<Accidental_placement_entry> asc = *apes;
+
+
+  asc.sort (&ape_compare);
+
+  apes->clear();
+
+  int i =0;
+  int parity = 1;
+  while (i < asc.size())
+    {
+      Accidental_placement_entry * a = 0;      
+      if (parity)
+       a = asc.pop();
+      else
+       a = asc[i++];
+
+      apes->push (a);
+      parity = !parity;
+    }
+
+  apes->reverse();
+}
+
+  
+
 /*
   Return: width as SCM interval.
 
@@ -265,7 +302,7 @@ Accidental_placement::position_accidentals (Grob * me)
       total.unite (y);
     }
   all_accidental_vertical_extent = total;
-  apes.sort (&ape_compare);  
+  stagger_apes (&apes);
 
   Accidental_placement_entry * head_ape = new Accidental_placement_entry;
   Grob *commonx = common_refpoint_of_array (heads, me, X_AXIS);  
index 8245965f3d1b4179894fee00d05a6fbdf75a9f70..53328a23d715f14884f07532417eea7965e6dd04 100644 (file)
@@ -156,8 +156,6 @@ Interval ly_scm2interval (SCM);
 Slice int_list_to_slice (SCM l);
 SCM ly_interval2scm (Drul_array<Real>);
 
-void taint (SCM *);
-
 
 SCM ly_parse_scm (char const* s, int* n);
 SCM ly_quote_scm (SCM s);
@@ -167,6 +165,8 @@ String print_scm_val (SCM val);
 SCM ly_number2string (SCM s);
 
 SCM parse_symbol_list (char const *);
+SCM robust_list_ref(int i, SCM l);
+
 
 inline SCM ly_cdr (SCM x) { return SCM_CDR (x); }
 inline SCM ly_car (SCM x) { return SCM_CAR (x); } 
index 69990c82b1015e7253c3c2623afd3fc9d4e3c08a..6f8bcbe4c0a8619243ce76afc45393466b8773a5 100644 (file)
@@ -812,3 +812,19 @@ int_list_to_slice (SCM l)
   return s;
 }
 
+
+
+
+/*
+  return I-th element, or last elt L
+
+  PRE: length (L) > 0
+ */
+SCM
+robust_list_ref(int i, SCM l)
+{
+  while (i--  && gh_pair_p (gh_cdr(l)))
+    l = gh_cdr (l);
+
+  return gh_car(l);
+}
index 8589fc0295f02595fcda8ed9d7e986984609c0aa..32ccc700b85a6b12e4f88e42503effd2e74fe0e5 100644 (file)
@@ -294,24 +294,22 @@ Stem::get_default_stem_end_position (Grob*me)
   else
     {
       s = me->get_grob_property ("lengths");
-      for (SCM q = s; q != SCM_EOL; q = ly_cdr (q))
-       a.push (gh_scm2double (ly_car (q)));
-               
-      // stem uses half-spaces
-      length_f = a[ ((duration_log (me) - 2) >? 0) <? (a.size () - 1)] * 2;
+      length_f = 3.5;
+      
+      if (gh_pair_p (s))
+       {
+         length_f = 2* gh_scm2double (robust_list_ref (duration_log(me) -2, s));
+       }
     }
 
 
-  a.clear ();
-  s = me->get_grob_property ("stem-shorten");
-  for (SCM q = s; gh_pair_p (q); q = ly_cdr (q))
-    a.push (gh_scm2double (ly_car (q)));
-
-
-  // stem uses half-spaces
-
-  // fixme: use scm_list_n_ref () iso. array[]
-  Real shorten_f = a[ ((duration_log (me) - 2) >? 0) <? (a.size () - 1)] * 2;
+  Real shorten_f = 0.0;
+  
+  SCM sshorten = me->get_grob_property ("stem-shorten");
+  if (gh_pair_p (sshorten))
+    {
+      shorten_f = 2* gh_scm2double (robust_list_ref ((duration_log (me) - 2) >? 0, sshorten));
+    }
 
   /* On boundary: shorten only half */
   if (abs (chord_start_y (me)) == 0.5)
@@ -760,20 +758,6 @@ Stem::beam_l (Grob*me)
   return unsmob_grob (b);
 }
 
-/*
-  return I-th element, or last elt L
-
-  PRE: length (L) > 0
- */
-SCM
-robust_list_ref(int i, SCM l)
-{
-  while (i--  && gh_pair_p (gh_cdr(l)))
-    l = gh_cdr (l);
-
-  return gh_car(l);
-}
-
 // ugh still very long.
 Stem_info
 Stem::calc_stem_info (Grob*me) 
index 4d6dd6199634b4e50718331533149b24a83100de..3363568582ce60ac246369f97ee4fe13918088d8 100644 (file)
@@ -251,7 +251,7 @@ enddef;
 % unfortunately, 600dpi is not enough to show the brush of the stem.
 %
 fet_beginchar("Flat", "-1", "flat")
-       set_char_box(1.2 stafflinethickness#, .8 staff_space#, .5 staff_space#, 2 staff_space#);
+       set_char_box(1.2 stafflinethickness#, .8 staff_space#, 0.6 staff_space#, 2 staff_space#);
        draw_meta_flat(0, w, 1/3 staff_space);
        fet_endchar;
 
index 61934849a616b77ffe7a4b5a0fcf0a8aac0d74b5..27aca00c771d75b799dec152e1cfb5343a26f60d 100644 (file)
@@ -247,7 +247,10 @@ For barline, space after a thick line.")
 (grob-property-description 'left-widen boolean? "Whether the left edge of a piano pedal bracket should be widened by the first element of edge-widen.")
 
 (grob-property-description 'length number? "Stem length for unbeamed stems, only for user override.")
-(grob-property-description 'lengths list? "Stem length given multiplicity of flag.")
+(grob-property-description 'lengths list? "Stem length given
+multiplicity of flag.  The Nth element of the list gives the stem
+length of a note with N flags.
+")
 (grob-property-description 'line-count integer? "Number of staff
 lines.  If you want to override this for staffs individually, you must
 use @code{\outputproperty}. @code{\property .. \override} will not
@@ -379,7 +382,9 @@ being the style. It returns a (X . Y) pair, specifying location in
 terms of note head bounding box.")
 (grob-property-description 'stem-end-position number? "Where does the stem end (the end is opposite to the support-head.")
 
-(grob-property-description 'stem-shorten list? "shorten stems in forced directions given flag multiplicity.")
+(grob-property-description 'stem-shorten list? "shorten stems in forced directions given flag multiplicity:
+the Nth element of the list gives the amount stem shortening of a note with N flags.
+")
 (grob-property-description 'stem-spacing-correction number? "optical correction amount.  [TODO: doco] ")
 (grob-property-description 'stems grob-list? "list of stem objects, corresponding to the notes that the arpeggio has to be before.")
 (grob-property-description 'style symbol? "a string determining what style of  glyph is typeset. Valid choices depend on the function that is reading this property. .")