]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem.cc
* lily/coherent-ligature-engraver.cc,
[lilypond.git] / lily / stem.cc
index c9deff1dc9c019a8e72b2ea6cbb7e3fa7ce2c7d8..7a63f20b7c5eeb0e5d6a8f023f11ca07faadc34e 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1996--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
     Jan Nieuwenhuizen <janneke@gnu.org>
 
   TODO: This is way too hairy
@@ -418,10 +418,8 @@ Stem::position_noteheads (Grob*me)
 
 
   bool invisible = invisible_b (me);
-  Real thick = 0.0;
-  if (invisible)
-        thick = gh_scm2double (me->get_grob_property ("thickness"))
-         * me->get_paper ()->get_var ("linethickness");
+  Real thick = gh_scm2double (me->get_grob_property ("thickness"))
+     * me->get_paper ()->get_var ("linethickness");
       
 
   Grob *hed = support_head (me);
@@ -446,10 +444,16 @@ Stem::position_noteheads (Grob*me)
              Real l = Note_head::head_extent (heads[i], X_AXIS).length ();
 
              Direction d = get_direction (me);
-             heads[i]->translate_axis (l * d, X_AXIS);
+             /* reversed head should be shifted l-thickness, but this looks
+                too crowded, so we only shift l-0.5*thickness.
+                Notice that this leads to assymetry: Normal heads overlap
+                the stem 100% whereas reversed heads only overlaps the stem
+                50% */
+             #define magic 0.5
+             heads[i]->translate_axis ((l-thick*magic) * d, X_AXIS);
 
              if (invisible_b(me))
-               heads[i]->translate_axis (-thick *2* d , X_AXIS);
+               heads[i]->translate_axis (-thick*(2-magic) * d , X_AXIS);
 
              
             /* TODO:
@@ -529,24 +533,26 @@ Stem::height (SCM smob, SCM ax)
 Molecule
 Stem::flag (Grob*me)
 {
-  /* TODO: rename flag-style into something more appropriate,
-   e.g. "stroke-style", maybe with values "" (i.e. no stroke),
-   "single" and "double".  Needs more discussion.
-  */
-  String style, staffline_offs;
-
-  SCM style_scm = me->get_grob_property ("style");
-  if (gh_symbol_p (style_scm))
+  /* TODO: maybe property stroke-style should take different values,
+     e.g. "" (i.e. no stroke), "single" and "double" (currently, it's
+     '() or "grace").  */
+  String flag_style;
+  
+  SCM flag_style_scm = me->get_grob_property ("flag-style");
+  if (gh_symbol_p (flag_style_scm))
     {
-      style = (ly_scm2string (scm_symbol_to_string (style_scm)));
+      flag_style = ly_symbol2string (flag_style_scm);
     }
-  else
+
+  if (flag_style == "no-flag")
     {
-      style = "";
+      return Molecule ();
     }
+
   bool adjust = to_boolean (me->get_grob_property ("adjust-if-on-staffline"));
 
-  if (String::compare (style, "mensural") == 0)
+  String staffline_offs;
+  if (String::compare (flag_style, "mensural") == 0)
     /* Mensural notation: For notes on staff lines, use different
        flags than for notes between staff lines.  The idea is that
        flags are always vertically aligned with the staff lines,
@@ -593,9 +599,10 @@ Stem::flag (Grob*me)
     {
       staffline_offs = "";
     }
+
   char dir = (get_direction (me) == UP) ? 'u' : 'd';
   String font_char =
-    style + to_string (dir) + staffline_offs + to_string (duration_log (me));
+    flag_style + to_string (dir) + staffline_offs + to_string (duration_log (me));
   Font_metric *fm = Font_interface::get_default_font (me);
   Molecule flag = fm->find_by_name ("flags-" + font_char);
   if (flag.empty_b ())
@@ -603,13 +610,13 @@ Stem::flag (Grob*me)
       me->warning (_f ("flag `%s' not found", font_char));
     }
 
-  SCM stroke_scm = me->get_grob_property ("flag-style");
-  if (gh_string_p (stroke_scm))
+  SCM stroke_style_scm = me->get_grob_property ("stroke-style");
+  if (gh_string_p (stroke_style_scm))
     {
-      String stroke = ly_scm2string (stroke_scm);
-      if (!stroke.empty_b ())
+      String stroke_style = ly_scm2string (stroke_style_scm);
+      if (!stroke_style.empty_b ())
        {
-         String font_char = to_string (dir) + stroke;
+         String font_char = to_string (dir) + stroke_style;
          Molecule stroke = fm->find_by_name ("flags-" + font_char);
          if (stroke.empty_b ())
            {
@@ -665,9 +672,6 @@ Stem::brew_molecule (SCM smob)
   /*
     TODO: make  the stem start a direction ?
   */
-  
-
-  
   if (to_boolean (me->get_grob_property ("avoid-note-head")))
     {
       Grob * lh = last_head (me);
@@ -945,6 +949,6 @@ Stem::beam_multiplicity (Grob *stem)
 
 ADD_INTERFACE (Stem,"stem-interface",
   "A stem",
-  "up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length style no-stem-extend flag-style");
+  "french-beaming up-to-staff avoid-note-head adjust-if-on-staffline thickness stem-info beamed-lengths beamed-minimum-free-lengths beamed-extreme-minimum-free-lengths lengths beam stem-shorten duration-log beaming neutral-direction stem-end-position support-head note-heads direction length flag-style no-stem-extend stroke-style");