]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/grob-property.cc (get_interfaces): new function.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 16 Oct 2005 13:28:20 +0000 (13:28 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 16 Oct 2005 13:28:20 +0000 (13:28 +0000)
* lily/grob-scheme.cc (LY_DEFINE): new function ly:grob-interfaces

* lily/stem.cc (calc_stem_end_position): new function.
(calc_length): new function.
document details for stem.
remove Stem::get_direction()

* lily/grob-scheme.cc (LY_DEFINE): new function ly:grob-set-callback!

* lily/grob-property.cc (set_callback): new function.

* lily/script-engraver.cc (make_script_from_event): don't trigger callback.

* scm/define-grobs.scm: change print-function to stencil callback everywhere.

* lily/grob-property.cc (try_callback): remove marker if applicable.

* lily/stem.cc (height): idem.

* lily/stem-tremolo.cc: idem.

* lily/include/grob.hh: remove Grob_status.

* lily/beam.cc (calc_direction): use pseudo-property for beam
direction callback.
(calc_positions): use callback

* lily/stem.cc (calc_stem_end_position): use callback.
(calc_positioning_done): idem.
(calc_direction): idem.
(calc_stem_end_position): idem
(calc_stem_info): idem.

* lily/grob-property.cc (get_property_data): new function:
(try_callback): new function.

* scm/define-grob-properties.scm (all-user-grob-properties): doc
callbacks property.

34 files changed:
ChangeLog
input/regression/accidental-cautionary.ly
input/regression/accidental-double.ly
input/regression/accidental-ledger.ly
input/regression/accidental-octave.ly
input/regression/accidental-piano.ly
input/regression/accidental-placement.ly
input/regression/accidental-quarter.ly
input/regression/accidental-single-double.ly
input/regression/accidental-suggestions.ly
input/regression/accidental-tie.ly
input/regression/accidental-unbroken-tie-spacing.ly
input/regression/accidental-voice.ly
input/regression/accidental.ly
input/regression/alignment-order.ly
input/regression/alignment-vertical-spacing.ly
input/regression/ambitus.ly
input/regression/apply-context.ly
input/regression/apply-output.ly
lily/beam-concave.cc
lily/beam.cc
lily/grob-property.cc
lily/grob-scheme.cc
lily/include/grob.hh
lily/include/stem.hh
lily/note-column.cc
lily/note-spacing.cc
lily/script-engraver.cc
lily/staff-spacing.cc
lily/stem-tremolo.cc
lily/stem.cc
lily/tie-column-format.cc
scm/define-grob-properties.scm
scm/define-grobs.scm

index 76f752a461215a5b58e6077e39ffb7d68d240492..7e3e6c77e569cec095d3b10644e9a195772defb4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2005-10-16  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
+       * lily/grob-property.cc (get_interfaces): new function.
+
+       * lily/grob-scheme.cc (LY_DEFINE): new function ly:grob-interfaces
+
+       * lily/stem.cc (calc_stem_end_position): new function.
+       (calc_length): new function.
+       document details for stem.
+       remove Stem::get_direction()
+
+       * lily/grob-scheme.cc (LY_DEFINE): new function ly:grob-set-callback! 
+
+       * lily/grob-property.cc (set_callback): new function.
+
        * lily/script-engraver.cc (make_script_from_event): don't trigger callback.
 
        * lily/item-scheme.cc: new file.
index 596b7290c428904cfd21296d32c5280b17150e45..1edec4a0bc305cd8f94d618d101ae2e59350225f 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.6.0"
+\version "2.7.13"
 \header {
 
 texidoc = "Cautionary accidentals are indicated using either
index f0bd207e2aaf5157148a615c1caade541217e2e3..11460dd5778f215bfeb3f221a4f3ba34f15ed8ff 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.6.0"
+\version "2.7.13"
 \header {
        texidoc = "If two forced accidentals happen at the same time, only one
        sharp sign is printed."
index 1071d39a454d00db95866b0cc3293cf7d67f1f62..fae9f6d1e739aed3d9e6929fd4c916fa8f72de0e 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.6.0"
+\version "2.7.13"
 
 \header {
 
index 342465c6337a2e84c3370f59d40dc2121eb7f528..c79a4dc194648c1d86da8a038680aefa29d4cf0b 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 
 \header {
   texidoc="
index 642266bc3c2ae743543a0bc78c53c14b3808397d..0c229cc677ef2ae75cfcf0407540fba8dab824d3 100644 (file)
@@ -6,7 +6,7 @@ accidental."
 
 }
 
-\version "2.6.0"
+\version "2.7.13"
 
 \layout
 {
index ca1e7b6b32c24f28cd57c0caf26d0980b79322f3..c0ef2b07f42f43f646007d75f47aa8e01800bca0 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 
 \header {
 
index 32b3ef495a943ee61c9fd06af6b767eb3d1be654..0aca2134cdffd822ef6c204096bb8dd93fe908b6 100644 (file)
@@ -3,7 +3,7 @@
   texidoc = "Quarter tone notation is supported, including
     threequarters flat."
 }
-\version "2.6.0"
+\version "2.7.13"
 \layout { raggedright = ##t }
 
 \relative c'' {
index a7e196925e2c0c1bcbfd5bf3fa3f531ce23cbbb3..824e419fc6af51f4721226faf1918683490ffc4d 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 \header{
   texidoc="
 A sharp sign after a double sharp sign, as well as a flat sign
index d160ed01e98a60db3cb5901161353e9cf8496f96..7f1c534af3723d2d5db59add31966960b31ddfe4 100644 (file)
@@ -7,7 +7,7 @@ denoting Musica Ficta."
  
 }
 
-\version "2.7.2"
+\version "2.7.13"
 \paper {
   raggedright = ##t
 }
index 55146b18a94b78bf85a3cfe53e3695531c2e6c22..3651468934dcd244240f075cc960221606236d88 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.6.0"
+\version "2.7.13"
 
 \header {
   texidoc = "The second and third notes should not get accidentals,
index 4c718a4932004fb65e4b7486433f45335349e4c4..2ca2d36b3344a09ebdab333be088df76803c71fc 100644 (file)
@@ -4,7 +4,7 @@ texidoc = "Tied accidentaled notes (which cause reminder accidentals) do not
 wreak havoc in the spacing when unbroken."
 }
 
-\version "2.6.0"
+\version "2.7.13"
 \layout {
   raggedright = ##t
 }
index 66ab2514e8fd8caaa09186cc949ae66e0a203804..a0d5a2c5a147f00585eabda459f60010cf1ba769 100644 (file)
@@ -1,4 +1,4 @@
-\version "2.6.0"
+\version "2.7.13"
 \layout { raggedright = ##t }
 
 \header{
index 1e8de5dcb5a724493335aa4443ce084c83ae0add..0c04e44d46887ca9b1569dd867f6f7d6817639f3 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.6.0"
+\version "2.7.13"
 
 \header{
   texidoc="
index e933deb5baed25b8ce7e845166792cec76ec19eb..718187b862f9ac6899e4fae2b590d3238f584fd5 100644 (file)
@@ -3,7 +3,7 @@
 anywhere in the vertical alignment. "
 }
 
-\version "2.6.0"
+\version "2.7.13"
 
 \paper {
   raggedright = ##t
index 2fd0c0bd4f1c034920c7b26e8124ca8fe4d47943..5b7a8339b2dfa57f98aa45a007caa9fa853b6eea 100644 (file)
@@ -16,7 +16,7 @@ setting properties on individual object. @code{\override} in a
 
 }
 
-\version "2.7.10"
+\version "2.7.13"
 
 #(set-global-staff-size 13)
 
index c839d69568bbe6b549fa01155fe533858f7b8dde..ceab79155da4dd25af57f08f02bc97755cac489d 100644 (file)
@@ -6,7 +6,7 @@ signature. @code{AmbitusNoteHead} grobs also have ledger lines.
 
 "
 }
-\version "2.6.0"
+\version "2.7.13"
 
 \layout {
     raggedright = ##t
index 9eff3c001d57e3c31baceb9f33304e5dbbfd4136..e8bf2e1f16e848fd33df0d4a0eb509cbdb985123 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.7.10"
+\version "2.7.13"
 
 
 \header {
index 85829a0e889c93044e450bf0be382b473f83a450..59025e104490cc75a27dcb28a53c9dcf2e68fc45 100644 (file)
@@ -1,5 +1,5 @@
 
-\version "2.7.10
+\version "2.7.13
 \header {
 
   texidoc = "The @code{\applyOutput} expression is the most flexible way to
@@ -15,13 +15,13 @@ position.
 #(define  (mc-squared gr org cur)
   (let*
    (
-     (ifs (ly:grob-property gr 'interfaces))
+     (ifs (ly:grob-interfaces gr))
      (sp (ly:grob-property gr 'staff-position))
    )
    (if (and (memq 'note-head-interface ifs)
        (memq sp '(-2 -3 -5)))
     (begin
-     (ly:grob-set-property! gr 'print-function Text_interface::print)
+     (ly:grob-set-callback! gr 'stencil Text_interface::print)
      (ly:grob-set-property! gr 'font-family 'roman)
      (ly:grob-set-property!
       gr 'text
index f0e0cbde50a384afdd67cbfff4f2f01fdc8a2946..f8b31f460a6d1f926daa6d68513820a0c362efa7 100644 (file)
@@ -7,6 +7,7 @@
 #include "stem.hh"
 #include "beam.hh"
 #include "staff-symbol-referencer.hh"
+#include "directional-element-interface.hh"
 
 bool
 is_concave_single_notes (Array<int> const &positions, Direction beam_dir)
@@ -98,7 +99,7 @@ Beam::check_concave (SCM smob)
        stems.del (i);
       else
        {
-         if (Direction dir = Stem::get_direction (stems[i]))
+         if (Direction dir = get_grob_direction (stems[i]))
            beam_dir = dir;
        }
     }
index f4d29ed728d2d7af8c398e8f3def25ed5ea2bc84..2ee9e7086c67c6b15fd1e277d3d785eae799102c 100644 (file)
@@ -716,13 +716,12 @@ Beam::set_stem_shorten (Grob *me)
 
   SCM shorten_elt
     = robust_list_ref (beam_count -1, shorten_list);
-  Real shorten_f = scm_to_double (shorten_elt) * staff_space;
+  Real shorten = scm_to_double (shorten_elt) * staff_space;
 
-  /* your similar cute comment here */
-  shorten_f *= forced_fraction;
+  shorten *= forced_fraction;
 
-  if (shorten_f)
-    me->set_property ("shorten", scm_from_double (shorten_f));
+  if (shorten)
+    me->set_property ("shorten", scm_from_double (shorten));
 }
 
 MAKE_SCHEME_CALLBACK (Beam, calc_positions, 1);
@@ -942,7 +941,7 @@ Beam::shift_region_to_valid (SCM grob)
       if (Stem::is_invisible (s))
        continue;
 
-      Direction d = Stem::get_direction (s);
+      Direction d = get_grob_direction (s);
 
       Real left_y
        = Stem::get_stem_info (s).shortest_y_
@@ -1197,7 +1196,7 @@ Beam::forced_stem_count (Grob *me)
       /* I can imagine counting those boundaries as a half forced stem,
         but let's count them full for now. */
       if (abs (Stem::chord_start_y (s)) > 0.1
-         && (Stem::get_direction (s) != Stem::get_default_dir (s)))
+         && (get_grob_direction (s) != Stem::get_default_dir (s)))
        f++;
     }
   return f;
@@ -1292,7 +1291,7 @@ Beam::rest_collision_callback (SCM element_smob, SCM axis)
   Real dx = last_visible_stem (beam)->relative_coordinate (0, X_AXIS) - x0;
   Real slope = dy && dx ? dy / dx : 0;
 
-  Direction d = Stem::get_direction (stem);
+  Direction d = get_grob_direction (stem);
   Real stem_y = pos[LEFT] + (stem->relative_coordinate (0, X_AXIS) - x0) * slope;
 
   Real beam_translation = get_beam_translation (beam);
@@ -1370,7 +1369,7 @@ Beam::get_direction_beam_count (Grob *me, Direction d)
       /*
        Should we take invisible stems into account?
       */
-      if (Stem::get_direction (stems[i]) == d)
+      if (get_grob_direction (stems[i]) == d)
        bc = max (bc, (Stem::beam_multiplicity (stems[i]).length () + 1));
     }
 
index 0513299cd83c48264ccc9c8b3f46b9f2ae60304f..529315402ab533ac36994322e6576c539fddfed8 100644 (file)
@@ -26,6 +26,12 @@ Grob::get_property_alist_chain (SCM def) const
                     SCM_UNDEFINED);
 }
 
+SCM
+Grob::get_interfaces () const
+{
+  return interfaces_;
+}
+
 /*
   This special add_thing routine is slightly more efficient than
 
@@ -160,7 +166,7 @@ Grob::internal_get_property (SCM sym) const
 #ifndef NDEBUG
 #include "protected-scm.hh"
 Protected_scm grob_property_callback_stack = SCM_EOL;
-bool debug_property_callbacks;
+bool debug_property_callbacks = 1;
 #endif
 
 SCM
index 5626914b9121c159a9c93a041d2fcf0dcb804df9..e3f72d999b609d08b85345e7ab116d9345c4f61f 100644 (file)
@@ -23,9 +23,9 @@ LY_DEFINE (ly_grob_set_callback_x, "ly:grob-set-callback!",
   Grob *sc = unsmob_grob (grob);
   SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
   SCM_ASSERT_TYPE (scm_is_symbol (sym), sym, SCM_ARG2, __FUNCTION__, "symbol");
-  SCM_ASSERT_TYPE (ly_is_procedure (val), val, SCM_ARG3, __FUNCTION__, "procedure");
+  SCM_ASSERT_TYPE (ly_is_procedure (proc), proc, SCM_ARG3, __FUNCTION__, "procedure");
 
-  sc->set_callback (sym, val);
+  sc->set_callback (sym, proc);
   return SCM_UNSPECIFIED;
 }
 
@@ -58,6 +58,17 @@ LY_DEFINE (ly_grob_property, "ly:grob-property",
   return sc->internal_get_property (sym);
 }
 
+
+LY_DEFINE (ly_grob_interfaces, "ly:grob-interfaces",
+          1, 0, 0, (SCM grob),
+          "Return the interfaces list of  grob @var{grob}.")
+{
+  Grob *sc = unsmob_grob (grob);
+  SCM_ASSERT_TYPE (sc, grob, SCM_ARG1, __FUNCTION__, "grob");
+
+  return sc->get_interfaces ();
+}
+
 LY_DEFINE (ly_grob_object, "ly:grob-object",
           2, 0, 0, (SCM grob, SCM sym),
           "Return the value of a pointer in grob @var{g} of property @var{sym}. "
index 7a74d8baee991071ee093ab864e543134622c867..96cfba86c31aab0ed39071ea9c8eb22c09667f05 100644 (file)
@@ -108,7 +108,8 @@ public:
 
   bool internal_has_interface (SCM intf);
   static bool has_interface (Grob *me);
-
+  SCM get_interfaces () const;
+  
   virtual void handle_broken_dependencies ();
   virtual void handle_prebroken_dependencies ();
 
index a42daf856d55cd2205ceb1458f683bd82681f0c9..5e6260c6b0281ad52cd3610683880b523f3981f9 100644 (file)
@@ -26,24 +26,23 @@ public:
   static void add_head (Grob *me, Grob *n);
   static Stem_info get_stem_info (Grob *);
   static Real chord_start_y (Grob *);
-  static Direction get_direction (Grob *);
   static void set_stemend (Grob *, Real);
-  static Direction get_default_dir (Grob *);
   static Slice beam_multiplicity (Grob *);
+  static Direction get_default_dir (Grob*);
   static Real thickness (Grob *);
   static int head_count (Grob *);
   static bool is_invisible (Grob *);
   static Interval head_positions (Grob *);
-  static Real get_default_stem_end_position (Grob *me);
   static Real stem_end_position (Grob *);
   static Stencil flag (Grob *);
   static Stencil get_translated_flag (Grob*);
   static bool has_interface (Grob *);
   static void set_spacing_hints (Grob *);
-
+  
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (offset_callback, (SCM element, SCM axis));
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_length, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_end_position, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_info, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM));
index f49b65b986fe97ce49fa00377f770258a80590ff..0b7481529ad209f89027f371d4a21a305e70bb9a 100644 (file)
@@ -20,6 +20,7 @@ using namespace std;
 #include "note-head.hh"
 #include "accidental-placement.hh"
 #include "pointer-group-interface.hh"
+#include "directional-element-interface.hh"
 
 /*
   TODO: figure out if we can prune this class. This is just an
@@ -73,7 +74,7 @@ Note_column::dir (Grob *me)
 {
   Grob *stem = unsmob_grob (me->get_object ("stem"));
   if (stem && Stem::has_interface (stem))
-    return Stem::get_direction (stem);
+    return get_grob_direction (stem);
   else
     {
       extract_grob_set (me, "note-heads", heads);
index 8f55664c331711cc79ad1bbdf2a15cf043563f5d..81ed7de0bc1ca4ae2eeb822712893b7c5b9ec7ee 100644 (file)
@@ -8,6 +8,7 @@
 
 #include "note-spacing.hh"
 
+#include "directional-element-interface.hh"
 #include "grob-array.hh"
 #include "paper-column.hh"
 #include "moment.hh"
@@ -300,7 +301,7 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn,
          stems_drul[d] = stem;
          beams_drul[d] = Stem::get_beam (stem);
 
-         Direction sd = Stem::get_direction (stem);
+         Direction sd = get_grob_direction (stem);
          if (stem_dirs[d] && stem_dirs[d] != sd)
            {
              correct_stem_dirs = false;
index 26d72f361deba3737a82b79ace6b38c9f5a3a2ca..63284c67e2719c32b742b9fa628ac6779e822189 100644 (file)
@@ -212,7 +212,6 @@ Script_engraver::acknowledge_note_column (Grob_info info)
 
      As the note head to put it on is not known now, postpone this
      decision to Script_interface::calc_direction ().  */
-  */
   for (int i = 0; i < scripts_.size (); i++)
     {
       Grob *e = scripts_[i].script_;
index a862a16f116c79b0c62cf3eb10f4f2eb72b51bff..495458eb77824616ef9e192ef65f16d22df0642e 100644 (file)
@@ -20,6 +20,7 @@ using namespace std;
 #include "stem.hh"
 #include "accidental-placement.hh"
 #include "pointer-group-interface.hh"
+#include "directional-element-interface.hh"
 
 /*
   Insert some more space for the next note, in case it has a stem in
@@ -66,7 +67,7 @@ Staff_spacing::next_note_correction (Grob *me,
   if (!bar_size.is_empty ())
     if (Grob *stem = Note_column::get_stem (g))
       {
-       Direction d = Stem::get_direction (stem);
+       Direction d = get_grob_direction (stem);
        if (d == DOWN)
          {
            Real stem_start = Stem::head_positions (stem) [DOWN];
index e5571b1e42b850024a444a40917c5642c2f5604b..94e0c366835c32e56e7ca2a625c2cc4841da1aee 100644 (file)
@@ -123,7 +123,7 @@ Stem_tremolo::print (SCM grob)
     }
 
   Spanner *beam = Stem::get_beam (stem);
-  Direction stemdir = Stem::get_direction (stem);
+  Direction stemdir = get_grob_direction (stem);
   if (stemdir == 0)
     stemdir = UP;
 
index 3f1bf40f333f84a4ccf05c512d49de4bfede2a2b..7b90d475e13251b3b01c4902f26b2cb0c09b6c90 100644 (file)
@@ -80,48 +80,20 @@ Stem::chord_start_y (Grob *me)
 {
   Interval hp = head_positions (me);
   if (!hp.is_empty ())
-    return hp[get_direction (me)] * Staff_symbol_referencer::staff_space (me)
+    return hp[get_grob_direction (me)] * Staff_symbol_referencer::staff_space (me)
       * 0.5;
   return 0;
 }
 
-Real
-Stem::stem_end_position (Grob *me)
-{
-  SCM p = me->get_property ("stem-end-position");
-  Real pos;
-  if (!scm_is_number (p))
-    {
-      pos = get_default_stem_end_position (me);
-      me->set_property ("stem-end-position", scm_from_double (pos));
-    }
-  else
-    pos = scm_to_double (p);
-
-  return pos;
-}
-
-Direction
-Stem::get_direction (Grob *me)
-{
-  Direction d = get_grob_direction (me);
 
-  if (!d)
-    {
-      d = get_default_dir (me);
-      // urg, AAARGH!
-      set_grob_direction (me, d);
-    }
-  return d;
-}
 
 void
 Stem::set_stemend (Grob *me, Real se)
 {
   // todo: margins
-  Direction d = get_direction (me);
+  Direction d = get_grob_direction (me);
 
-  if (d && d * head_positions (me)[get_direction (me)] >= se * d)
+  if (d && d * head_positions (me)[get_grob_direction (me)] >= se * d)
     me->warning (_ ("weird stem size, check for narrow beams"));
 
   me->set_property ("stem-end-position", scm_from_double (se));
@@ -150,7 +122,7 @@ Stem::head_count (Grob *me)
 Grob *
 Stem::first_head (Grob *me)
 {
-  Direction d = get_direction (me);
+  Direction d = get_grob_direction (me);
   if (d)
     return extremal_heads (me)[-d];
   return 0;
@@ -160,7 +132,7 @@ Stem::first_head (Grob *me)
 Grob *
 Stem::last_head (Grob *me)
 {
-  Direction d = get_direction (me);
+  Direction d = get_grob_direction (me);
   if (d)
     return extremal_heads (me)[d];
   return 0;
@@ -248,54 +220,92 @@ Stem::is_invisible (Grob *me)
           && scm_to_int (me->get_property ("duration-log")) >= 1);
 }
 
-Direction
-Stem::get_default_dir (Grob *me)
+MAKE_SCHEME_CALLBACK (Stem, calc_stem_end_position, 1)
+SCM
+Stem::calc_stem_end_position (SCM smob)
 {
-  int staff_center = 0;
+  Grob *me = unsmob_grob (smob);
+
+  if (!head_count (me))
+    return scm_from_double (0.0);
+
+
+  Real ss = Staff_symbol_referencer::staff_space (me);
+  int durlog = duration_log (me);
+  Array<Real> a;
+
+  /* WARNING: IN HALF SPACES */
+  Real length = robust_scm2double (me->get_property ("length"), 7);
+
+  Direction dir = get_grob_direction (me);
   Interval hp = head_positions (me);
-  if (hp.is_empty ())
-    return CENTER;
+  Real st = dir ? hp[dir] + dir * length : 0;
 
-  int udistance = (int) (UP *hp[UP] - staff_center);
-  int ddistance = (int) (DOWN *hp[DOWN] - staff_center);
+  /* TODO: change name  to extend-stems to staff/center/'()  */
+  bool no_extend_b = to_boolean (me->get_property ("no-stem-extend"));
+  if (!no_extend_b && dir * st < 0)
+    st = 0.0;
+
+  /* Make a little room if we have a upflag and there is a dot.
+     previous approach was to lengthen the stem. This is not
+     good typesetting practice.  */
+  if (!get_beam (me) && dir == UP
+      && durlog > 2)
+    {
+      Grob *closest_to_flag = extremal_heads (me)[dir];
+      Grob *dots = closest_to_flag
+       ? Rhythmic_head::get_dots (closest_to_flag) : 0;
+
+      if (dots)
+       {
+         Real dp = Staff_symbol_referencer::get_position (dots);
+         Real flagy = flag (me).extent (Y_AXIS)[-dir] * 2 / ss;
+
+         /* Very gory: add myself to the X-support of the parent,
+            which should be a dot-column. */
+         if (dir * (st + flagy - dp) < 0.5)
+           {
+             Grob *par = dots->get_parent (X_AXIS);
 
-  if (sign (ddistance - udistance))
-    return Direction (sign (ddistance - udistance));
+             if (Dot_column::has_interface (par))
+               {
+                 Side_position_interface::add_support (par, me);
 
-  return to_dir (me->get_property ("neutral-direction"));
+                 /* TODO: apply some better logic here. The flag is
+                    curved inwards, so this will typically be too
+                    much. */
+               }
+           }
+       }
+    }
+
+  return scm_from_double (st);
 }
 
 
-Real
-Stem::get_default_stem_end_position (Grob *me)
+MAKE_SCHEME_CALLBACK (Stem, calc_length, 1)
+SCM
+Stem::calc_length (SCM smob)
 {
-  Real ss = Staff_symbol_referencer::staff_space (me);
+  Grob *me = unsmob_grob (smob);
+  
+  SCM details = me->get_property ("details");
   int durlog = duration_log (me);
-  SCM s;
-  Array<Real> a;
 
-  /* WARNING: IN HALF SPACES */
+  Real ss = Staff_symbol_referencer::staff_space (me);
   Real length = 7;
-  SCM scm_len = me->get_property ("length");
-  if (scm_is_number (scm_len))
-    length = scm_to_double (scm_len);
-  else
-    {
-      s = me->get_property ("lengths");
-      if (scm_is_pair (s))
-       length = 2 * scm_to_double (robust_list_ref (durlog - 2, s));
-    }
+  SCM s = scm_cdr (scm_assq (ly_symbol2scm ("lengths"), details));
+  if (scm_is_pair (s))
+    length = 2 * scm_to_double (robust_list_ref (durlog - 2, s));
 
-  /* URGURGURG
-     'set-default-stemlen' sets direction too.   */
-  Direction dir = get_direction (me);
+  Direction dir = get_grob_direction (me);
 
   /* Stems in unnatural (forced) direction should be shortened,
      according to [Roush & Gourlay] */
   Interval hp = head_positions (me);
   if (dir && dir * hp[dir] >= 0)
     {
-      SCM sshorten = me->get_property ("stem-shorten");
+      SCM sshorten = scm_cdr (scm_assq (ly_symbol2scm ("stem-shorten"), details));
       SCM scm_shorten = scm_is_pair (sshorten)
        ? robust_list_ref (max (duration_log (me) - 2, 0), sshorten) : SCM_EOL;
       Real shorten = 2* robust_scm2double (scm_shorten, 0);
@@ -333,49 +343,9 @@ Stem::get_default_stem_end_position (Grob *me)
        }
       length = max (length, minlen + 1.0);
     }
-
-  Real st = dir ? hp[dir] + dir * length : 0;
-
-  /* TODO: change name  to extend-stems to staff/center/'()  */
-  bool no_extend_b = to_boolean (me->get_property ("no-stem-extend"));
-  if (!no_extend_b && dir * st < 0)
-    st = 0.0;
-
-  /* Make a little room if we have a upflag and there is a dot.
-     previous approach was to lengthen the stem. This is not
-     good typesetting practice.  */
-  if (!get_beam (me) && dir == UP
-      && durlog > 2)
-    {
-      Grob *closest_to_flag = extremal_heads (me)[dir];
-      Grob *dots = closest_to_flag
-       ? Rhythmic_head::get_dots (closest_to_flag) : 0;
-
-      if (dots)
-       {
-         Real dp = Staff_symbol_referencer::get_position (dots);
-         Real flagy = flag (me).extent (Y_AXIS)[-dir] * 2 / ss;
-
-         /* Very gory: add myself to the X-support of the parent,
-            which should be a dot-column. */
-         if (dir * (st + flagy - dp) < 0.5)
-           {
-             Grob *par = dots->get_parent (X_AXIS);
-
-             if (Dot_column::has_interface (par))
-               {
-                 Side_position_interface::add_support (par, me);
-
-                 /* TODO: apply some better logic here. The flag is
-                    curved inwards, so this will typically be too
-                    much. */
-               }
-           }
-       }
-    }
-  return st;
+  
+  return scm_from_double (length);
 }
-
 /* The log of the duration (Number of hooks on the flag minus two)  */
 int
 Stem::duration_log (Grob *me)
@@ -395,7 +365,7 @@ Stem::calc_positioning_done (SCM smob)
   extract_grob_set (me, "note-heads", ro_heads);
   Link_array<Grob> heads (ro_heads);
   heads.sort (compare_position);
-  Direction dir = get_direction (me);
+  Direction dir = get_grob_direction (me);
 
   if (dir < 0)
     heads.reverse ();
@@ -425,7 +395,7 @@ Stem::calc_positioning_done (SCM smob)
            {
              Real ell = heads[i]->extent (heads[i], X_AXIS).length ();
 
-             Direction d = get_direction (me);
+             Direction d = get_grob_direction (me);
              /*
                Reversed head should be shifted ell-thickness, but this
                looks too crowded, so we only shift ell-0.5*thickness.
@@ -484,29 +454,31 @@ Stem::calc_direction (SCM smob)
     }
   else
     dir = get_default_dir (me);
-
+  
   return scm_from_int (dir);
 }
 
-MAKE_SCHEME_CALLBACK (Stem, calc_stem_end_position, 1);
-SCM
-Stem::calc_stem_end_position (SCM smob)
+Direction
+Stem::get_default_dir (Grob *me)
 {
-  Grob *me = unsmob_grob (smob);
-
-  /*
-    Do the calculations for visible stems, but also for invisible stems
-    with note heads (i.e. half notes.)
-  */
-  Real pos = 0.0;
-  if (head_count (me))
+  Direction dir = CENTER;
+  int staff_center = 0;
+  Interval hp = head_positions (me);
+  if (!hp.is_empty ())
     {
-      pos = stem_end_position (me);    // ugh. Trigger direction calc.
+      int udistance = (int) (UP *hp[UP] - staff_center);
+      int ddistance = (int) (DOWN *hp[DOWN] - staff_center);
+      
+      if (sign (ddistance - udistance))
+       dir = Direction (sign (ddistance - udistance));
+      else
+       dir = to_dir (me->get_property ("neutral-direction"));
     }
-
-  return scm_from_double (pos);
+  return dir;
 }
 
+
+
 MAKE_SCHEME_CALLBACK (Stem, height, 2);
 SCM
 Stem::height (SCM smob, SCM ax)
@@ -542,6 +514,12 @@ Stem::height (SCM smob, SCM ax)
   return ly_interval2scm (iv);
 }
 
+Real
+Stem::stem_end_position (Grob *me)
+{
+  return robust_scm2double (me->get_property ("stem-end-position"), 0);
+}
+
 Stencil
 Stem::flag (Grob *me)
 {
@@ -587,7 +565,7 @@ Stem::flag (Grob *me)
   else
     staffline_offs = "";
 
-  char dir = (get_direction (me) == UP) ? 'u' : 'd';
+  char dir = (get_grob_direction (me) == UP) ? 'u' : 'd';
   String font_char = flag_style
     + to_string (dir) + staffline_offs + to_string (log);
   Font_metric *fm = Font_interface::get_default_font (me);
@@ -652,7 +630,7 @@ Stem::print (SCM smob)
 {
   Grob *me = unsmob_grob (smob);
   Stencil mol;
-  Direction d = get_direction (me);
+  Direction d = get_grob_direction (me);
 
   Real stemlet_length = robust_scm2double (me->get_property ("stemlet-length"),
                                           0.0);
@@ -675,7 +653,7 @@ Stem::print (SCM smob)
   if (is_invisible (me))
     return SCM_EOL;
 
-  Real y2 = stem_end_position (me);
+  Real y2 = robust_scm2double (me->get_property ("stem-end-position"), 0.0);
   Real y1 = y2;
   Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
 
@@ -729,12 +707,12 @@ Stem::get_translated_flag (Grob *me)
   Stencil fl = flag (me);
   if (!fl.is_empty ())
     {
-      Direction d = get_direction (me);
+      Direction d = get_grob_direction (me);
       Real blot
        = me->get_layout ()->get_dimension (ly_symbol2scm ("blotdiameter"));
       Real stem_width = thickness (me);
       Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;
-      Real y2 = stem_end_position (me);
+      Real y2 = robust_scm2double (me->get_property ("stem-end-position"), 0.0);
       fl.translate_axis (y2 * half_space - d * blot / 2, Y_AXIS);
       fl.translate_axis (stem_width / 2, X_AXIS);
     }
@@ -762,7 +740,7 @@ Stem::offset_callback (SCM element_smob, SCM)
       else
        attach = Note_head::stem_attachment_coordinate (f, X_AXIS);
 
-      Direction d = get_direction (me);
+      Direction d = get_grob_direction (me);
       Real real_attach = head_wid.linear_combination (d * attach);
       r = real_attach;
 
@@ -825,7 +803,8 @@ Stem::calc_stem_info (SCM smob)
   int beam_count = Beam::get_direction_beam_count (beam, my_dir);
 
   /* Simple standard stem length */
-  SCM lengths = me->get_property ("beamed-lengths");
+  SCM details = me->get_property ("details");
+  SCM lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-lengths"), details));
   Real ideal_length
     = scm_to_double (robust_list_ref (beam_count - 1, lengths))
 
@@ -835,7 +814,7 @@ Stem::calc_stem_info (SCM smob)
     - 0.5 * beam_thickness;
 
   /* Condition: sane minimum free stem length (chord to beams) */
-  lengths = me->get_property ("beamed-minimum-free-lengths");
+  lengths = scm_cdr (scm_assq (ly_symbol2scm ("beamed-minimum-free-lengths"), details));
   Real ideal_minimum_free
     = scm_to_double (robust_list_ref (beam_count - 1, lengths))
     * staff_space;
@@ -893,11 +872,10 @@ Stem::calc_stem_info (SCM smob)
 
   ideal_y -= robust_scm2double (beam->get_property ("shorten"), 0);
 
+  SCM bemfl = scm_cdr (scm_assq (ly_symbol2scm ("beamed-extreme-minimum-free-lengths"), details));
+  
   Real minimum_free
-    = scm_to_double (robust_list_ref
-                    (beam_count - 1,
-                     me->get_property
-                     ("beamed-extreme-minimum-free-lengths")))
+    = scm_to_double (robust_list_ref (beam_count - 1, bemfl))
     * staff_space;
 
   Real minimum_length = minimum_free
@@ -935,22 +913,36 @@ ADD_INTERFACE (Stem, "stem-interface",
               "The stem represent the graphical stem.  "
               "In addition, it internally connects note heads, beams and"
               "tremolos. "
-              "Rests and whole notes have invisible stems.",
+              "Rests and whole notes have invisible stems."
+
+              "\n\nThe following properties may be set in the details list." 
+              "@table @code\n"
+              "@item  beamed-lengths \n"
+              "list of stem lengths given beam multiplicity. \n"
+              "@item beamed-minimum-free-lengths \n"
+              "list of normal minimum free stem lengths (chord to beams) given beam multiplicity.\n"
+              "@item beamed-extreme-minimum-free-lengths\n"
+              "list of extreme minimum free stem lengths (chord to beams) given beam multiplicity.\n"
+              "@item lengths\n"
+              "Default stem lengths. The list gives a length for each flag-count.\n"
+              "@item stem-shorten\n"
+              "How much a stem in a forced direction "
+              "should be shortened. The list gives an amount depending on the number "
+              "of flags/beams."
+              "@end table\n"
+
+              ,
 
               /* properties */
               
               "avoid-note-head "
               "beam "
-              "beamed-extreme-minimum-free-lengths "
-              "beamed-lengths "
-              "beamed-minimum-free-lengths "
               "beaming "
               "direction "
               "duration-log "
               "flag-style "
               "french-beaming "
               "length "
-              "lengths "
               "neutral-direction "
               "no-stem-extend "
               "note-heads "
@@ -958,7 +950,6 @@ ADD_INTERFACE (Stem, "stem-interface",
               "rests "
               "stem-end-position "
               "stem-info "
-              "stem-shorten "
               "stemlet-length "
               "stroke-style "
               "thickness "
index 3fb78cd16683ceb1f2261ceb4daa4240a6a0bff3..bde9073652ed65c46a8154f88fb4cd7c98d4ced5 100644 (file)
@@ -14,6 +14,7 @@
 #include "spanner.hh"
 #include "item.hh"
 #include "staff-symbol-referencer.hh"
+#include "directional-element-interface.hh"
 
 #include <set>
 
@@ -96,7 +97,7 @@ set_chord_outline (Array<Skyline_entry> *skyline,
       Interval y;
       y.add_point (Stem::stem_end_position (stem) * staff_space * .5);
 
-      Direction stemdir = Stem::get_direction (stem);
+      Direction stemdir = get_grob_direction (stem);
       y.add_point (Stem::head_positions (stem)[-stemdir]
                   * staff_space * .5);
          
index b80e958b390f582c06a23e5f890b5ef4cfc9f752..5a15927a730f402cd3a9255122b44e5e2719ef06 100644 (file)
@@ -69,10 +69,6 @@ Choices include @code{curved} and @code{straight}.")
  multiple lines of text.")
      (beam-thickness ,ly:dimension? "thickness, measured in staffspace.")
      (beam-width ,ly:dimension? "width of the tremolo sign.")
-     (beamed-lengths ,list? "list of stem lengths given beam multiplicity .")
-     (beamed-minimum-free-lengths ,list? "list of normal minimum free stem lengths (chord to beams) given beam multiplicity.")
-     (beamed-extreme-minimum-free-lengths ,list? "list of extreme minimum free stem lengths (chord to beams) given beam multiplicity.")
-
      (beamed-stem-shorten ,list? "How much to shorten beamed stems,
 when their direction is forced. It is a list, since the value is different
 depending on the number flags/beams.")
@@ -300,8 +296,7 @@ left to a group of accidentals.")
      (length ,ly:dimension? "User override for the stem length of
 unbeamed stems.")
      (length-fraction ,number? "Length of ledger line as fraction of note head size.")
-     (lengths ,list? "Default stem lengths. The list gives a length
-for each flag-count.")
+
      (line-break-system-details ,list?
                                "Alist of properties to use when this
 column is the start of a system.")
@@ -439,10 +434,6 @@ location in terms of note head bounding box.")
 
      (stem-end-position ,number? "Where does the stem end (the end is opposite to the support-head.")
 
-     (stem-shorten ,list? "How much a stem in a forced direction
-should be shortened. The list gives an amount depending on the number
-of flags/beams.")
-
      ;;[TODO: doco]
      (stem-spacing-correction ,number? "Optical correction amount for
 stems that are placed in tight configurations. For opposite
index d16e1c4b9a67eb2e195c0d6127158b39bb2549db..0c83785411ea9bbf204f9222d390f97414f73998 100644 (file)
                      (stem-info . ,Stem::calc_stem_info)
                      (positioning-done . ,Stem::calc_positioning_done)
                      (stencil . ,Stem::print)
+                     (length . ,Stem::calc_length)
                      ))
        (thickness . 1.3)
 
-       ;; 3.5 (or 3 measured from note head) is standard length
-       ;; 32nd, 64th flagged stems should be longer
-       (lengths . (3.5 3.5 3.5 4.5 5.0))
+       (details
+        . (
+           ;; 3.5 (or 3 measured from note head) is standard length
+           ;; 32nd, 64th flagged stems should be longer
+           (lengths . (3.5 3.5 3.5 4.5 5.0))
 
-       ;; Stems in unnatural (forced) direction should be shortened by
-       ;; one staff space, according to [Roush & Gourlay].
-       ;; Flagged stems we shorten only half a staff space.
-       (stem-shorten . (1.0 0.5))
+           ;; FIXME.  3.5 yields too long beams (according to Ross and
+           ;; looking at Baerenreiter examples) for a number of common
+           ;; boundary cases.  Subtracting half a beam thickness fixes
+           ;; this, but the bug may well be somewhere else.
 
-       ;; default stem direction for note on middle line
-       (neutral-direction . -1)
+           ;; FIXME this should come from 'lengths
+           (beamed-lengths . (3.26 3.5 3.6))
 
-       ;; FIXME.  3.5 yields too long beams (according to Ross and
-       ;; looking at Baerenreiter examples) for a number of common
-       ;; boundary cases.  Subtracting half a beam thickness fixes
-       ;; this, but the bug may well be somewhere else.
+           ;; The 'normal' minima
+           (beamed-minimum-free-lengths . (1.83 1.5 1.25))
+                                       ;(beamed-minimum-free-lengths . (2.0 1.83 1.25))
 
-       ;; FIXME this should come from 'lengths
+           ;; The 'extreme case' minima
+           (beamed-extreme-minimum-free-lengths . (2.0 1.25))
 
-       (beamed-lengths . (3.26 3.5 3.6))
+           ;; Stems in unnatural (forced) direction should be shortened by
+           ;; one staff space, according to [Roush & Gourlay].
+           ;; Flagged stems we shorten only half a staff space.
+           (stem-shorten . (1.0 0.5))
 
-       ;; We use the normal minima as minimum for the ideal lengths,
-       ;; and the extreme minima as abolute minimum length.
+           ))
+       
 
-       ;; The 'normal' minima
-       (beamed-minimum-free-lengths . (1.83 1.5 1.25))
-                                       ;(beamed-minimum-free-lengths . (2.0 1.83 1.25))
+       ;; default stem direction for note on middle line
+       (neutral-direction . -1)
 
-       ;; The 'extreme case' minima
-       (beamed-extreme-minimum-free-lengths . (2.0 1.25))
+       ;; We use the normal minima as minimum for the ideal lengths,
+       ;; and the extreme minima as abolute minimum length.
 
        (X-offset-callbacks . (,Stem::offset_callback))
        (X-extent-callback . ,Stem::width_callback)