]> git.donarmstrong.com Git - lilypond.git/commitdiff
* scm/script.scm (default-script-alist): cleanup.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 2 Nov 2002 01:52:47 +0000 (01:52 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sat, 2 Nov 2002 01:52:47 +0000 (01:52 +0000)
* lily/script-engraver.cc (make_script_from_event): cleanup.

ChangeLog
lily/script-engraver.cc
scm/script.scm

index faacac1f7ee02de69abc61a6dfb7766d23f0d4f9..258069066a6755a4836bc134e8e47db52f0e3648 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2002-11-02  Han-Wen Nienhuys  <hanwen@cs.uu.nl>
 
+       * scm/script.scm (default-script-alist): cleanup.
+
+       * lily/script-engraver.cc (make_script_from_event): cleanup.
+
        * lily/lyric-combine-music-iterator.cc
        (Lyric_combine_music_iterator): remove superfluous events.
        (melisma_busy): new function.
index 69668f20cbeae1160ae529d746a86572157c2152..eabe2f86bdd6bf31275f59af4eb607cc1e59079c 100644 (file)
@@ -11,7 +11,7 @@
 #include "rhythmic-head.hh"
 #include "engraver.hh"
 #include "note-column.hh"
-
+#include "translator-group.hh"
 
 struct Script_tuple
 {
@@ -60,66 +60,80 @@ Script_engraver::try_music (Music *r)
 }
 
 void
-Script_engraver::process_music ()
+copy_property (Grob * g , SCM sym, SCM alist)
 {
-  for (int i=0; i < scripts_.size (); i++)
+  if (g->internal_get_grob_property (sym) == SCM_EOL)
     {
-      Music* l=scripts_[i].event_;
-
-      SCM alist = get_property ("scriptDefinitions");
-      SCM art = scm_assoc (l->get_mus_property ("articulation-type"), alist);
-
-      if (art == SCM_BOOL_F)
+      SCM entry = scm_assoc (sym,alist);
+      if (gh_pair_p (entry))
        {
-         String a = ly_scm2string (l->get_mus_property ("articulation-type"));
-         l->origin ()->warning (_f ("Don't know how to interpret articulation `%s'", a.to_str0 ()));
-                       
-         continue;
+         g->internal_set_grob_property (sym, gh_cdr (entry));
        }
-      
-      // todo -> use result of articulation-to-scriptdef directly as basic prop list.
-      Grob *p =new Item (get_property ("Script"));
-      scripts_[i].script_ = p;
-      art = ly_cdr (art);
+    }
+}
 
-      scripts_[i].description_ = art;
-      
-      p->set_grob_property ("script-molecule", ly_car (art));
 
-      art = ly_cdr (art);
-      art = ly_cdr (art);
-      SCM relative_stem_dir = ly_car (art);
-      art = ly_cdr (art);
+/*
+  We add the properties, one by one for each Script. We could save a
+  little space by tacking the props onto the Script grob (i.e. make
+  ScriptStaccato , ScriptMarcato, etc. )
+ */
+Grob *make_script_from_event (SCM * descr, Translator_group*tg, Music * event,
+                             int index)
+{
+  SCM alist = tg->get_property ("scriptDefinitions");
+  SCM art = scm_assoc (event->get_mus_property ("articulation-type"), alist);
 
-      SCM force_dir = l->get_mus_property ("direction");
-      if (ly_dir_p (force_dir) && !to_dir (force_dir))
-       force_dir = ly_car (art);
-      
-      art = ly_cdr (art);
-      int priority = gh_scm2int (ly_car (art));
+  if (art == SCM_BOOL_F)
+    {
+      String a = ly_scm2string (event->get_mus_property ("articulation-type"));
+      event->origin ()->warning (_f ("Don't know how to interpret articulation `%s'", a.to_str0 ()));
+      return 0 ;
+    }
 
-      SCM s = p->get_grob_property ("script-priority");
-      if (gh_number_p (s))
-       priority = gh_scm2int (s);
+  art = gh_cdr (art);
+    
+  Grob *p =new Item (tg->get_property ("Script"));
+  *descr = art;  
 
-      /*
-       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.
-      */
-      priority += i;
+  SCM force_dir = event->get_mus_property ("direction");
+  if (ly_dir_p (force_dir) && to_dir (force_dir))
+    p->set_grob_property ("direction", force_dir);
 
-      if (ly_dir_p (force_dir) && to_dir (force_dir))
-       p->set_grob_property ("direction", force_dir);
-      else if (to_dir (relative_stem_dir))
-       p->set_grob_property ("side-relative-direction", relative_stem_dir);
+  copy_property (p, ly_symbol2scm ("script-molecule"), art);
+  copy_property (p, ly_symbol2scm ("direction"), art);
+  copy_property (p, ly_symbol2scm ("side-relative-direction"), art);
 
+  int prio =0;
+  SCM sprio = scm_assoc (ly_symbol2scm ("script-priority"), art);
+  if (gh_pair_p (sprio))
+    prio = gh_scm2int (gh_cdr (sprio));
 
-      Side_position_interface::set_axis (p, Y_AXIS);
-      p->set_grob_property ("script-priority", gh_int2scm (priority));
 
-      
-      announce_grob (p, l->self_scm());
+  /*
+    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;
+
+  Side_position_interface::set_axis (p, Y_AXIS);
+  p->set_grob_property ("script-priority", gh_int2scm (prio));
+  return p;
+}
+
+void
+Script_engraver::process_music ()
+{
+  for (int i=0; i < scripts_.size (); i++)
+    {
+      Music* l=scripts_[i].event_;
+
+      Grob * p = make_script_from_event (&scripts_[i].description_, daddy_trans_, l, i);
+
+      scripts_[i].script_ = p;
+      if (p)
+       announce_grob (p, l->self_scm());
     }
 }
 
@@ -132,7 +146,12 @@ Script_engraver::acknowledge_grob (Grob_info inf)
        {
          Grob*e = scripts_[i].script_;
 
-         e->set_grob_property ("direction-source", inf.grob_->self_scm ());
+         if (to_dir (e->get_grob_property ("side-relative-direction")))
+           e->set_grob_property ("direction-source", inf.grob_->self_scm ());
+
+         /*
+           add dep ? 
+          */
          e->add_dependency (inf.grob_);
          Side_position_interface::add_support (e, inf.grob_);
        }
@@ -185,8 +204,10 @@ Script_engraver::stop_translation_timestep ()
        continue;
       
       Grob * sc = scripts_[i].script_;
-      if (to_boolean (gh_cadr (scripts_[i].description_)))
-       sc->add_offset_callback (Side_position_interface::quantised_position_proc, Y_AXIS);
+
+      SCM follow = scm_assoc (ly_symbol2scm ("follow-into-staff"), scripts_[i].description_);
+      if (gh_pair_p (follow) && to_boolean (gh_cdr (follow)))
+       sc->add_offset_callback (Side_position_interface::quntised_position_proc, Y_AXIS);
       else
        Side_position_interface::add_staff_support (sc);
       typeset_grob (sc);
index 058f03aefd65eecec43db595e6f38e4841a47ad9..1f58ab119c01a00893cc3bb08c51a89a9336c4f3 100644 (file)
-;; (name . '((downindexstring . upindexstring)
-;;           follow-into-staff :: bool
-;;           dir-relative-to-stem :: int
-;;           force-dir :: int
-
-
-;;           priority :: int -- lower number means closer to the  note head. 
-
-;; TODO: generate Grob types for this, by prepending appropriate props
-;; on top of Script (?)  
-
-
-;; TODO: don't use 2 level indiriection, simply set
-;; thumb = \script #'((feta . ( . .. ) (follow-staff .  #f))
-
 
 (set! default-script-alist
       (append 
-      '(("thumb" . ((feta . ("thumb"  . "thumb")) #f 0 1 0))
-       ("accent" . ((feta . ("sforzato" .  "sforzato")) #f -1 0 0))
-       ("marcato" . ((feta . ("dmarcato" . "umarcato")) #f -1 0  0))
-       ("staccatissimo" . ((feta . ("dstaccatissimo" . "ustaccatissimo")) #f  -1 0 0))
-       ("portato" . ((feta . ("dportato" . "uportato")) #f -1 0 0))
-       ("fermata" . ((feta . ("dfermata" . "ufermata")) #f 0 1 0))
-       ("stopped" . ((feta . ("stopped" . "stopped")) #f 0 1 0))
-       ("staccato" . ((feta . ("staccato" . "staccato")) #t -1 0 -100))
-       ("tenuto" . ((feta . ("tenuto" . "tenuto")) #t -1 0 0))
-       ("comma" . ((feta . ("lcomma" . "rcomma")) #t 0 1 0))
-       ("upbow" . ((feta . ("upbow" . "upbow")) #f 0 1 0))
-       ("downbow" . ((feta . ("downbow" . "downbow")) #f 0 1 0))
-       ("lheel" . ((feta . ("upedalheel" . "upedalheel")) #f 0 -1  0))
-       ("rheel" . ((feta . ("dpedalheel" . "dpedalheel")) #f 0 1 0))
-       ("ltoe" . ((feta . ("upedaltoe" . "upedaltoe")) #f 0 -1 0))
-       ("rtoe" . ((feta . ("dpedaltoe" . "dpedaltoe")) #f 0 1 0))
-       ("turn" . ((feta . ("turn" . "turn")) #f 0 1 0))
-       ("open" . ((feta . ("open" . "open")) #f 0 1 0))
-       ("flageolet" . ((feta . ("flageolet" . "flageolet")) #f 0 1 0))
-       ("reverseturn" . ((feta . ("reverseturn" . "reverseturn")) #f 0 1 0))
-       ("trill" . ((feta . ("trill" . "trill")) #f 0 1 2000))
-       ("prall" . ((feta . ("prall" . "prall")) #f 0 1 0))
-       ("mordent" . ((feta . ("mordent" . "mordent")) #f 0 1 0))
-       ("prallprall" . ((feta . ("prallprall" . "prallprall")) #f 0 1 0))
-       ("prallmordent" . ((feta . ("prallmordent" . "prallmordent")) #f 0 1 0))
-       ("upprall" . ((feta . ("upprall" . "upprall")) #f 0 1 0))
-       ("downprall" . ((feta . ("downprall" . "downprall")) #f 0 1 0))
-       ("upmordent" . ((feta . ("upmordent" . "upmordent")) #f 0 1 0))
-       ("downmordent" . ((feta . ("downmordent" . "downmordent")) #f 0 1 0))
-       ("lineprall" . ((feta . ("lineprall" . "lineprall")) #f 0 1 0))
-       ("pralldown" . ((feta . ("pralldown" . "pralldown")) #f 0 1 0))
-       ("prallup" . ((feta . ("prallup" . "prallup")) #f 0 1 0))
-       ("segno" . ((feta . ("segno" . "segno")) #f 0 1 0))
-       ("coda" . ((feta . ("coda" . "coda")) #f 0 1 0)))
-      default-script-alist)
-      )
+       '(("thumb" .
+         (
+          (script-molecule . (feta . ("thumb"  . "thumb")))
+          (direction . 1)))
+        ("accent" .
+         (
+          (script-molecule . (feta . ("sforzato" .  "sforzato")))
+          (side-relative-direction . -1))
+         )      
+        ("marcato" .
+         (
+          (script-molecule . (feta . ("dmarcato" . "umarcato")))
+          (side-relative-direction .  -1)))
+        ("staccatissimo" .
+         (
+          (script-molecule . (feta . ("dstaccatissimo" . "ustaccatissimo")))
+          (side-relative-direction .  -1)))
+        
+        ("portato" .
+         ((script-molecule . (feta . ("dportato" . "uportato")))
+          (side-relative-direction . -1)))
 
-(set! default-script-alist
-      (append 
-      '(("accDiscant" . ((accordion "Discant" "") #f 0 1 0))
-       ("accDiscantF" . ((accordion "Discant" "F") #f 0 1 0))
-       ("accDiscantE" . ((accordion "Discant" "E") #f 0 1 0))
-       ("accDiscantEh" . ((accordion "Discant" "Eh") #f 0 1 0))
-       ("accDiscantFE" . ((accordion "Discant" "FE") #f 0 1 0))
-       ("accDiscantFEh" . ((accordion "Discant" "FEh") #f 0 1 0))
-       ("accDiscantEE" . ((accordion "Discant" "EE") #f 0 1 0))
-       ("accDiscantFEE" . ((accordion "Discant" "FEE") #f 0 1 0))
-       ("accDiscantEEE" . ((accordion "Discant" "EEE") #f 0 1 0))
-       ("accDiscantFEEE" . ((accordion "Discant" "FEEE") #f 0 1 0))
-       ("accDiscantS" . ((accordion "Discant" "S") #f 0 1 0))
-       ("accDiscantFS" . ((accordion "Discant" "FS") #f 0 1 0))
-       ("accDiscantES" . ((accordion "Discant" "ES") #f 0 1 0))
-       ("accDiscantEhS" . ((accordion "Discant" "EhS") #f 0 1 0))
-       ("accDiscantFES" . ((accordion "Discant" "FES") #f 0 1 0))
-       ("accDiscantFEhS" . ((accordion "Discant" "FEhS") #f 0 1 0))
-       ("accDiscantEES" . ((accordion "Discant" "EES") #f 0 1 0))
-       ("accDiscantFEES" . ((accordion "Discant" "FEES") #f 0 1 0))
-       ("accDiscantEEES" . ((accordion "Discant" "EEES") #f 0 1 0))
-       ("accDiscantFEEES" . ((accordion "Discant" "FEEES") #f 0 1 0))
-       ("accDiscantSS" . ((accordion "Discant" "SS") #f 0 1 0))
-       ("accDiscantESS" . ((accordion "Discant" "ESS") #f 0 1 0))
-       ("accDiscantEESS" . ((accordion "Discant" "EESS") #f 0 1 0))
-       ("accDiscantEEESS" . ((accordion "Discant" "EEESS") #f 0 1 0))
-       ("accFreebase" . ((accordion "Freebase" "") #f 0 -1 0))
-       ("accFreebaseF" . ((accordion "Freebase" "F") #f 0 -1 0))
-       ("accFreebaseE" . ((accordion "Freebase" "E") #f 0 -1 0))
-       ("accFreebaseFE" . ((accordion "Freebase" "FE") #f 0 -1 0))
-       ("accBayanbase" . ((accordion "Bayanbase" "") #f 0 -1 0))
-       ("accBayanbaseT" . ((accordion "Bayanbase" "T") #f 0 -1 0))
-       ("accBayanbaseE" . ((accordion "Bayanbase" "E") #f 0 -1 0))
-       ("accBayanbaseTE" . ((accordion "Bayanbase" "TE") #f 0 -1 0))
-       ("accBayanbaseEE" . ((accordion "Bayanbase" "EE") #f 0 -1 0))
-       ("accBayanbaseTEE" . ((accordion "Bayanbase" "TEE") #f 0 -1 0))
-       ("accStdbase" . ((accordion "Stdbase" "") #f 0 -1 0))
-       ("accStdbaseFE" . ((accordion "Stdbase" "FE") #f 0 -1 0))
-       ("accStdbaseTFE" . ((accordion "Stdbase" "TFE") #f 0 -1 0))
-       ("accStdbaseMES" . ((accordion "Stdbase" "MES") #f 0 -1 0))
-       ("accStdbaseTFMES" . ((accordion "Stdbase" "TFMES") #f 0 -1 0))
-       ("accSB" . ((accordion "SB" "") #f 0 -1 0))
-       ("accBB" . ((accordion "BB" "") #f 0 -1 0))
-       ("accOldEE" . ((accordion "OldEE" "") #f 0 -1 0))
-       ("accOldEES" . ((accordion "OldEES" "") #f 0 -1 0)))
-      default-script-alist)
+        ("fermata" .
+         ((script-molecule . (feta . ("dfermata" . "ufermata")))
+          (direction .  1)))
+        ("stopped" .
+         ((script-molecule . (feta . ("stopped" . "stopped")))
+          (direction  . 1) ))
+        ("staccato" .
+         ((script-molecule . (feta . ("staccato" . "staccato")))
+          (side-relative-direction .  -1)
+          (follow-into-staff  . #t)
+          (priority . -100)))
+        ("tenuto" .
+         ((script-molecule . (feta . ("tenuto" . "tenuto")))
+          (follow-into-staff . #t)
+          (side-relative-direction . -1)))
+        ("comma" .
+         ((script-molecule . (feta . ("lcomma" . "rcomma")))
+          (follow-into-staff . #t)
+          (direction . 1)))
+        ("upbow" .
+         ((script-molecule . (feta . ("upbow" . "upbow")))
+          (direction  . 1) ))
+        ("downbow" .
+         ((script-molecule . (feta . ("downbow" . "downbow")))
+          (direction  . 1) ))
+        ("lheel" .
+         ((script-molecule . (feta . ("upedalheel" . "upedalheel")))
+          (direction .  -1))
+        ("rheel" .
+         ((script-molecule . (feta . ("dpedalheel" . "dpedalheel")))
+          (direction  . 1) ))
+        ("ltoe" .
+         ((script-molecule . (feta . ("upedaltoe" . "upedaltoe")))
+          (direction  . -1) ))
+        ("rtoe" .
+         ((script-molecule . (feta . ("dpedaltoe" . "dpedaltoe")))
+          (direction  . 1) ))
+        ("turn" .
+         ((script-molecule . (feta . ("turn" . "turn")))
+          (direction  . 1) ))
+        ("open" .
+         ((script-molecule . (feta . ("open" . "open")))
+          (direction  . 1) ))
+        ("flageolet" .
+         ((script-molecule . (feta . ("flageolet" . "flageolet")))
+          (direction  . 1) ))
+        ("reverseturn" .
+         ((script-molecule . (feta . ("reverseturn" . "reverseturn")))
+          (direction  . 1) ))
+        ("trill" .
+         ((script-molecule . (feta . ("trill" . "trill")))
+          (direction . 1)
+          (priority . 2000)))
+        ("prall" .
+         ((script-molecule . (feta . ("prall" . "prall")))
+          (direction  . 1) ))
+        ("mordent" .
+         ((script-molecule . (feta . ("mordent" . "mordent")))
+          (direction  . 1) ))
+        ("prallprall" .
+         ((script-molecule . (feta . ("prallprall" . "prallprall")))
+          (direction  . 1) ))
+        ("prallmordent" .
+         ((script-molecule . (feta . ("prallmordent" . "prallmordent")))
+          (direction  . 1) ))
+        ("upprall" .
+         ((script-molecule . (feta . ("upprall" . "upprall")))
+          (direction  . 1) ))
+        ("downprall" .
+         ((script-molecule . (feta . ("downprall" . "downprall")))
+          (direction  . 1) ))
+        ("upmordent" .
+         ((script-molecule . (feta . ("upmordent" . "upmordent")))
+          (direction  . 1) ))
+        ("downmordent" .
+         ((script-molecule . (feta . ("downmordent" . "downmordent")))
+          (direction  . 1) ))
+        ("lineprall" .
+         ((script-molecule . (feta . ("lineprall" . "lineprall")))
+          (direction  . 1) ))
+        ("pralldown" .
+         ((script-molecule . (feta . ("pralldown" . "pralldown")))
+          (direction  . 1) ))
+        ("prallup" .
+         ((script-molecule . (feta . ("prallup" . "prallup")))
+          (direction  . 1) ))
+        ("segno" .
+         ((script-molecule . (feta . ("segno" . "segno")))
+          (direction  . 1) ))
+        ("coda" .
+         ((script-molecule . (feta . ("coda" . "coda")))
+          (direction  . 1) )))
+       default-script-alist)
       )
-
-