]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/slur-script-inside.ly: new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 24 Aug 2004 21:34:36 +0000 (21:34 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Tue, 24 Aug 2004 21:34:36 +0000 (21:34 +0000)
* lily/new-slur.cc (outside_slur_callback): new function, to make
scripts avoid slurs

* lily/slur-engraver.cc (finalize):

* lily/script-interface.cc: add inside-slur property.

* lily/slur-engraver.cc (finalize): read inside-slur property.

* scm/lily.scm (postscript->png): use ~a iso. ~s

* ly/property-init.ly (unHideNotes): hide accidentals at staff
level. Fixes: hideNotes-accidental.ly

ChangeLog
input/regression/slur-script-inside.ly [new file with mode: 0644]
lily/drum-note-engraver.cc
lily/include/new-slur.hh
lily/include/script-interface.hh
lily/new-fingering-engraver.cc
lily/new-slur.cc
lily/script-engraver.cc
lily/side-position-interface.cc
lily/slur-engraver.cc
scm/script.scm

index e46d4cd1898966734fe7fc753c0fbb639377a76a..c69eaf084751ea4463ebdc1aacb42d0a310e48be 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2004-08-24  Han-Wen Nienhuys   <hanwen@xs4all.nl>
 
+       * input/regression/slur-script-inside.ly: new file.
+
+       * lily/new-slur.cc (outside_slur_callback): new function, to make
+       scripts avoid slurs 
+
+       * lily/slur-engraver.cc (finalize): 
+
+       * lily/script-interface.cc: add inside-slur property.
+
+       * lily/slur-engraver.cc (finalize): read inside-slur property.
+
        * scm/lily.scm (postscript->png): use ~a iso. ~s 
 
        * ly/property-init.ly (unHideNotes): hide accidentals at staff
diff --git a/input/regression/slur-script-inside.ly b/input/regression/slur-script-inside.ly
new file mode 100644 (file)
index 0000000..93ac982
--- /dev/null
@@ -0,0 +1,22 @@
+\header {
+
+    texidoc = "Slurs avoid scripts with @code{inside-slur} set
+    true, while scripts avoid slurs if @code{inside-slur} set to
+    false."
+
+}
+
+
+\version "2.3.12"
+
+\paper { raggedright = ##t }
+
+\relative c''{
+    \clef alto
+    \slurUp
+    \override Script #'inside-slur = ##t 
+    c4(^\downbow b) 
+    \override Script #'inside-slur = ##f 
+    c4(^\downbow b) 
+    c4^\downbow b 
+}
index 3143bcf78c9ced40c3e8957fc16e447516ddfc73..e26cdceebff0240656db94dca136a195c8424d4f 100644 (file)
@@ -104,8 +104,8 @@ Drum_notes_engraver::process_music ()
          if (ly_c_string_p (script))
            {
              Item *p  = make_item ("Script", ev->self_scm ());
-             SCM desc  = SCM_EOL;
-             make_script_from_event (p, &desc,
+             bool follow;
+             make_script_from_event (p, &follow,
                                      context (), script,
                                      0);
 
index 51c837c8c43092955a98e7c3eeda1899a24b371b..25caa9528cff8ec92f39dae41906346e7efd361e 100644 (file)
@@ -23,7 +23,7 @@ public:
   DECLARE_SCHEME_CALLBACK (print, (SCM));
   DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM));
   DECLARE_SCHEME_CALLBACK (height, (SCM,SCM));
-
+  DECLARE_SCHEME_CALLBACK (outside_slur_callback, (SCM,SCM));
   static bool has_interface (Grob *);
   static Bezier get_curve (Grob*me);
 };
index fbef77562a2aacd35652ac67a53ffe871664d972..c5ed3291300249e5825eaf97e746bbe703884796 100644 (file)
@@ -26,7 +26,7 @@ public:
   DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM));
 };
 
-void make_script_from_event (Grob *p, SCM *descr, Context *tg,
+void make_script_from_event (Grob *p, bool *follow, Context *tg,
                             SCM type, int index);
 
 #endif /* SCRIPT_INTERFACE_HH */
index 3dbb171395178ddc75d91674afcde5fc07f092be..e40c970a372574342580bf74b6d7376740a6de79 100644 (file)
@@ -24,7 +24,7 @@ struct Finger_tuple
   Grob *script_;
   Music *note_event_;
   Music *finger_event_;
-  SCM description_;
+  bool follow_into_staff_;
   int position_;
 
   Finger_tuple ()
@@ -32,7 +32,7 @@ struct Finger_tuple
     position_ = 0;
     head_ = script_ = 0;
     note_event_ = finger_event_ = 0;
-    description_ = SCM_EOL;
+    follow_into_staff_ = false;
   }
   static int compare (Finger_tuple const & c1, Finger_tuple const & c2)
   {
@@ -114,7 +114,7 @@ New_fingering_engraver::add_script (Grob * head,
   Finger_tuple ft ;
 
   Grob * g=  make_item ("Script", event->self_scm () );
-  make_script_from_event (g, &ft.description_, context (),
+  make_script_from_event (g, &ft.follow_into_staff_, context (),
                          event->get_property ("articulation-type"), 0);
   if (g)
     {
@@ -300,8 +300,7 @@ New_fingering_engraver::stop_translation_timestep ()
       if (stem_ && to_dir (sc->get_property ("side-relative-direction")))
        sc->set_property ("direction-source", stem_->self_scm ());
       
-      SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"), articulations_[i].description_);
-      if (ly_c_pair_p (follow) && to_boolean (ly_cdr (follow)))
+      if (articulations_[i].follow_into_staff_)
        {
          sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
          sc->set_property ("staff-padding" , SCM_EOL);
index 5da6a302ee19bbcdce8f6e5c6cc4405cf826c569..78b569053e18fde0ae19ff4966fa451c840ce06e 100644 (file)
@@ -129,3 +129,55 @@ New_slur::add_extra_encompass (Grob*me, Grob*n)
 ADD_INTERFACE (New_slur, "new-slur-interface",
               "A slur",
               "encompass-objects control-points dashed details direction height-limit note-columns ratio thickness");
+
+
+
+MAKE_SCHEME_CALLBACK (New_slur, outside_slur_callback, 2);
+SCM
+New_slur::outside_slur_callback (SCM grob, SCM axis)
+{
+  Grob *script = unsmob_grob (grob);
+  Axis a = Axis (ly_scm2int (axis));
+  assert (a == Y_AXIS);
+
+  Grob *slur = unsmob_grob (script->get_property ("slur"));
+
+  if (!slur)
+    return scm_from_int (0);
+  
+  Grob *cx = script->common_refpoint (slur, X_AXIS);
+  Grob *cy = script->common_refpoint (slur, Y_AXIS);
+
+  Bezier curve = New_slur::get_curve (slur);
+
+  curve.translate (Offset (slur->relative_coordinate (cx, X_AXIS),
+                          slur->relative_coordinate (cy, Y_AXIS)));
+
+  Interval yext = robust_relative_extent (script, cy, Y_AXIS);
+  Interval xext = robust_relative_extent (script, cx, X_AXIS);
+
+
+  Real slur_padding = 0.2;     // todo: slur property, script property?
+  yext.widen (slur_padding);
+  
+  Interval bezext (curve.control_[0][X_AXIS],
+                  curve.control_[3][X_AXIS]);
+
+  Real x = xext.center ();
+  if (!bezext.contains (xext[RIGHT]))
+    x = xext[LEFT];
+  else if (!bezext.contains (xext[LEFT]))
+    x = xext[RIGHT];
+
+  
+  if (!bezext.contains (x))
+    return scm_make_real (0);
+
+  Real y = curve.get_other_coordinate (X_AXIS, x);
+  if (yext.contains (y)) 
+    {
+      Direction dir = get_grob_direction (script); 
+      return scm_make_real (y - yext[-dir] + dir * slur_padding);
+    }
+  return scm_make_real (0.0);
+}
index 21072b1132a9b61192c9bc9ccc9135c53927fe00..0cf404e7b10dc7ed2b8dda17beca92cf660977c3 100644 (file)
@@ -24,12 +24,12 @@ struct Script_tuple
 {
   Music *event_;
   Grob *script_;
-  SCM description_;
+  bool follow_into_staff_;
   Script_tuple ()
   {
+    follow_into_staff_ = false;
     event_ = 0;
     script_ = 0;
-    description_ = SCM_EOL;
   }
 };
 
@@ -85,10 +85,12 @@ copy_property (Grob *g, SCM sym, SCM alist)
     }
 }
 
-/* Add the properties, one by one for each Script.  A little space
-   (memory? --jcn) could be saved by tacking the props onto the Script
-   grob (i.e. make ScriptStaccato , ScriptMarcato, etc. ).  */
-void make_script_from_event (Grob *p, SCM *descr, Context *tg,
+/* Add the properties, one by one for each Script.  A little memory
+   could be saved by tacking the props onto the Script grob (i.e. make
+   ScriptStaccato , ScriptMarcato, etc. ).
+
+*/
+void make_script_from_event (Grob *p, bool * follow, Context *tg,
                             SCM art_type, int index)
 {
   SCM alist = tg->get_property ("scriptDefinitions");
@@ -104,24 +106,41 @@ void make_script_from_event (Grob *p, SCM *descr, Context *tg,
     }
 
   art = ly_cdr (art);
-  *descr = art;
 
-  copy_property (p, ly_symbol2scm ("script-stencil"), art);
-  copy_property (p, ly_symbol2scm ("direction"), art);
-  copy_property (p, ly_symbol2scm ("side-relative-direction"), art);
+  SCM follow_scm = scm_assoc (ly_symbol2scm ("follow-into-staff"),
+                             art);
 
-  int prio = 0;
-  SCM sprio = scm_assoc (ly_symbol2scm ("script-priority"), art);
-  if (ly_c_pair_p (sprio))
-    prio = ly_scm2int (ly_cdr (sprio));
+  *follow = ly_c_pair_p (follow_scm) && to_boolean (ly_cdr (follow_scm));
+  bool priority_found = false ; 
+    
+  for (SCM s = art ; ly_c_pair_p (s); s = ly_cdr (s))
+    {
+      SCM sym = ly_caar (s);
+      SCM val = ly_cdar (s);
 
-  /* 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.  */
-  prio += index;
+      if (sym == ly_symbol2scm ("script-priority"))
+       {
+         priority_found = true;
+         /* 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.  */
+         int prio  = ly_scm2int (val) +  index;
+         
+        
+         val = scm_int2num (prio);
+       }
+      if (p->internal_get_property (sym) == SCM_EOL)
+       p->internal_set_property (sym, val);
+    }
 
+  if (!priority_found)
+    {
+      p->set_property ("script-priority",
+                      scm_int2num (index));
+    }
+  
   Side_position_interface::set_axis (p, Y_AXIS);
-  p->set_property ("script-priority", scm_int2num (prio));
+
 }
 
 void
@@ -134,7 +153,7 @@ Script_engraver::process_music ()
 
       Grob *p = make_item ("Script", m->self_scm ());
 
-      make_script_from_event (p, &scripts_[i].description_, context (),
+      make_script_from_event (p, &scripts_[i].follow_into_staff_, context (),
                              m->get_property ("articulation-type"),
                              i);
 
@@ -206,17 +225,14 @@ Script_engraver::stop_translation_timestep ()
 {
   int script_count = scripts_.size ();
   for (int i = 0; i < script_count; i++)
-    if (Grob *sc = scripts_[i].script_)
+    if (scripts_[i].follow_into_staff_)
       {
-       SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"),
-                               scripts_[i].description_);
-       if (ly_c_pair_p (follow) && to_boolean (ly_cdr (follow)))
-         {
-           sc->add_offset_callback (Side_position_interface
-                                    ::quantised_position_proc, Y_AXIS);
-           sc->set_property ("staff-padding", SCM_EOL);
-         }
+       Grob *sc = scripts_[i].script_;
+       sc->add_offset_callback (Side_position_interface
+                                ::quantised_position_proc, Y_AXIS);
+       sc->set_property ("staff-padding", SCM_EOL);
       }
+  
   scripts_.clear ();
 }
 
index 896bbb2b3326dae03c30bf754e6c89a5e9abbf55..6220a609f045129c22435fd54f49267244fb87b7 100644 (file)
@@ -231,7 +231,6 @@ Side_position_interface::aligned_side (SCM element_smob, SCM axis)
       Grob *common = me->common_refpoint (st, Y_AXIS);
       
       Interval staff_size = st->extent (common, Y_AXIS);
-      Interval me_ext = me->extent (common, a);
       Real diff =  d*staff_size[d] + padding - d*(o + iv[-d]);
       o += (d*  (diff >? 0));
     }
@@ -246,8 +245,6 @@ Side_position_interface::set_axis (Grob*me, Axis a)
   me->add_offset_callback (Side_position_interface::aligned_side_proc, a);
 }
 
-
-
 // ugh. doesn't catch all variants. 
 Axis
 Side_position_interface::get_axis (Grob*me)
index 2f1cc065e8f5b6c87e310fd01f3debb35142e61b..bad108894a7d94d031eb26b7ec2aaef4b02bd997 100644 (file)
@@ -12,6 +12,7 @@
 #include "directional-element-interface.hh"
 #include "engraver.hh"
 #include "spanner.hh"
+#include "tie.hh"
 
 /*
   It is possible that a slur starts and ends on the same note.  At
@@ -89,16 +90,30 @@ Slur_engraver::acknowledge_grob (Grob_info info)
     }
   else
     {
+      SCM inside = e->get_property ("inside-slur");
       if (Tie::has_interface (e)
-         || to_boolean (e->get_property ("inside-slur")))
+         || to_boolean (inside))
        {
          for (int i = slurs_.size (); i--; )
            New_slur::add_extra_encompass (slurs_[i], e);
          for (int i = end_slurs_.size (); i--; )
            New_slur::add_extra_encompass (end_slurs_[i], e);
        }
+      else if (inside == SCM_BOOL_F)
+       {
+         Grob *slur = slurs_.size()?slurs_[0] : 0;
+         slur =  (end_slurs_.size () && !slur)
+           ? end_slurs_[0] : slur;
+
+         if (slur)
+           {
+             e->add_offset_callback (New_slur::outside_slur_callback_proc, Y_AXIS);
+             e->set_property ("slur", slur->self_scm());
+           }
+       }
     }
 }
+
 void
 Slur_engraver::finalize ()
 {
index 0c57f21b5a95eb2822b578a3dceeb219ed59516c..2da8149027fe4ad309ad4b81b118a3c092c08701 100644 (file)
@@ -7,21 +7,19 @@
 (set! default-script-alist
       (append 
        '(("thumb" .
-         (
-          (script-stencil . (feta . ("thumb"  . "thumb")))
+         ((script-stencil . (feta . ("thumb"  . "thumb")))
           (direction . 1)))
         ("accent" .
-         (
+         ((inside-slur . #t) 
+          (follow-into-staff . #t)
           (script-stencil . (feta . ("sforzato" .  "sforzato")))
-          (side-relative-direction . -1))
-         )      
+          (side-relative-direction . -1)))      
         ("marcato" .
-         (
-          (script-stencil . (feta . ("dmarcato" . "umarcato")))
+         ((script-stencil . (feta . ("dmarcato" . "umarcato")))
           (follow-into-staff . #t)
           (side-relative-direction .  -1)))
         ("staccatissimo" .
-         (
+         ((inside-slur . #t) 
           (script-stencil . (feta . ("dstaccatissimo" . "ustaccatissimo")))
           (side-relative-direction .  -1)))
         
@@ -76,6 +74,7 @@
          ((script-stencil . (feta . ("staccato" . "staccato")))
           (side-relative-direction .  -1)
           (follow-into-staff  . #t)
+          (inside-slur . #t) 
           (priority . -100)))
         ("tenuto" .
          ((script-stencil . (feta . ("tenuto" . "tenuto")))
           (direction . 1)))
         ("upbow" .
          ((script-stencil . (feta . ("upbow" . "upbow")))
+          (inside-slur . #f)
           (direction  . 1) ))
         ("downbow" .
          ((script-stencil . (feta . ("downbow" . "downbow")))
-          (direction  . 1) ))
+          (inside-slur . #f)
+          (direction  . 1)))
         ("lheel" .
          ((script-stencil . (feta . ("upedalheel" . "upedalheel")))
           (direction .  -1))