]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/stem-engraver.cc
release: 1.3.0
[lilypond.git] / lily / stem-engraver.cc
index 44e991908a9e3ddbd8654a1ed7c367f650358070..d48fa3925f3f0db14beaafa23a510d69a3780219 100644 (file)
@@ -12,7 +12,7 @@
 #include "musical-request.hh"
 #include "duration-convert.hh"
 #include "misc.hh"
-#include "abbrev.hh"
+#include "stem-tremolo.hh"
 #include "staff-info.hh"
 #include "translator-group.hh"
 
@@ -22,30 +22,33 @@ Stem_engraver::Stem_engraver()
   stem_p_ = 0;
   abbrev_p_ = 0;
   default_abbrev_i_ = 16;
+  rhythmic_req_l_ =0;
 }
 
 void
 Stem_engraver::do_creation_processing ()
 {
-  Scalar prop = get_property ("abbrev", 0);
-  if (prop.isnum_b ()) 
+  SCM prop = get_property ("abbrev", 0);
+  if (SCM_NUMBERP(prop)) 
     {
-      default_abbrev_i_  = prop;
+      default_abbrev_i_  = gh_scm2int (prop);
     }
 }
 
 void
 Stem_engraver::acknowledge_element(Score_element_info i)
 {
-  if (dynamic_cast<Rhythmic_head *> (i.elem_l_))
+  if (Rhythmic_head * h = dynamic_cast<Rhythmic_head *> (i.elem_l_))
     {
-      Rhythmic_head *h  = dynamic_cast<Rhythmic_head *> (i.elem_l_);
+      if (h->stem_l_)
+       return;
+      
+      Rhythmic_req * r = dynamic_cast <Rhythmic_req *> (i.req_l_);
+      int duration_log = r->duration_.durlog_i_;      
       if (!stem_p_) 
        {
-         Rhythmic_req * r = dynamic_cast <Rhythmic_req *> (i.req_l_);
          stem_p_ = new Stem;
-         int durlog_i = r->duration_.durlog_i_;
-         stem_p_->flag_i_ = durlog_i;
+         stem_p_->flag_i_ = duration_log;
 
          if (abbrev_req_l_)
            {
@@ -62,15 +65,21 @@ Stem_engraver::acknowledge_element(Score_element_info i)
 
              if (t)
                {
-                 abbrev_p_ = new Abbreviation;
+                 abbrev_p_ = new Stem_tremolo;
                  announce_element (Score_element_info (abbrev_p_, abbrev_req_l_));
-                 abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (durlog_i>? 2);
+                 abbrev_p_->abbrev_flags_i_ =intlog2 (t) - (duration_log>? 2);
                }
            }
 
          // must give the request, to preserve the rhythmic info.
          announce_element (Score_element_info (stem_p_, r));
        }
+
+      if (stem_p_->flag_i_ != duration_log)
+       {
+         r->warning (_f ("Adding note head to incompatible stem (type = %d)", 1 <<  stem_p_->flag_i_));
+       }
+
       stem_p_->add_head (h);
     }
 }
@@ -87,28 +96,45 @@ Stem_engraver::do_pre_move_processing()
 
   if (stem_p_)
     {
-      Scalar prop = get_property ("ydirection", 0);
-      Direction dir = prop.isnum_b () ? (Direction)int(prop) : CENTER;
-      if (dir)
+      SCM prop = get_property ("verticalDirection", 0);
+      if (SCM_NUMBERP(prop))
        {
-         stem_p_->dir_ = dir;
+         stem_p_->dir_ = to_dir (prop);
          stem_p_->set_elt_property (dir_forced_scm_sym, SCM_BOOL_T);
        }
 
-      Translator_group const *which;
+      Translator_groupwhich;
       prop = get_property ("stemLeftBeamCount", &which);
-      if (prop.isnum_b ())
+      if (SCM_NUMBERP(prop))
        {
-         stem_p_->beams_i_drul_[LEFT] = prop;
-         ((Translator_group*)which)->set_property ("stemLeftBeamCount", "");
+         stem_p_->beams_i_drul_[LEFT] = gh_scm2int (prop);
+         ((Translator_group*)which)->set_property ("stemLeftBeamCount", SCM_UNDEFINED);
        }
       prop = get_property ("stemRightBeamCount", &which);
-      if (prop.isnum_b ())
+      if (SCM_NUMBERP(prop))
        {
-         stem_p_->beams_i_drul_[RIGHT] = prop;
-         ((Translator_group*)which)->set_property ("stemRightBeamCount", "");
+         stem_p_->beams_i_drul_[RIGHT] = gh_scm2int (prop);
+         ((Translator_group*)which)->set_property ("stemRightBeamCount", SCM_UNDEFINED);
        }
 
+      prop = get_property ("stemLength", 0);
+      if (SCM_NUMBERP(prop))
+       {
+         stem_p_->set_elt_property (length_scm_sym, prop);
+       }
+
+      prop = get_property ("stemStyle", 0);
+      if (gh_string_p (prop))
+       {
+         stem_p_->set_elt_property (style_scm_sym, prop);
+       }
+      
+      prop = get_property ("noStemExtend", 0);
+      if (gh_boolean_p (prop) && gh_scm2bool (prop))
+       {
+         stem_p_->set_elt_property (no_stem_extend_scm_sym, prop);
+       }
+      
       typeset_element(stem_p_);
       stem_p_ = 0;
     }
@@ -118,7 +144,7 @@ Stem_engraver::do_pre_move_processing()
 bool
 Stem_engraver::do_try_music (Music* r)
 {
-  if (Abbreviation_req* a = dynamic_cast <Abbreviation_req *> (r))
+  if (Tremolo_req* a = dynamic_cast <Tremolo_req *> (r))
     {
       abbrev_req_l_ = a;
       return true;