lilypond-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creates callback for stem-begin-position. (issue4752048)


From: mtsolo
Subject: Creates callback for stem-begin-position. (issue4752048)
Date: Sat, 16 Jul 2011 16:34:05 +0000

Reviewers: ,

Message:
On Jul 1, 2011, at 5:50 PM, Han-Wen Nienhuys wrote:

On Thu, Jun 30, 2011 at 12:46 PM, address@hidden
<address@hidden> wrote:
can you show png examples of what you're trying to do?

Honestly, I cannot allow this patch in its current design. I don't see
a reason for an obscure feature to be touching code of note-spacing,
stem-tremolo, stem, beam etc.

If we add patches like this for every composer's favorite avant-garde
notation, the large parts of the lilypond codebase will shortly become
a tangle of hard to understand dependencies; code for uncommon
notation constructs should only be added if their implementation is
separate, modular and generic. This patch is neither.

Can you try a minimal implementation first? For example,

* Have a stem property that determines the end of the stem.
Currently, we have

   y2 = Staff_symbol_referencer::get_position (lh);

Done in this patch.

Cheers,
MS

Description:
Creates callback for stem-begin-position.

Please review this at http://codereview.appspot.com/4752048/

Affected files:
  M lily/include/stem.hh
  M lily/stem.cc
  M scm/define-grob-properties.scm
  M scm/define-grobs.scm


Index: lily/include/stem.hh
diff --git a/lily/include/stem.hh b/lily/include/stem.hh
index 27fe988b615bb33436ee152317bf027a82ab59ec..3388e34b590b8d92601e990fa4dd21ecc765545a 100644
--- a/lily/include/stem.hh
+++ b/lily/include/stem.hh
@@ -61,6 +61,7 @@ public:
   DECLARE_SCHEME_CALLBACK (calc_direction, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_beaming, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_length, (SCM));
+  DECLARE_SCHEME_CALLBACK (calc_stem_begin_position, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_end_position, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_stem_info, (SCM));
   DECLARE_SCHEME_CALLBACK (calc_positioning_done, (SCM));
Index: lily/stem.cc
diff --git a/lily/stem.cc b/lily/stem.cc
index 04bc4105922e0ecfbca2ea41da058b007ff25fe7..595499282c74d3ddf669bfa8b87417e913303dbc 100644
--- a/lily/stem.cc
+++ b/lily/stem.cc
@@ -733,6 +733,19 @@ Stem::thickness (Grob *me)
     * Staff_symbol_referencer::line_thickness (me);
 }

+MAKE_SCHEME_CALLBACK (Stem, calc_stem_begin_position, 1);
+SCM
+Stem::calc_stem_begin_position (SCM smob)
+{
+  Grob *me = unsmob_grob (smob);
+  Grob *lh
+    = to_boolean (me->get_property ("avoid-note-head"))
+    ? last_head (me)
+    : first_head (me);
+
+  return scm_from_double (Staff_symbol_referencer::get_position (lh));
+}
+
 MAKE_SCHEME_CALLBACK (Stem, print, 1);
 SCM
 Stem::print (SCM smob)
@@ -771,7 +784,7 @@ Stem::print (SCM smob)
   Real half_space = Staff_symbol_referencer::staff_space (me) * 0.5;

   if (lh)
-    y2 = Staff_symbol_referencer::get_position (lh);
+    y2 = robust_scm2double (me->get_property ("stem-begin-position"), 0.0);
   else if (stemlet)
     {
       Real beam_translation = Beam::get_beam_translation (beam);
@@ -1110,6 +1123,7 @@ ADD_INTERFACE (Stem,
               "note-heads "
               "positioning-done "
               "rests "
+              "stem-begin-position "
               "stem-end-position "
               "stem-info "
               "stemlet-length "
Index: scm/define-grob-properties.scm
diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm
index 5c2114338e053cb5468c5af6672d689d22d74ddf..40732d0e9d10997850ade1bc6b85a168fad765f8 100644
--- a/scm/define-grob-properties.scm
+++ b/scm/define-grob-properties.scm
@@ -841,6 +841,8 @@ the @code{staff-staff-spacing} property of the staff's
 structure.")
      (stem-attachment ,number-pair? "An @code{(@var{x} . @var{y})}
 pair where the stem attaches to the notehead.")
+     (stem-begin-position ,number? "Where does the stem begin (the
+position of the support-head)?")
      (stem-end-position ,number? "Where does the stem end (the end is
 opposite to the support-head)?")
      ;;[TODO: doco]
Index: scm/define-grobs.scm
diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm
index 177ebafc847426248949e66dc7d4d4c02b697415..393bc7c187ebaf3d165070c7713431aeb18a2295 100644
--- a/scm/define-grobs.scm
+++ b/scm/define-grobs.scm
@@ -1916,6 +1916,7 @@
        (length . ,ly:stem::calc-length)
        (neutral-direction . ,DOWN)
        (positioning-done . ,ly:stem::calc-positioning-done)
+       (stem-begin-position . ,ly:stem::calc-stem-begin-position)
        (stem-end-position . ,ly:stem::calc-stem-end-position)
        (stem-info . ,ly:stem::calc-stem-info)
        (stencil . ,ly:stem::print)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]