]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/text-spanner-engraver.cc
2003 -> 2004
[lilypond.git] / lily / text-spanner-engraver.cc
index e0d1c5f0a733fd230a443be0829402e8ed6516b4..29814d752b514c613e30814e35b536b1dba6ee4c 100644 (file)
@@ -3,21 +3,13 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
+  (c) 2000--2004 Jan Nieuwenhuizen <janneke@gnu.org>
 */
 
-#include "dimensions.hh"
-#include "musical-request.hh"
-#include "paper-column.hh"
 #include "note-column.hh"
 #include "item.hh"
 #include "side-position-interface.hh"
 #include "engraver.hh"
-#include "group-interface.hh"
-#include "directional-element-interface.hh"
-#include "translator-group.hh"
-#include "axis-group-interface.hh"
-
 
 class Text_spanner_engraver : public Engraver
 {
@@ -28,20 +20,17 @@ protected:
   virtual void acknowledge_grob (Grob_info);
   virtual bool try_music (Music *);
   virtual void stop_translation_timestep ();
-  virtual void start_translation_timestep ();
   virtual void process_music ();
 
 private:
   Spanner *span_;
   Spanner *finished_;
-  Span_req *current_req_;
-  Drul_array<Span_req*> req_drul_;
+  Music *current_req_;
+  Drul_array<Music*> req_drul_;
   void typeset_all ();
 };
 
 
-
-
 Text_spanner_engraver::Text_spanner_engraver ()
 {
   finished_ = 0;
@@ -51,33 +40,17 @@ Text_spanner_engraver::Text_spanner_engraver ()
   req_drul_[STOP] = 0;
 }
 
-void
-Text_spanner_engraver::start_translation_timestep ()
-{
-  req_drul_[START] = 0;
-  req_drul_[STOP] = 0;
-}
-
 bool
 Text_spanner_engraver::try_music (Music *m)
 {
-  if (Span_req *s =  dynamic_cast <Span_req*> (m))
+  if (m->is_mus_type ("text-span-event"))
     {
-      String t =  ly_scm2string (s->get_mus_property ("span-type"));            
-      if (t == "abort")
-       {
-         req_drul_[LEFT] = 0;
-         req_drul_[RIGHT] = 0;
-         if (span_)
-           span_->suicide ();
-         span_ = 0;
-       }
-      else if (t == "text")
-       {
-         req_drul_[s->get_span_dir ()] = s;
-         return true;
-       }
+
+      Direction d = to_dir (m->get_mus_property ("span-direction"));
+      req_drul_[d] = m;
+      return true;
     }
+
   return false;
 }
 
@@ -108,13 +81,9 @@ Text_spanner_engraver::process_music ()
       else
        {
          current_req_ = req_drul_[START];
-         span_  = new Spanner (get_property ("TextSpanner"));
+         span_  = make_spanner ("TextSpanner");
 
-         /* Ugh.  Reset (de)cresc. specific properties */
-         span_->set_grob_property ("outer", SCM_BOOL_T);
-         span_->set_grob_property ("if-text-padding", gh_double2scm (0));
-         span_->set_grob_property ("width-correct", gh_double2scm (0));
-                   
+         
          Side_position_interface::set_axis (span_, Y_AXIS);
          announce_grob (span_, req_drul_[START]->self_scm());
          req_drul_[START] = 0;
@@ -141,12 +110,10 @@ Text_spanner_engraver::typeset_all ()
 {  
   if (finished_)
     {
-      Side_position_interface::add_staff_support (finished_);
-
       if (!finished_->get_bound (RIGHT))
        {
          Grob* e = unsmob_grob (get_property ("currentMusicalColumn"));
-         span_->set_bound (RIGHT, e);
+         finished_->set_bound (RIGHT, e);
        }
       typeset_grob (finished_);
       finished_ = 0;
@@ -163,6 +130,8 @@ Text_spanner_engraver::stop_translation_timestep ()
     }
 
   typeset_all ();
+  req_drul_[START] = 0;
+  req_drul_[STOP] = 0;
 }
 
 void
@@ -178,8 +147,9 @@ Text_spanner_engraver::finalize ()
 }
 
 ENTER_DESCRIPTION(Text_spanner_engraver,
-/* descr */       "Create text spanner from a Span_req.",
+/* descr */       "Create text spanner from a Music.",
 /* creats*/       "TextSpanner",
-/* acks  */       "note-column-interface",
+/* accepts */     "text-span-event",
+/* acks  */      "note-column-interface",
 /* reads */       "",
 /* write */       "");