]> git.donarmstrong.com Git - lilypond.git/commitdiff
(spanned_rank_iv): Bugfix.
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 13 Aug 2004 20:14:02 +0000 (20:14 +0000)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 13 Aug 2004 20:14:02 +0000 (20:14 +0000)
ChangeLog
flower/include/interval.tcc
lily/chord-name.cc
lily/dynamic-engraver.cc
lily/script-engraver.cc
lily/slur-engraver.cc
lily/spanner.cc

index 488fa46b0e5d597bbc667725fc86ea65a58b5102..6d1cc98b0f5825185ab222347365402c046f151a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2004-08-13  Jan Nieuwenhuizen  <janneke@gnu.org>
 
+       * lily/spanner.cc (spanned_rank_iv): Bugfix.
+
        * lily.scm: Mark un-internationlised user messages (with FIXME).
 
        * lily/include/modified-font-metric.hh (struct
index 4284ac2bdff50afefdb0db628cf6d1f9cc5e5806..afa4e9cf9a0c6f5a470072fc3312eadb4d368b7c 100644 (file)
@@ -32,12 +32,11 @@ _Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
   return -2;
 }
 
-
 template<class T>
 bool 
 Interval_t<T>::superset (Interval_t<T> const& a) const
 {
-  int c_i= _Interval__compare (*this, a);
+  int c_i = _Interval__compare (*this, a);
   if (c_i == -2)
     return false;
   return c_i >= 0;
@@ -45,7 +44,7 @@ Interval_t<T>::superset (Interval_t<T> const& a) const
 
 template<class T>
 int
-Interval__compare (const Interval_t<T>&a,Interval_t<T> const&b)
+Interval__compare (Interval_t<T> const& a,Interval_t<T> const& b)
 {
   int i = _Interval__compare (a,b);
   if (i < -1)
@@ -108,6 +107,7 @@ Interval_t<T>::intersect (Interval_t<T> h)
 #endif
 }
 
+#if 0 //this is called intersection
 template<class T>
 Interval_t<T>
 intersect (Interval_t<T> x, Interval_t<T> const &y)
@@ -115,6 +115,7 @@ intersect (Interval_t<T> x, Interval_t<T> const &y)
   x.intersect (y);
   return x;
 }
+#endif
 
 template<class T>
 String
index ce7099fa7df743120d68a87eb5a432c5060484e8..b7c019e3220ca319780408395ae50c044e91f08f 100644 (file)
@@ -16,7 +16,7 @@
 #include "staff-symbol-referencer.hh"
 #include "text-item.hh"
 
-MAKE_SCHEME_CALLBACK (Chord_name,after_line_breaking,1);
+MAKE_SCHEME_CALLBACK (Chord_name, after_line_breaking, 1);
 SCM
 Chord_name::after_line_breaking (SCM smob)
 {
@@ -33,8 +33,6 @@ Chord_name::after_line_breaking (SCM smob)
   return SCM_UNSPECIFIED;
 }
 
-
 ADD_INTERFACE (Chord_name, "chord-name-interface",
   "A chord name.",
   "begin-of-line-visible");
-
index 95e2c7df2997a5f7d3dc390b621bfb8d53777800..76dc123384b75fca2f8a6a088bdb1dae986efb1d 100644 (file)
@@ -14,6 +14,7 @@
 #include "event.hh"
 #include "group-interface.hh"
 #include "hairpin.hh"
+#include "interval.hh"
 #include "item.hh"
 #include "new-slur.hh"
 #include "note-column.hh"
@@ -44,7 +45,7 @@ class Dynamic_engraver : public Engraver
 {
   Item *script_;
   Spanner *line_spanner_;
-  Grob *slur_;
+  Spanner *slur_;
   Spanner *cresc_;
 
   Spanner *finished_line_spanner_;
@@ -89,7 +90,7 @@ Dynamic_engraver::Dynamic_engraver ()
 }
 
 bool
-Dynamic_engraver::try_music (Music * m)
+Dynamic_engraver::try_music (Music *m)
 {
   if (m->is_mus_type ("absolute-dynamic-event"))
     {
@@ -277,7 +278,6 @@ Dynamic_engraver::stop_translation_timestep ()
       finished_line_spanner_ = line_spanner_;
       line_spanner_ = 0;
       typeset_all ();
-      slur_ = 0;
     }
 
   script_ev_ = 0;
@@ -320,11 +320,15 @@ Dynamic_engraver::typeset_all ()
 
      which are unacceptable, but it most probably breaks for more
      interesting cases.  Maybe make a new colission engraver.  */
-  if (finished_line_spanner_ && slur_
-      && get_slur_dir (slur_) == get_grob_direction (finished_line_spanner_))
+  if (finished_line_spanner_
+      && slur_
+      && get_slur_dir (slur_) == get_grob_direction (finished_line_spanner_)
+      && !intersection (slur_->spanned_rank_iv (),
+                       finished_line_spanner_->spanned_rank_iv ()).is_empty ())
     {
       Real ss = Staff_symbol_referencer::staff_space (finished_line_spanner_);
-      Real pad = robust_scm2double (finished_line_spanner_->get_property ("padding"), 0);
+      Real pad = robust_scm2double (finished_line_spanner_
+                                   ->get_property ("padding"), 0);
       /* FIXME: 1ss padding hardcoded */
       finished_line_spanner_->set_property ("padding",
                                            scm_make_real (pad + ss));
@@ -382,31 +386,31 @@ Dynamic_engraver::typeset_all ()
 }
 
 void
-Dynamic_engraver::acknowledge_grob (Grob_info i)
+Dynamic_engraver::acknowledge_grob (Grob_info info)
 {
   if (!line_spanner_)
     return;
 
-  if (Note_column::has_interface (i.grob_))
+  if (Note_column::has_interface (info.grob_))
     {
       if (line_spanner_
          /* Don't refill killed spanner */
          && line_spanner_->is_live ())
        {
-         Side_position_interface::add_support (line_spanner_,i.grob_);
-         add_bound_item (line_spanner_,dynamic_cast<Item*> (i.grob_));
+         Side_position_interface::add_support (line_spanner_,info.grob_);
+         add_bound_item (line_spanner_,dynamic_cast<Item*> (info.grob_));
        }
 
       if (script_ && !script_->get_parent (X_AXIS))
        {
-         SCM head = scm_last_pair (i.grob_->get_property ("note-heads"));
+         SCM head = scm_last_pair (info.grob_->get_property ("note-heads"));
          if (ly_c_pair_p (head))
            script_->set_parent (unsmob_grob (ly_car (head)),  X_AXIS);
        }
     }
-  else if (Script_interface::has_interface (i.grob_) && script_)
+  else if (Script_interface::has_interface (info.grob_) && script_)
     {
-      SCM p = i.grob_->get_property ("script-priority");
+      SCM p = info.grob_->get_property ("script-priority");
 
       /*
        UGH.
@@ -416,10 +420,10 @@ Dynamic_engraver::acknowledge_grob (Grob_info i)
       if (ly_c_number_p (p)
          && ly_scm2int (p)
          < ly_scm2int (script_->get_property ("script-priority")))
-       Side_position_interface::add_support (line_spanner_, i.grob_);
+       Side_position_interface::add_support (line_spanner_, info.grob_);
     }
-  else if (New_slur::has_interface (i.grob_) && line_spanner_)
-    slur_ = i.grob_;
+  else if (New_slur::has_interface (info.grob_))
+    slur_ = dynamic_cast<Spanner*> (info.grob_);
 }
 
 ENTER_DESCRIPTION (Dynamic_engraver,
index 45fbb9d71c1839aff1820081b8cb925b40ba14a8..b8e93c6cd00aa193a509acd7264e12f9e623fa3a 100644 (file)
@@ -12,6 +12,7 @@
 #include "event.hh"
 #include "new-slur.hh"
 #include "note-column.hh"
+#include "paper-column.hh"
 #include "rhythmic-head.hh"
 #include "script-interface.hh"
 #include "side-position-interface.hh"
@@ -35,7 +36,7 @@ struct Script_tuple
 class Script_engraver : public Engraver
 {
   Array<Script_tuple> scripts_;
-  Grob *slur_;
+  Spanner *slur_;
 
 protected:
   virtual bool try_music (Music*);
@@ -53,20 +54,20 @@ Script_engraver::Script_engraver ()
 }
 
 bool
-Script_engraver::try_music (Music *r)
+Script_engraver::try_music (Music *m)
 {
-  if (r->is_mus_type ("articulation-event"))
+  if (m->is_mus_type ("articulation-event"))
     {
       /* Discard double articulations for part-combining.  */
       int script_count = scripts_.size ();
       for (int i = 0; i < script_count; i++)
        if (ly_c_equal_p (scripts_[i].event_
                          ->get_property ("articulation-type"),
-                         r->get_property ("articulation-type")))
+                         m->get_property ("articulation-type")))
          return true;
 
       Script_tuple t;
-      t.event_ = r;
+      t.event_ = m;
       scripts_.push (t);
       return true;
     }
@@ -146,24 +147,24 @@ Script_engraver::process_music ()
 }
 
 void
-Script_engraver::acknowledge_grob (Grob_info inf)
+Script_engraver::acknowledge_grob (Grob_info info)
 {
   int script_count = scripts_.size ();
-  if (Stem::has_interface (inf.grob_))
+  if (Stem::has_interface (info.grob_))
     {
       for (int i = 0; i < script_count; i++)
        {
          Grob *e = scripts_[i].script_;
 
          if (to_dir (e->get_property ("side-relative-direction")))
-           e->set_property ("direction-source", inf.grob_->self_scm ());
+           e->set_property ("direction-source", info.grob_->self_scm ());
 
          /* FIXME: add dependency */
-         e->add_dependency (inf.grob_);
-         Side_position_interface::add_support (e, inf.grob_);
+         e->add_dependency (info.grob_);
+         Side_position_interface::add_support (e, info.grob_);
        }
     }
-  else if (Rhythmic_head::has_interface (inf.grob_))
+  else if (Rhythmic_head::has_interface (info.grob_))
     {
       for (int i = 0; i < script_count; i++)
        {
@@ -172,13 +173,13 @@ Script_engraver::acknowledge_grob (Grob_info inf)
          if (Side_position_interface::get_axis (e) == X_AXIS
              && !e->get_parent (Y_AXIS))
            {
-             e->set_parent (inf.grob_, Y_AXIS);
-             e->add_dependency (inf.grob_); // ??
+             e->set_parent (info.grob_, Y_AXIS);
+             e->add_dependency (info.grob_);
            }
-         Side_position_interface::add_support (e,inf.grob_);
+         Side_position_interface::add_support (e,info.grob_);
        }
     }
-  else if (Note_column::has_interface (inf.grob_))
+  else if (Note_column::has_interface (info.grob_))
     {
       /* Make note column the parent of the script.  That is not
        correct, but due to seconds in a chord, noteheads may be
@@ -192,11 +193,11 @@ Script_engraver::acknowledge_grob (Grob_info inf)
 
          if (!e->get_parent (X_AXIS)
              && Side_position_interface::get_axis (e) == Y_AXIS)
-           e->set_parent (inf.grob_, X_AXIS);
+           e->set_parent (info.grob_, X_AXIS);
        }
     }
-  else if (New_slur::has_interface (inf.grob_) && script_count)
-    slur_ = inf.grob_;
+  else if (New_slur::has_interface (info.grob_))
+    slur_ = dynamic_cast<Spanner*> (info.grob_);
 }
 
 void
@@ -227,9 +228,35 @@ Script_engraver::stop_translation_timestep ()
           Assume that a SCRIPT that should collide with SLUR does not
           have a negative priority. */
        SCM priority = sc->get_property ("script-priority");
+
+#if 0
+       // this segfaults...
+       int rank = Paper_column::get_rank (sc);
+#endif
+       
+       int rank = -1;
+#if 1
+       // this always yields -1
+       if (Item *i = dynamic_cast<Item*> (sc))
+         if (i->get_column ())
+           rank = i->get_column ()->rank_;
+#else
+       // this always yields -1
+       for (Grob *p = sc; p && rank < 0; p = p->get_parent (Y_AXIS))
+         {
+           if (Item *i = dynamic_cast<Item*> (p))
+             if (i->get_column ())
+               rank = i->get_column ()->rank_;
+         }
+#endif
+
        if (robust_scm2int (priority, 0) >= 0
            && slur_
-           && get_grob_direction (sc) == get_slur_dir (slur_))
+           && get_grob_direction (sc) == get_slur_dir (slur_)
+           && (slur_->spanned_rank_iv ().contains (rank)
+               /* I'm a bit out of ideas about and time to search for
+                  how to get our rank.  Sue me.  */
+               || rank == -1))
          {
            Real ss = Staff_symbol_referencer::staff_space (sc);
            Real pad = robust_scm2double (sc->get_property ("padding"), 0);
@@ -238,7 +265,6 @@ Script_engraver::stop_translation_timestep ()
            sc->set_property ("padding", scm_make_real (pad + ss));
          }
       }
-  slur_ = 0;
   scripts_.clear ();
 }
 
index 695bfb505d7b17eb5ce6eff999fe056a0e1ab6cf..a8cbd27598374b78a5b465387bb59809fd2f5650 100644 (file)
@@ -43,19 +43,19 @@ Slur_engraver::Slur_engraver ()
 }
 
 bool
-Slur_engraver::try_music (Music *ev)
+Slur_engraver::try_music (Music *m)
 {
-  if (ev->is_mus_type ("slur-event"))
+  if (m->is_mus_type ("slur-event"))
     {
       /*
        Let's not start more than one slur per moment.
       */
-      Direction d = to_dir (ev->get_property ("span-direction"));
+      Direction d = to_dir (m->get_property ("span-direction"));
       if (d == START)
        {
          if (now_mom () > last_start_)
            {
-             new_slur_evs_.push (ev);
+             new_slur_evs_.push (m);
              last_start_ = now_mom ();
            }
 
@@ -78,7 +78,7 @@ Slur_engraver::try_music (Music *ev)
                return true;
            }
              
-         new_slur_evs_.push (ev);
+         new_slur_evs_.push (m);
          return true;
        }
     }
index 69ed46231cda14c17bdaea4c96df82a980ff11f7..058cc2f0ba4bd0fe19cb910737c1e917a1a0c236 100644 (file)
@@ -124,7 +124,7 @@ Spanner::do_break_processing ()
 }
 
 int
-Spanner::get_break_index ()const
+Spanner::get_break_index () const
 {
   return break_index_;
 }
@@ -146,14 +146,10 @@ Spanner::spanned_rank_iv ()
 {
   Interval_t<int> iv (0, 0);
 
-  if (spanned_drul_[LEFT])
-    {
-      iv[LEFT] = Paper_column::get_rank (spanned_drul_[LEFT]->get_column ());
-    }
-  if (spanned_drul_[RIGHT])
-    {
-      iv[RIGHT] = Paper_column::get_rank (spanned_drul_[RIGHT]->get_column ());
-    }
+  if (spanned_drul_[LEFT] && spanned_drul_[LEFT]->get_column ())
+    iv[LEFT] = Paper_column::get_rank (spanned_drul_[LEFT]->get_column ());
+  if (spanned_drul_[RIGHT] && spanned_drul_[RIGHT]->get_column ())
+    iv[RIGHT] = Paper_column::get_rank (spanned_drul_[RIGHT]->get_column ());
   return iv;
 }