]> git.donarmstrong.com Git - lilypond.git/commitdiff
release: 1.3.70 release/1.3.70
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 5 Jul 2000 13:41:25 +0000 (15:41 +0200)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 5 Jul 2000 13:41:25 +0000 (15:41 +0200)
======

* Cleanup auto-beam-engraver: use properties for retrieving timing
information.

* Fixed: Multi measure rests don't cause crashes.

* Fixed: don't invoke Hara_kiri::consider_suicide too early.

* Fixed: property engraver.

* Fixed: don't crash on multiple ties.

* Cleanups of Beam, should also be a little faster.

* Reunite properties and pointers. In implementation we make a
distinction between mutable and immutable properties

* Add {has|set}_interface () static methods to interface classes.

* Made Side_position_interface and Staff_symbol_interface an all
statics class, and stripped _interface suffix.

* Make Align_interface and Axis_group_interface an all-statics class

* Rhythmic_head, Staff_symbol, Grace_align_item, Break_align_item,
Bar, Span_bar are now interfaces, Staff_bar was removed. Use a
callback for determining barsize.

* Removed all GLUE_SCORE_ELEMENT callbacks.

* Added test for repeats to trip.ly

1.3

84 files changed:
CHANGES
VERSION
buildscripts/ps-to-pfa.py
input/bugs/auto-beam.ly [new file with mode: 0644]
input/bugs/f.ly [new file with mode: 0644]
lily/align-note-column-engraver.cc
lily/all-font-metrics.cc
lily/auto-beam-engraver.cc
lily/axis-group-interface.cc
lily/beam-engraver.cc
lily/beam.cc
lily/break-algorithm.cc
lily/chord-tremolo-engraver.cc
lily/collision-engraver.cc
lily/collision.cc
lily/dynamic-engraver.cc
lily/gourlay-breaking.cc
lily/grace-align-item.cc
lily/include/beam.hh
lily/include/break-algorithm.hh
lily/include/collision.hh
lily/include/column-x-positions.hh
lily/include/item.hh
lily/include/line-of-score.hh
lily/include/multi-measure-rest.hh
lily/include/note-column.hh
lily/include/paper-column.hh
lily/include/rest-collision.hh
lily/include/rod.hh
lily/include/score-element.hh
lily/include/script.hh
lily/include/separating-group-spanner.hh
lily/include/simple-spacer.hh
lily/include/slur.hh
lily/include/spaceable-element.hh [new file with mode: 0644]
lily/include/spacing-engraver.hh [deleted file]
lily/include/spacing-spanner.hh
lily/include/spanner.hh
lily/include/stem.hh
lily/include/system-start-delimiter.hh
lily/include/tie-column.hh
lily/include/tie.hh
lily/instrument-name-engraver.cc
lily/item.cc
lily/line-of-score.cc
lily/main.cc
lily/multi-measure-rest-engraver.cc
lily/multi-measure-rest.cc
lily/note-column.cc
lily/paper-column.cc
lily/paper-score.cc
lily/rest-collision-engraver.cc
lily/rest-collision.cc
lily/rhythmic-column-engraver.cc
lily/rhythmic-head.cc
lily/rod.cc
lily/score-element.cc
lily/score-engraver.cc
lily/script-column-engraver.cc
lily/script-engraver.cc
lily/script.cc
lily/separating-group-spanner.cc
lily/separating-line-group-engraver.cc
lily/simple-spacer.cc
lily/slur-engraver.cc
lily/slur.cc
lily/spaceable-element.cc [new file with mode: 0644]
lily/spacing-engraver.cc
lily/spacing-spanner.cc
lily/spanner.cc
lily/spring.cc
lily/stem-engraver.cc
lily/stem-tremolo.cc
lily/stem.cc
lily/system-start-delimiter-engraver.cc
lily/system-start-delimiter.cc
lily/tie-column.cc
lily/tie-engraver.cc
lily/tie.cc
lily/tuplet-engraver.cc
lily/tuplet-spanner.cc
ly/engraver.ly
make/out/lilypond.lsm
make/out/lilypond.spec

diff --git a/CHANGES b/CHANGES
index 36ed28852a67630a50c974a4ddb67440eac37e49..fd106120c2edc571ece2db4f8ef5e35b7e1b2610 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,18 @@
-1.3.68.hwn1
-===========
+* Fixed: long standing problem in optical-illusion code.
+
+* Fixed: stop beam if stem *has* a beam in auto-beam-engraver. 
+
+* Made interface of Multi_measure_rest, System_start_delimiter,
+Spacing_spanner, Separating_group_spanner, Beam, Slur and
+Rhythmic_head.
+
+* Use properties for minimum distances and spring parameters.  Move
+spacing related functions from Paper_column into Spaceable_element.
+
+* Removed most Paper_column typecasts.
+
+1.3.69
+======
 
 * Cleanup auto-beam-engraver: use properties for retrieving timing
 information.
@@ -32,8 +45,6 @@ callback for determining barsize.
 
 * Added test for repeats to trip.ly
 
-* 
-
 1.3.68
 ======
 
diff --git a/VERSION b/VERSION
index 45f7a19dcfc68e0f0ae9d6c39ada4fe3811b4260..7da804129723ea48c53a6f66c346f762e7610ae5 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1,8 +1,8 @@
 PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=3
-PATCH_LEVEL=69
-MY_PATCH_LEVEL=cb1
+PATCH_LEVEL=70
+MY_PATCH_LEVEL=
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index 796c5d8b3770426b7dec2792e60d636da579fedf..ef3c94a291ba67ac1c42191d6ad56102911ca5c4 100755 (executable)
@@ -21,6 +21,8 @@ from string import *
 import re
 import time
 
+logfile = sys.stdout
+
 def program_id ():
     return name + ' version ' + version;
 
@@ -58,19 +60,19 @@ for opt in options:
 
 
 def gulp_file (f):
-       sys.stderr.write ('[%s' % f)
+       logfile.write ('[%s' % f)
        try:
                i = open (f)
                i.seek (0, 2)
                n = i.tell ()
                i.seek (0,0)
        except:
-               sys.stderr.write ('can\'t open file %s\n ' % f)
+               logfile.write ('can\'t open file %s\n ' % f)
                return ''
        s = i.read (n)
-       sys.stderr.write (']')
+       logfile.write (']')
        if len (s) <= 0:
-               sys.stderr.write ('gulped empty file: %s\n'% f)
+               logfile.write ('gulped empty file: %s\n'% f)
        return s
 
 mf = files[0]
@@ -81,7 +83,7 @@ if not output_name:
     output_name  = font_name + '.pfa'
 
 
-sys.stderr.write ('Font: %s\n'% font_name)
+logfile.write ('Font: %s\n'% font_name)
 
 def header (f):
        f.write ('%!PS-AdobeFont-3.0: ' + font_name + '\n')
@@ -125,7 +127,7 @@ end                                         % of font dictionary
 suspect_re = re.compile ('closepath ((gsave )*fill( grestore stroke)*) 1 setgray newpath (.*?) closepath fill')
 
 def characters (f):
-       sys.stderr.write ('[')
+       logfile.write ('[')
        
        files = []
        import find                     # q
@@ -179,14 +181,14 @@ def characters (f):
        f.write ('end                                         % of CharProcs\n')
        f.write (encoding)
        f.write ('\n')
-       sys.stderr.write (']')
+       logfile.write (']')
 
 
 ps_file = open (output_name, 'w')
 header (ps_file)
 characters (ps_file)
 footer (ps_file)
-sys.stderr.write ('\n')
+logfile.write ('\n')
 ps_file.close ()
-sys.stderr.write ('Wrote PostScript font: %s\n' % output_name)
+logfile.write ('Wrote PostScript font: %s\n' % output_name)
 
diff --git a/input/bugs/auto-beam.ly b/input/bugs/auto-beam.ly
new file mode 100644 (file)
index 0000000..5acc702
--- /dev/null
@@ -0,0 +1,6 @@
+% bug or feature?
+\score { \notes { c8 c8
+  % needed to force auto-beam:
+  % c4
+
+}}
diff --git a/input/bugs/f.ly b/input/bugs/f.ly
new file mode 100644 (file)
index 0000000..5acc702
--- /dev/null
@@ -0,0 +1,6 @@
+% bug or feature?
+\score { \notes { c8 c8
+  % needed to force auto-beam:
+  % c4
+
+}}
index cbe7a931f01da1b2312ba61aaf243cc71659176b..05a51c710b0fb1b2bdca95d123838b4d7ae9d0a8 100644 (file)
@@ -22,7 +22,7 @@
 class Align_note_column_engraver: public Engraver
 {
   Item * align_item_p_;
-  Note_column * now_column_l_;
+  Score_element * now_column_l_;
   Score_element * accidental_l_;
 
   virtual void process_acknowledged ();
@@ -71,9 +71,9 @@ Align_note_column_engraver::do_removal_processing ()
 void
 Align_note_column_engraver::acknowledge_element (Score_element_info inf)
 {
-  if (Note_column * n = dynamic_cast<Note_column*> (inf.elem_l_))
+  if (Note_column::has_interface(inf.elem_l_))
     {
-      now_column_l_ =n;
+      now_column_l_ =inf.elem_l_;
     }
   else if (Local_key_item::has_interface (inf.elem_l_))
     {
index f014ef3e46883bce1600badfa69e11467e8f7449..f8e2c0cee1ae37ed3c061af5ec6d3c97f769c445 100644 (file)
 #include "lily-guile.hh"
 #include "tfm-reader.hh"
 
-extern "C" {
-#include <kpathsea/kpathsea.h>
-}
-
 const char * default_font_sz_ = "cmr10";
 
 All_font_metrics::All_font_metrics (String path)
@@ -36,11 +32,8 @@ All_font_metrics::find_afm (String name)
       String path = name  + ".afm";
       path = search_path_.find (path);
       if (path.empty_b ())
-        { 
-         path = kpse_find_file(name.ch_C(), kpse_afm_format, true);
-         if (path.empty_b())
-           return 0;
-        }
+       return 0;
+
       if (verbose_global_b)
        progress_indication ("[" + path);
       Adobe_font_metric * afm_p = read_afm_file (path);
@@ -85,13 +78,8 @@ All_font_metrics::find_tfm (String name)
     {
       String path = name  + ".tfm";
       path = search_path_.find (path);
-      path = search_path_.find (path);
       if (path.empty_b ())
-        { 
-         path = kpse_find_tfm(name.ch_C());
-         if (path.empty_b())
-           return 0;
-        }
+       return 0;
       if (verbose_global_b)
        progress_indication ("[" + path);
       Tex_font_metric  * tfm_p = Tex_font_metric_reader::read_file (path);
index d912bb9585d17f8b6fe14b5a55cf1f2d0864ab44..316cc56f621593855cfd8049c3a30633c667020a 100644 (file)
@@ -16,6 +16,8 @@
 #include "bar.hh"
 #include "rest.hh"
 #include "engraver.hh"
+#include "item.hh"
+#include "spanner.hh"
 
 class Auto_beam_engraver : public Engraver
 {
@@ -34,14 +36,14 @@ protected:
 private:
   void begin_beam ();
   void consider_end_and_begin (Moment test_mom);
-  Beam* create_beam_p ();
+  Spanner* create_beam_p ();
   void end_beam ();
   void junk_beam ();
   bool same_grace_state_b (Score_element* e);
   void typeset_beam ();
 
   Moment shortest_mom_;
-  Beam *finished_beam_p_;
+  Spanner *finished_beam_p_;
   Link_array<Item>* stem_l_arr_p_;
   
   Moment last_add_mom_;
@@ -234,10 +236,11 @@ Auto_beam_engraver::begin_beam ()
   beam_start_location_ = *unsmob_moment (get_property ("measurePosition"));
 }
 
-Beam*
+Spanner*
 Auto_beam_engraver::create_beam_p ()
 {
-  Beam* beam_p = new Beam (get_property ("basicBeamProperties"));
+  Spanner* beam_p = new Spanner (get_property ("basicBeamProperties"));
+  Beam::set_interface (beam_p);
 
   for (int i = 0; i < stem_l_arr_p_->size (); i++)
     {
@@ -248,7 +251,7 @@ Auto_beam_engraver::create_beam_p ()
        {
          return 0;
        }
-      beam_p->add_stem ((*stem_l_arr_p_)[i]);
+      Beam::add_stem (beam_p,(*stem_l_arr_p_)[i]);
     }
   
   announce_element (Score_element_info (beam_p, 0));
@@ -281,7 +284,7 @@ Auto_beam_engraver::typeset_beam ()
   if (finished_beam_p_)
     {
       finished_grouping_p_->beamify ();
-      finished_beam_p_->set_beaming (finished_grouping_p_);
+      Beam::set_beaming (finished_beam_p_, finished_grouping_p_);
       typeset_element (finished_beam_p_);
       finished_beam_p_ = 0;
     
@@ -338,7 +341,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
   
   if (stem_l_arr_p_)
     {
-      if (Beam *b = dynamic_cast<Beam *> (info.elem_l_))
+      if (Beam::has_interface (info.elem_l_))
        {
          end_beam ();
        }
@@ -373,7 +376,7 @@ Auto_beam_engraver::acknowledge_element (Score_element_info info)
          return;
        }
 
-      if (!Stem::beam_l (stem_l))
+      if (Stem::beam_l (stem_l))
        {
          if (stem_l_arr_p_)
            junk_beam ();
index 12eac1632955ff20618b64087ab28cb7301af37e..3b144f624f1665d47b4d2ba18d7723b102c5df84 100644 (file)
@@ -125,6 +125,6 @@ Axis_group_interface::set_interface (Score_element*me)
   if (!has_interface (me))
     {
       me->set_interface (ly_symbol2scm ("axis-group-interface"));      
-      me->set_elt_property ("elements", SCM_EOL);
     }
+  me->set_elt_property ("elements", SCM_EOL);
 }
index dedbad0dd00c029c89254529ffed89b9b77fd6d7..1678dff784e836a482386ef3e6b60b5bbe13f4d9 100644 (file)
 #include "score-engraver.hh"
 #include "rest.hh"
 #include "drul-array.hh"
+#include "item.hh"
+#include "spanner.hh"
 
 class Beam_engraver : public Engraver
 {
   Drul_array<Span_req*> reqs_drul_;
 
-  Beam *finished_beam_p_;
-  Beam *beam_p_;
+  Spanner *finished_beam_p_;
+  Spanner *beam_p_;
   Span_req * prev_start_req_;
 
   Beaming_info_list * beam_info_p_;
@@ -120,8 +122,9 @@ Beam_engraver::do_process_music ()
        }
 
       prev_start_req_ = reqs_drul_[START];
-      beam_p_ = new Beam (get_property ("basicBeamProperties"));
-
+      beam_p_ = new Spanner (get_property ("basicBeamProperties"));
+      Beam::set_interface (beam_p_);
+      
       SCM smp = get_property ("measurePosition");
       Moment mp =  (unsmob_moment (smp)) ? *unsmob_moment (smp) : Moment (0);
 
@@ -143,7 +146,7 @@ Beam_engraver::typeset_beam ()
     {
       finished_beam_info_p_->beamify ();
       
-      finished_beam_p_->set_beaming (finished_beam_info_p_);
+      Beam::set_beaming (finished_beam_p_, finished_beam_info_p_);
       typeset_element (finished_beam_p_);
       delete finished_beam_info_p_;
       finished_beam_info_p_ =0;
@@ -229,7 +232,7 @@ Beam_engraver::acknowledge_element (Score_element_info info)
          Moment stem_location = now_mom () - beam_start_mom_ + beam_start_location_;
          beam_info_p_->add_stem (stem_location,
                                  (rhythmic_req->duration_.durlog_i_ - 2) >? 1);
-         beam_p_->add_stem (stem_l);
+         Beam::add_stem (beam_p_, stem_l);
        }
     }
 }
index 604c4d356bdb3a542718fe9e3b9ec52921183d16..9e59ec64851ef735e95d7ba00e2b0ae7ad2eab20 100644 (file)
 
 
 #include <math.h> // tanh.
+
+
 #include "directional-element-interface.hh"
 #include "beaming.hh"
-#include "dimensions.hh"
 #include "beam.hh"
 #include "misc.hh"
-#include "debug.hh"
 #include "least-squares.hh"
 #include "stem.hh"
 #include "paper-def.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
 #include "cross-staff.hh"
-
-Beam::Beam (SCM s)
-  : Spanner (s)
-{
-  Score_element*me =this;
-  
-  Pointer_group_interface g (me, "stems");
-  g.set_interface ();
-
-  set_elt_property ("height", gh_int2scm (0)); // ugh.
-  set_elt_property ("y-position" ,gh_int2scm (0));
-}
+#include "item.hh"
+#include "spanner.hh"
+#include "warn.hh"
 
 void
-Beam::add_stem (Score_element*s)
+Beam::add_stem (Score_element*me, Score_element*s)
 {
-    Score_element*me =this;
   Pointer_group_interface gi (me, "stems");
   gi.add_element (s);
   
   s->add_dependency (me);
 
   assert (!Stem::beam_l (s));
-  s->set_elt_property ("beam", self_scm_);
+  s->set_elt_property ("beam", me->self_scm_);
 
   add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*> (s));
 }
 
 int
-Beam::get_multiplicity () const
+Beam::get_multiplicity (Score_element*me) 
 {
-  Score_element*me =(Score_element*)this;
   int m = 0;
   for (SCM s = me->get_elt_property ("stems"); gh_pair_p (s); s = gh_cdr (s))
     {
@@ -86,23 +75,20 @@ MAKE_SCHEME_CALLBACK(Beam,before_line_breaking);
 SCM
 Beam::before_line_breaking (SCM smob)
 {
-  
-  Score_element * beam =  unsmob_element (smob);
-  Beam * me =dynamic_cast<Beam*> (beam);
+  Score_element * me =  unsmob_element (smob);
 
   // Why?
-  if (me->visible_stem_count () < 2)
+  if (visible_stem_count (me) < 2)
     {
       warning (_ ("beam has less than two stems"));
-
     }
 
   if (!Directional_element_interface (me).get ())
-    Directional_element_interface (me).set (me->get_default_dir ());
+    Directional_element_interface (me).set (get_default_dir (me));
 
-  me->auto_knees ();
-  me->set_stem_directions ();
-  me->set_stem_shorten ();
+  auto_knees (me);
+  set_stem_directions (me);
+  set_stem_shorten (me);
 
   return SCM_EOL;
 }
@@ -111,14 +97,14 @@ Beam::before_line_breaking (SCM smob)
  FIXME
  */
 Direction
-Beam::get_default_dir () const
+Beam::get_default_dir (Score_element*me) 
 {
   Drul_array<int> total;
   total[UP]  = total[DOWN] = 0;
   Drul_array<int> count; 
   count[UP]  = count[DOWN] = 0;
   Direction d = DOWN;
-  Spanner*me = (Spanner*)this;
+
   Link_array<Item> stems=
        Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
 
@@ -150,7 +136,7 @@ Beam::get_default_dir () const
   /*
     If dir is not determined: get default
   */
-  return to_dir (get_elt_property ("default-neutral-direction"));
+  return to_dir (me->get_elt_property ("default-neutral-direction"));
 }
 
 
@@ -160,11 +146,11 @@ Beam::get_default_dir () const
        once stem gets cleaned-up.
  */
 void
-Beam::set_stem_directions ()
+Beam::set_stem_directions (Score_element*me)
 {
   Link_array<Item> stems
-    =Pointer_group_interface__extract_elements (this,  (Item*) 0, "stems");
-  Direction d = Directional_element_interface (this).get ();
+    =Pointer_group_interface__extract_elements (me,  (Item*) 0, "stems");
+  Direction d = Directional_element_interface (me).get ();
   
   for (int i=0; i <stems.size (); i++)
     {
@@ -176,10 +162,10 @@ Beam::set_stem_directions ()
 } 
 
 void
-Beam::auto_knees ()
+Beam::auto_knees (Score_element*me)
 {
-  if (!auto_knee ("auto-interstaff-knee-gap", true))
-    auto_knee ("auto-knee-gap", false);
+  if (!auto_knee (me,"auto-interstaff-knee-gap", true))
+    auto_knee (me, "auto-knee-gap", false);
 }
 
 /*
@@ -190,12 +176,11 @@ Beam::auto_knees ()
   don't set, or unset autoKneeGap/autoInterstaffKneeGap.
  */
 bool
-Beam::auto_knee (String gap_str, bool interstaff_b)
+Beam::auto_knee (Score_element*me, String gap_str, bool interstaff_b)
 {
   bool knee_b = false;
   int knee_y = 0;
-  SCM gap = get_elt_property (gap_str.ch_C());
-  Spanner* me =  this;
+  SCM gap = me->get_elt_property (gap_str.ch_C());
   
   Direction d = Directional_element_interface (me).get ();
       Link_array<Item> stems=
@@ -203,15 +188,16 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
   
   if (gh_number_p (gap))
     {
+      Spanner*sp = dynamic_cast<Spanner*> (me);
       int auto_gap_i = gh_scm2int (gap);
       for (int i=1; i < stems.size (); i++)
         {
-         bool is_b = (bool)(calc_interstaff_dist (stems[i], me
-           - calc_interstaff_dist (stems[i-1], me));
+         bool is_b = (bool)(calc_interstaff_dist (stems[i], sp
+           - calc_interstaff_dist (stems[i-1], sp));
          int l_y = (int)(Stem::head_positions(stems[i-1])[d])
-           + (int)calc_interstaff_dist (stems[i-1], me);
+           + (int)calc_interstaff_dist (stems[i-1], sp);
          int r_y = (int)(Stem::head_positions(stems[i])[d])
-           + (int)calc_interstaff_dist (stems[i], me);
+           + (int)calc_interstaff_dist (stems[i], sp);
          int gap_i = r_y - l_y;
 
          if ((abs (gap_i) >= auto_gap_i) && (!interstaff_b || is_b))
@@ -228,7 +214,7 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
         {
          Item *s = stems[i];     
          int y = (int)(Stem::head_positions(s)[d])
-           + (int)calc_interstaff_dist (s, me);
+           + (int)calc_interstaff_dist (s, dynamic_cast<Spanner*> (me));
 
          Directional_element_interface (s).set (y < knee_y ? UP : DOWN);
          s->set_elt_property ("dir-forced", SCM_BOOL_T);
@@ -244,17 +230,17 @@ Beam::auto_knee (String gap_str, bool interstaff_b)
     scmify forced-fraction
  */
 void
-Beam::set_stem_shorten ()
+Beam::set_stem_shorten (Score_element*m)
 {
-  Spanner*me = this;
-  if (!visible_stem_count ())
+  Spanner*me = dynamic_cast<Spanner*> (m);
+  if (!visible_stem_count (me))
     return;
 
-  Real forced_fraction = forced_stem_count () / visible_stem_count ();
+  Real forced_fraction = forced_stem_count (me) / visible_stem_count (me);
   if (forced_fraction < 0.5)
     return;
 
-  int multiplicity = get_multiplicity ();
+  int multiplicity = get_multiplicity (me);
 
   // grace stems?
   SCM shorten = scm_eval (ly_symbol2scm ("beamed-stem-shorten"));
@@ -268,7 +254,7 @@ Beam::set_stem_shorten ()
   SCM shorten_elt = scm_list_ref (shorten, gh_int2scm (multiplicity <? (sz - 1)));
   Real shorten_f = gh_scm2double (shorten_elt) * staff_space;
 
-  /* cute, but who invented this -- how to customise ? */
+  /* cute, but who invented me -- how to customise ? */
   if (forced_fraction < 1)
     shorten_f /= 2;
 
@@ -293,19 +279,18 @@ MAKE_SCHEME_CALLBACK(Beam,after_line_breaking);
 SCM
 Beam::after_line_breaking (SCM smob)
 {
-  Score_element * beam =  unsmob_element (smob);
-  Beam * me =dynamic_cast<Beam*> (beam);
+  Score_element * me =  unsmob_element (smob);
 
   /* first, calculate y, dy */
   Real y, dy;
-  me->calc_default_position_and_height (&y, &dy);
-  if (me->visible_stem_count ())
+calc_default_position_and_height (me, &y, &dy);
+  if (visible_stem_count (me))
     {
-      if (me->suspect_slope_b (y, dy))
+      if (suspect_slope_b (me, y, dy))
        dy = 0;
 
-      Real damped_dy = me->calc_slope_damping_f (dy);
-      Real quantised_dy = me->quantise_dy_f (damped_dy);
+      Real damped_dy = calc_slope_damping_f (me, dy);
+      Real quantised_dy = quantise_dy_f (me, damped_dy);
 
       y += (dy - quantised_dy) / 2;
       dy = quantised_dy;
@@ -336,11 +321,11 @@ Beam::after_line_breaking (SCM smob)
   else
     { 
       /* we can modify y, so we should quantise y */
-      Real y_shift = me->check_stem_length_f (y, dy);
+      Real y_shift = check_stem_length_f (me, y, dy);
       y += y_shift;
-      y = me->quantise_y_f (y, dy, 0);
-      me->set_stem_length (y, dy);
-      y_shift = me->check_stem_length_f (y, dy);
+      y = quantise_y_f (me,y, dy, 0);
+      set_stem_length (me, y, dy);
+      y_shift = check_stem_length_f (me, y, dy);
 
       if (y_shift > half_space / 4)
        {
@@ -353,12 +338,12 @@ Beam::after_line_breaking (SCM smob)
          int quant_dir = 0;
          if (abs (y_shift) > half_space / 2)
            quant_dir = sign (y_shift) * Directional_element_interface (me).get ();
-         y = me->quantise_y_f (y, dy, quant_dir);
+         y = quantise_y_f (me, y, dy, quant_dir);
        }
     }
   // UGH. Y is not in staff position unit?
   // Ik dacht datwe daar juist van weg wilden?
-  me->set_stem_length (y, dy);
+  set_stem_length (me, y, dy);
   me->set_elt_property ("y-position", gh_double2scm (y));
 
   return SCM_UNDEFINED;
@@ -368,16 +353,15 @@ Beam::after_line_breaking (SCM smob)
   See Documentation/tex/fonts.doc
  */
 void
-Beam::calc_default_position_and_height (Real* y, Real* dy) const
+Beam::calc_default_position_and_height (Score_element*me,Real* y, Real* dy) 
 {
-  Spanner*me = (Spanner*)this;
   *y = 0;
   *dy = 0;  
-  if (visible_stem_count () <= 1)
+  if (visible_stem_count (me) <= 1)
     return;
 
-  Real first_ideal = Stem::calc_stem_info (first_visible_stem ()).idealy_f_;
-  if (first_ideal == Stem::calc_stem_info (last_visible_stem ()).idealy_f_)
+  Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
+  if (first_ideal == Stem::calc_stem_info (last_visible_stem (me)).idealy_f_)
     {
       *dy = 0;
       *y = first_ideal;
@@ -385,7 +369,7 @@ Beam::calc_default_position_and_height (Real* y, Real* dy) const
     }
 
   Array<Offset> ideals;
-  Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
+  Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
   Link_array<Item> stems=
     Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
 
@@ -400,23 +384,23 @@ Beam::calc_default_position_and_height (Real* y, Real* dy) const
   Real dydx;
   minimise_least_squares (&dydx, y, ideals); // duh, takes references
 
-  Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+  Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
   *dy = dydx * dx;
 }
 
 bool
-Beam::suspect_slope_b (Real y, Real dy) const
+Beam::suspect_slope_b (Score_element*me, Real y, Real dy) 
 {
   /* first, calculate y, dy */
   /*
     steep slope running against lengthened stem is suspect
   */
-  Real first_ideal = Stem::calc_stem_info (first_visible_stem ()).idealy_f_;
-  Real last_ideal = Stem::calc_stem_info (last_visible_stem ()).idealy_f_;
-  Real lengthened = paper_l ()->get_var ("beam_lengthened");
-  Real steep = paper_l ()->get_var ("beam_steep_slope");
+  Real first_ideal = Stem::calc_stem_info (first_visible_stem (me)).idealy_f_;
+  Real last_ideal = Stem::calc_stem_info (last_visible_stem (me)).idealy_f_;
+  Real lengthened = me->paper_l ()->get_var ("beam_lengthened");
+  Real steep = me->paper_l ()->get_var ("beam_steep_slope");
 
-  Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS);
+  Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS);
   Real dydx = dy && dx ? dy/dx : 0;
 
   if (((y - first_ideal > lengthened) && (dydx > steep))
@@ -433,15 +417,15 @@ Beam::suspect_slope_b (Real y, Real dy) const
   corresponds with some tables in [Wanske]
 */
 Real
-Beam::calc_slope_damping_f (Real dy) const
+Beam::calc_slope_damping_f (Score_element*me,Real dy) 
 {
-  SCM damp = get_elt_property ("damping"); 
+  SCM damp = me->get_elt_property ("damping"); 
   int damping = gh_scm2int (damp);
 
   if (damping)
     {
-      Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS)
-       - first_visible_stem ()->relative_coordinate (0, X_AXIS);
+      Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS)
+       - first_visible_stem (me)->relative_coordinate (0, X_AXIS);
       Real dydx = dy && dx ? dy/dx : 0;
       dydx = 0.6 * tanh (dydx) / damping;
       return dydx * dx;
@@ -450,18 +434,17 @@ Beam::calc_slope_damping_f (Real dy) const
 }
 
 Real
-Beam::calc_stem_y_f (Item* s, Real y, Real dy) const
+Beam::calc_stem_y_f (Score_element*me,Item* s, Real y, Real dy) 
 {
-  Score_element*me = (Score_element*)this;
-  Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
-  thick *= paper_l ()->get_var ("staffspace");
+  Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
+  thick *= me->paper_l ()->get_var ("staffspace");
   
-  int beam_multiplicity = get_multiplicity ();
+  int beam_multiplicity = get_multiplicity (me);
   int stem_multiplicity = (Stem::flag_i (s) - 2) >? 0;
 
-  Real interbeam_f = paper_l ()->interbeam_f (beam_multiplicity);
-  Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
-  Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+  Real interbeam_f = me->paper_l ()->interbeam_f (beam_multiplicity);
+  Real x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
+  Real dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
   Real stem_y = (dy && dx ? (s->relative_coordinate (0, X_AXIS) - x0) / dx * dy : 0) + y;
 
   /* knee */
@@ -478,7 +461,7 @@ Beam::calc_stem_y_f (Item* s, Real y, Real dy) const
       
       // huh, why not for first visible?
        if (Staff_symbol_referencer::staff_symbol_l (s)
-          != Staff_symbol_referencer::staff_symbol_l (last_visible_stem ()))
+          != Staff_symbol_referencer::staff_symbol_l (last_visible_stem (me)))
         stem_y += Directional_element_interface (me).get ()
           * (beam_multiplicity - stem_multiplicity) * interbeam_f;
       }
@@ -487,9 +470,8 @@ Beam::calc_stem_y_f (Item* s, Real y, Real dy) const
 }
 
 Real
-Beam::check_stem_length_f (Real y, Real dy) const
+Beam::check_stem_length_f (Score_element*me,Real y, Real dy) 
 {
-  Score_element * me = (Score_element*)this;
   Real shorten = 0;
   Real lengthen = 0;
   Direction dir = Directional_element_interface (me).get ();
@@ -503,7 +485,7 @@ Beam::check_stem_length_f (Real y, Real dy) const
       if (Stem::invisible_b (s))
        continue;
 
-      Real stem_y = calc_stem_y_f (s, y, dy);
+      Real stem_y = calc_stem_y_f (me, s, y, dy);
        
       stem_y *= dir;
       Stem_info info = Stem::calc_stem_info (s);
@@ -526,10 +508,8 @@ Beam::check_stem_length_f (Real y, Real dy) const
   stem directions and length should set to relative to the chord's
   position of the beam.  */
 void
-Beam::set_stem_length (Real y, Real dy)
+Beam::set_stem_length (Score_element*me,Real y, Real dy)
 {
-  Beam*me = this;
-
   Real half_space = Staff_symbol_referencer::staff_space (me)/2;
   Link_array<Item> stems=
     Pointer_group_interface__extract_elements (me, (Item*)0, "stems");
@@ -541,10 +521,10 @@ Beam::set_stem_length (Real y, Real dy)
       if (Stem::invisible_b (s))
        continue;
 
-      Real stem_y = calc_stem_y_f (s, y, dy);
+      Real stem_y = calc_stem_y_f (me, s, y, dy);
 
       /* caution: stem measures in staff-positions */
-      Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, me)) / half_space);
+      Stem::set_stemend (s,(stem_y + calc_interstaff_dist (s, dynamic_cast<Spanner*> (me))) / half_space);
     }
 }
 
@@ -557,9 +537,8 @@ Beam::set_stem_length (Real y, Real dy)
   + n * staff_space
 */
 Real
-Beam::quantise_dy_f (Real dy) const
+Beam::quantise_dy_f (Score_element*me,Real dy) 
 {
-  Score_element*me = (Score_element*)this;
   Array<Real> a;
   for (SCM s = scm_eval (ly_symbol2scm ("beam-height-quants")); s !=SCM_EOL; s = gh_cdr (s))
     a.push (gh_scm2double (gh_car (s)));
@@ -586,10 +565,9 @@ Beam::quantise_dy_f (Real dy) const
   if extend_b then stems must *not* get shorter
  */
 Real
-Beam::quantise_y_f (Real y, Real dy, int quant_dir)
+Beam::quantise_y_f (Score_element*me,Real y, Real dy, int quant_dir)
 {
-  int multiplicity = get_multiplicity ();
-  Score_element*me = (Score_element*)this;
+  int multiplicity = get_multiplicity (me);
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   SCM quants = scm_eval (gh_list (ly_symbol2scm ("beam-vertical-position-quants"),
@@ -617,9 +595,8 @@ Beam::quantise_y_f (Real y, Real dy, int quant_dir)
 }
 
 void
-Beam::set_beaming (Beaming_info_list *beaming)
+Beam::set_beaming (Score_element*me,Beaming_info_list *beaming)
 {
-  Score_element*me = this;
   Link_array<Score_element> stems=
     Pointer_group_interface__extract_elements (me, (Score_element*)0, "stems");
   
@@ -644,28 +621,27 @@ Beam::set_beaming (Beaming_info_list *beaming)
   clean  me up.
   */
 Molecule
-Beam::stem_beams (Item *here, Item *next, Item *prev) const
+Beam::stem_beams (Score_element*me,Item *here, Item *next, Item *prev) 
 {
-  Score_element*me = (Score_element*)this;
   if ((next && !(next->relative_coordinate (0, X_AXIS) > here->relative_coordinate (0, X_AXIS))) ||
       (prev && !(prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS))))
       programming_error ("Beams are not left-to-right");
 
-  Real staffline_f = paper_l ()->get_var ("stafflinethickness");
-  int multiplicity = get_multiplicity ();
+  Real staffline_f = me->paper_l ()->get_var ("stafflinethickness");
+  int multiplicity = get_multiplicity (me);
 
 
-  Real interbeam_f = paper_l ()->interbeam_f (multiplicity);
-  Real thick = gh_scm2double (get_elt_property ("beam-thickness"));
-  thick *= paper_l ()->get_var ("staffspace");
+  Real interbeam_f = me->paper_l ()->interbeam_f (multiplicity);
+  Real thick = gh_scm2double (me->get_elt_property ("beam-thickness"));
+  thick *= me->paper_l ()->get_var ("staffspace");
     
   Real bdy = interbeam_f;
   Real stemdx = staffline_f;
 
-  Real dx = visible_stem_count () ?
-    last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS)
+  Real dx = visible_stem_count (me) ?
+    last_visible_stem (me)->relative_coordinate (0, X_AXIS) - first_visible_stem (me)->relative_coordinate (0, X_AXIS)
     : 0.0;
-  Real dy = gh_scm2double (get_elt_property ("height"));
+  Real dy = gh_scm2double (me->get_elt_property ("height"));
   Real dydx = dy && dx ? dy/dx : 0;
 
   Molecule leftbeams;
@@ -676,11 +652,11 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
   if (!Stem::first_head (here))
     nw_f = 0;
   else if (Stem::type_i (here)== 1)
-    nw_f = paper_l ()->get_var ("wholewidth");
+    nw_f = me->paper_l ()->get_var ("wholewidth");
   else if (Stem::type_i (here) == 2)
-    nw_f = paper_l ()->get_var ("notewidth") * 0.8;
+    nw_f = me->paper_l ()->get_var ("notewidth") * 0.8;
   else
-    nw_f = paper_l ()->get_var ("quartwidth");
+    nw_f = me->paper_l ()->get_var ("quartwidth");
 
 
   Direction dir = Directional_element_interface (me).get ();
@@ -698,7 +674,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
       w = w/2 <? nw_f;
       Molecule a;
       if (lhalfs)              // generates warnings if not
-       a =  lookup_l ()->beam (dydx, w, thick);
+       a =  me->lookup_l ()->beam (dydx, w, thick);
       a.translate (Offset (-w, -w * dydx));
       for (int j = 0; j  < lhalfs; j++)
        {
@@ -714,12 +690,12 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
       int rwholebeams= Stem::beam_count (here,RIGHT) <? Stem::beam_count (next,LEFT) ;
 
       Real w = next->relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS);
-      Molecule a = lookup_l ()->beam (dydx, w + stemdx, thick);
+      Molecule a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
       a.translate_axis( - stemdx/2, X_AXIS);
       int j = 0;
       Real gap_f = 0;
 
-      SCM gap = get_elt_property ("beam-gap");
+      SCM gap = me->get_elt_property ("beam-gap");
       if (gh_number_p (gap))
        {
          int gap_i = gh_scm2int ( (gap));
@@ -734,7 +710,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
          // TODO: notehead widths differ for different types
          gap_f = nw_f / 2;
          w -= 2 * gap_f;
-         a = lookup_l ()->beam (dydx, w + stemdx, thick);
+         a = me->lookup_l ()->beam (dydx, w + stemdx, thick);
        }
 
       for (; j  < rwholebeams; j++)
@@ -746,7 +722,7 @@ Beam::stem_beams (Item *here, Item *next, Item *prev) const
 
       w = w/2 <? nw_f;
       if (rhalfs)
-       a = lookup_l ()->beam (dydx, w, thick);
+       a = me->lookup_l ()->beam (dydx, w, thick);
 
       for (; j  < rwholebeams + rhalfs; j++)
        {
@@ -769,19 +745,18 @@ MAKE_SCHEME_CALLBACK(Beam,brew_molecule);
 SCM
 Beam::brew_molecule (SCM smob)
 {
-  Score_element * beam =  unsmob_element (smob);
-  Beam * me =dynamic_cast<Beam*> (beam);
+  Score_element * me =unsmob_element (smob);
 
   Molecule mol;
   if (!gh_pair_p (me->get_elt_property ("stems")))
     return SCM_EOL;
   Real x0,dx;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");  
-  if (me->visible_stem_count ())
+    Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");  
+  if (visible_stem_count (me))
     {
-      x0 = me->first_visible_stem ()->relative_coordinate (0, X_AXIS);
-      dx = me->last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+      x0 = first_visible_stem (me)->relative_coordinate (0, X_AXIS);
+      dx = last_visible_stem (me)->relative_coordinate (0, X_AXIS) - x0;
     }
   else
     {
@@ -801,23 +776,22 @@ Beam::brew_molecule (SCM smob)
       Item * prev = (j > 0)? stems[j-1] : 0;
       Item * next = (j < stems.size()-1) ? stems[j+1] :0;
 
-      Molecule sb = me->stem_beams (i, next, prev);
+      Molecule sb = stem_beams (me, i, next, prev);
       Real x = i->relative_coordinate (0, X_AXIS)-x0;
       sb.translate (Offset (x, x * dydx + y));
       mol.add_molecule (sb);
     }
   mol.translate_axis (x0 
-    - me->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS);
+    - dynamic_cast<Spanner*> (me)->get_bound (LEFT)->relative_coordinate (0, X_AXIS), X_AXIS);
 
   return mol.create_scheme ();
 }
 
 int
-Beam::forced_stem_count () const
+Beam::forced_stem_count (Score_element*me) 
 {
-  Score_element* me = (Score_element*)this;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");
+    Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
   int f = 0;
   for (int i=0; i < stems.size (); i++)
     {
@@ -840,9 +814,8 @@ Beam::forced_stem_count () const
    use filter and standard list functions.
  */
 int
-Beam::visible_stem_count () const
+Beam::visible_stem_count (Score_element*me) 
 {
-  Score_element * me = (Score_element*)this;
   Link_array<Item>stems = 
     Pointer_group_interface__extract_elements (me, (Item*) 0, "stems");
   int c = 0;
@@ -855,11 +828,10 @@ Beam::visible_stem_count () const
 }
 
 Item*
-Beam::first_visible_stem() const
+Beam::first_visible_stem(Score_element*me) 
 {
-  Score_element * me = (Score_element*)this;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");
+    Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
   
   for (int i = 0; i < stems.size (); i++)
     {
@@ -870,11 +842,10 @@ Beam::first_visible_stem() const
 }
 
 Item*
-Beam::last_visible_stem() const
+Beam::last_visible_stem(Score_element*me) 
 {
-  Score_element * me = (Score_element*)this;
   Link_array<Item>stems = 
-    Pointer_group_interface__extract_elements ((Beam*) me, (Item*) 0, "stems");
+    Pointer_group_interface__extract_elements ( me, (Item*) 0, "stems");
   for (int i = stems.size (); i--;)
     {
       if (!Stem::invisible_b (stems[i]))
@@ -902,8 +873,8 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
   Score_element * stem = st;
   if (!stem)
     return 0.0;
-  Beam * beam = dynamic_cast<Beam*> (unsmob_element (stem->get_elt_property ("beam"))); 
-  if (!beam || !beam->visible_stem_count ())
+  Score_element * beam = unsmob_element (stem->get_elt_property ("beam"));
+  if (!beam || !Beam::has_interface (beam) || !Beam::visible_stem_count (beam))
     return 0.0;
 
   // make callback for rest from this.
@@ -920,8 +891,8 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
   if (gh_number_p (s))
     beam_y = gh_scm2double (s);
   
-  Real x0 = beam->first_visible_stem()->relative_coordinate (0, X_AXIS);
-  Real dx = beam->last_visible_stem()->relative_coordinate (0, X_AXIS) - x0;
+  Real x0 = first_visible_stem(beam)->relative_coordinate (0, X_AXIS);
+  Real dx = last_visible_stem(beam)->relative_coordinate (0, X_AXIS) - x0;
   Real dydx = beam_dy && dx ? beam_dy/dx : 0;
 
   Direction d = Stem::get_direction (stem);
@@ -946,3 +917,21 @@ Beam::rest_collision_callback (Score_element *rest, Axis a )
 
   return  (-d *  discrete_dist);
 }
+
+
+bool
+Beam::has_interface (Score_element*me)
+{
+  return me->has_interface (ly_symbol2scm ("beam-interface"));
+}
+
+void
+Beam::set_interface (Score_element*me)
+{
+  Pointer_group_interface g (me, "stems");
+  g.set_interface ();
+
+  me->set_elt_property ("height", gh_int2scm (0)); // ugh.
+  me->set_elt_property ("y-position" ,gh_int2scm (0));
+  me->set_interface (ly_symbol2scm("beam-interface"));
+}
index 7c679d76fb42b0e22589e291d5494fbd55c41896..4802e0507c9ed2420495d5a0221605388158fa93 100644 (file)
 Array<int>
 Break_algorithm::find_break_indices () const
 {
-  Link_array<Paper_column> all = pscore_l_->line_l_->column_l_arr ();
-  
-                                        
+  Link_array<Score_element> all = pscore_l_->line_l_->column_l_arr ();
   Array<int> retval;
 
   for (int i=0; i < all.size (); i++)
-    if (all[i]->breakable_b ())
+    if (Item::breakable_b (all[i]))
       retval.push (i);
 
   if (linewidth_f_ <=0)
@@ -39,15 +37,14 @@ Break_algorithm::find_break_indices () const
 }
 
 
-Link_array<Paper_column>
+Link_array<Score_element>
 Break_algorithm::find_breaks () const
 {
-  Link_array<Paper_column> all = pscore_l_->line_l_->column_l_arr ();
-    
-  Link_array<Paper_column> retval;
+  Link_array<Score_element> all = pscore_l_->line_l_->column_l_arr ();
+  Link_array<Score_element> retval;
 
   for (int i=0; i < all.size (); i++)
-    if (all[i]->breakable_b ())
+    if (Item::breakable_b (all[i]))
       retval.push (all[i]);
 
   if (linewidth_f_ <=0)
@@ -59,7 +56,7 @@ Break_algorithm::find_breaks () const
 
 
 Simple_spacer*
-Break_algorithm::generate_spacing_problem (Link_array<Paper_column> curline, Interval line) const
+Break_algorithm::generate_spacing_problem (Link_array<Score_element> curline, Interval line) const
 {
   Simple_spacer * sp =  new Simple_spacer;
   Paper_def * d = pscore_l_->paper_l_;
index d670feb130172f09bd157469b7ad8f505c36105e..87fdecbce89e1540b40204bd0454b5e6dc5af58c 100644 (file)
@@ -17,6 +17,8 @@
 #include "warn.hh"
 #include "misc.hh"
 #include "note-head.hh"
+#include "spanner.hh"
+#include "item.hh"
 
 /**
   This acknowledges repeated music with "tremolo" style.  It typesets
@@ -49,8 +51,8 @@ protected:
 
   int note_head_i_;
   
-  Beam * beam_p_;
-  Beam * finished_beam_p_;
+  Spanner * beam_p_;
+  Spanner * finished_beam_p_;
   
 protected:
   virtual void do_removal_processing();
@@ -91,7 +93,8 @@ Chord_tremolo_engraver::do_process_music ()
 {
   if (repeat_ && !beam_p_)
     {
-      beam_p_ = new Beam (get_property ("basicBeamProperties"));
+      beam_p_ = new Spanner (get_property ("basicBeamProperties"));
+      Beam::set_interface (beam_p_);
       beam_p_->set_elt_property ("chord-tremolo", SCM_BOOL_T);
 
 
@@ -160,7 +163,7 @@ Chord_tremolo_engraver::acknowledge_element (Score_element_info info)
 
          if (Rhythmic_req* r = dynamic_cast <Rhythmic_req *> (info.req_l_))
            {
-             beam_p_->add_stem (s);
+             Beam::add_stem (beam_p_, s);
              Moment stem_location = now_mom () -
                start_mom_ + beam_start_location_;
            }
index 8816100638c886697c2e7bbe8a02debee40301a4..9b3218de78922fd0eadd0c253a7270bba2d842d3 100644 (file)
@@ -17,7 +17,7 @@
   a collision object.  */
 class Collision_engraver : public Engraver {
   Item * col_p_;
-  Link_array<Note_column> note_column_l_arr_;
+  Link_array<Score_element> note_column_l_arr_;
 
 protected:
   virtual void acknowledge_element (Score_element_info);
@@ -50,13 +50,13 @@ Collision_engraver::process_acknowledged ()
 void
 Collision_engraver::acknowledge_element (Score_element_info i)
 {
-  if (Note_column * c = dynamic_cast<Note_column *> (i.elem_l_))
+  if (Note_column::has_interface (i.elem_l_))
     {
       /*should check Y axis? */
-      if (c->rest_b () || c->parent_l(X_AXIS))
+      if (Note_column::rest_b (i.elem_l_) || i.elem_l_->parent_l(X_AXIS))
        return ;
 
-      note_column_l_arr_.push (c);
+      note_column_l_arr_.push (i.elem_l_);
     }
 }
 
index a52c13004850036456932058960b3e1a55a9c0b0..8d1f6d1232ca0fa1d63cce82821b665af6be83db 100644 (file)
@@ -14,7 +14,7 @@
 #include "item.hh"
 
 void
-Collision::add_column (Score_element*me,Note_column* ncol_l)
+Collision::add_column (Score_element*me,Score_element* ncol_l)
 {
   ncol_l->add_offset_callback (force_shift_callback, X_AXIS);
   Axis_group_interface::add_element (me, ncol_l);
@@ -77,7 +77,7 @@ Collision::do_shifts(Score_element* me)
 SCM
 Collision::automatic_shift (Score_element *me)
 {
-  Drul_array<Link_array<Note_column> > clash_groups;
+  Drul_array<Link_array<Score_element> > clash_groups;
   Drul_array<Array<int> > shifts;
   SCM  tups = SCM_EOL;
 
@@ -87,8 +87,8 @@ Collision::automatic_shift (Score_element *me)
       SCM car = gh_car (s);
 
       Score_element * se = unsmob_element (car);
-      if (Note_column * col = dynamic_cast<Note_column*> (se))
-       clash_groups[col->dir ()].push (col);
+      if (Note_column::has_interface (se))
+       clash_groups[Note_column::dir (se)].push (se);
     }
 
   
@@ -96,7 +96,7 @@ Collision::automatic_shift (Score_element *me)
   do
     {
       Array<int> & shift (shifts[d]);
-      Link_array<Note_column> & clashes (clash_groups[d]);
+      Link_array<Score_element> & clashes (clash_groups[d]);
 
       clashes.sort (Note_column::shift_compare);
 
@@ -157,15 +157,15 @@ Collision::automatic_shift (Score_element *me)
     all of them again. */
   if (extents[UP].size () && extents[DOWN].size ())
     {
-      Note_column *cu_l =clash_groups[UP][0];
-      Note_column *cd_l =clash_groups[DOWN][0];
+      Score_element *cu_l =clash_groups[UP][0];
+      Score_element *cd_l =clash_groups[DOWN][0];
 
 
       /*
        TODO.
        */
-      Score_element * nu_l= cu_l->first_head();
-      Score_element * nd_l = cd_l->first_head();
+      Score_element * nu_l= Note_column::first_head(cu_l);
+      Score_element * nd_l = Note_column::first_head(cd_l);
       
       int downpos = Note_column::head_positions_interval (cd_l)[BIGGER];
       int uppos = Note_column::head_positions_interval (cu_l)[SMALLER];      
index 967dcc188693e0561fddb4f04d501996ba4ec703..f0390d479853df753d537b69ad890d2f99005158 100644 (file)
@@ -333,12 +333,12 @@ Dynamic_engraver::typeset_all ()
 void
 Dynamic_engraver::acknowledge_element (Score_element_info i)
 {
-  if (Note_column* n = dynamic_cast<Note_column*> (i.elem_l_))
+  if (Note_column::has_interface (i.elem_l_))
     {
       if (line_spanner_)
        {
-         Side_position::add_support (line_spanner_,n);
-         add_bound_item (line_spanner_,n);
+         Side_position::add_support (line_spanner_,i.elem_l_);
+         add_bound_item (line_spanner_,dynamic_cast<Item*>(i.elem_l_));
        }
     }
 }
index 3f9662a99a95b07f3600de8c3ca6b327ed74839c..192ece0a69c9642c51a56b04fed0b3ad03894f42 100644 (file)
@@ -54,7 +54,7 @@ Array<Column_x_positions>
 Gourlay_breaking::do_solve () const
 {
   Array<Break_node> optimal_paths;
-  Link_array<Paper_column> all =
+  Link_array<Score_element> all =
     pscore_l_->line_l_->column_l_arr ();
   
   Array<int> breaks = find_break_indices ();
@@ -80,10 +80,10 @@ Gourlay_breaking::do_solve () const
 
       for (int start_idx = break_idx; start_idx--;)
        {
-         Link_array<Paper_column> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
+         Link_array<Score_element> line = all.slice (breaks[start_idx], breaks[break_idx]+1);
   
-         line[0]     = dynamic_cast<Paper_column*> (line[0]    ->find_prebroken_piece (RIGHT));
-         line.top () = dynamic_cast<Paper_column*> (line.top ()->find_prebroken_piece (LEFT));
+         line[0]     = dynamic_cast<Item*> (line[0])    ->find_prebroken_piece (RIGHT);
+         line.top () = dynamic_cast<Item*> (line.top ())->find_prebroken_piece (LEFT);
            
          Column_x_positions cp;
          cp.cols_ = line;
@@ -177,7 +177,7 @@ Gourlay_breaking::combine_demerits (Column_x_positions const &prev,
                                    Column_x_positions const &this_one) const
 {
   Real break_penalties = 0.0;
-  Paper_column * pc = this_one.cols_.top ();
+  Score_element * pc = this_one.cols_.top ();
   if (pc->original_l_)
     {
       SCM pen = pc->get_elt_property ("penalty");
index 2b7aec2beb2aa11c2a801e3cb6e6374d08644f33..a8150dac67b2d14580051b4d54660a74166ffe79 100644 (file)
 #include "paper-column.hh"
 #include "paper-def.hh"
 
-void
-Grace_align_item::set_interface (Score_element*me)
-{
-  me->set_interface (ly_symbol2scm ("grace-align-interface"));
-  me->set_elt_property ("stacking-dir", gh_int2scm (RIGHT));
-  Align_interface::set_interface(me);
-  Align_interface::set_axis (me,X_AXIS);
-}
-
 /*
   TODO: cfg-able
  */
@@ -41,6 +32,17 @@ Grace_align_item::before_line_breaking (SCM smob)
   return SCM_UNDEFINED;
 }
 
+void
+Grace_align_item::set_interface (Score_element*me)
+{
+  me->set_interface (ly_symbol2scm ("grace-align-interface"));
+  me->set_elt_property ("stacking-dir", gh_int2scm (RIGHT));
+  Align_interface::set_interface(me);
+  Align_interface::set_axis (me,X_AXIS);
+}
+
+
+
 bool
 Grace_align_item::has_interface (Score_element*m)
 {
index dba75f20450bc798474b7311e6dbe9f35419c291..b83254e1c5346fe64056f73d812cfd91eddb9c61 100644 (file)
@@ -8,7 +8,7 @@
 #define BEAM_HH
 
 #include "lily-proto.hh"
-#include "spanner.hh"
+#include "lily-guile.hh"
 
 
 /** a beam connects multiple stems.
    damping -- amount of beam slope damping. (int)
    should beam slope be damped? 0: no, 1: yes, 100000: horizontal beams 
 */
-class Beam : public Spanner
+class Beam
 {
 public:
-
-
-  int visible_stem_count () const;
-  Item* first_visible_stem () const;
-  Item* last_visible_stem () const;
+  static int visible_stem_count (Score_element*);
+  static  Item* first_visible_stem (Score_element*);
+  static  Item* last_visible_stem (Score_element*);
+  static bool has_interface (Score_element*);
+  static void set_interface (Score_element*);  
   static Real rest_collision_callback (Score_element *,Axis);
   Beam (SCM);
-  void add_stem (Score_element*);
-  void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current);
-  void set_beaming (Beaming_info_list *);
-  void set_stemlens ();
-  VIRTUAL_COPY_CONS(Score_element);
-
-  int get_multiplicity () const;
-
+  static void add_stem (Score_element*,Score_element*);
+  static void set_grouping (Score_element*,Rhythmic_grouping def, Rhythmic_grouping current);
+  static void set_beaming (Score_element*,Beaming_info_list *);
+  static void set_stemlens (Score_element*);
+  static int get_multiplicity (Score_element*me);
   static SCM brew_molecule (SCM);
   static SCM before_line_breaking (SCM);
   static SCM after_line_breaking (SCM);
+  static Molecule stem_beams (Score_element*,Item *here, Item *next, Item *prev);
 
-  Molecule stem_beams (Item *here, Item *next, Item *prev) const;
 private:
-  Direction get_default_dir () const;
-  void set_stem_directions ();
-  void auto_knees ();
-  bool auto_knee (String gap_str, bool interstaff_b);
-  void set_stem_shorten ();
-  void calc_default_position_and_height (Real* y, Real* dy) const;
-  bool suspect_slope_b (Real y, Real dy) const;
-  Real calc_slope_damping_f (Real dy) const;
-  Real calc_stem_y_f (Item* s, Real y, Real dy) const;
-  Real check_stem_length_f (Real y, Real dy) const;
-  void set_stem_length (Real y, Real dy);
-  Real quantise_dy_f (Real dy) const;
-  Real quantise_y_f (Real y, Real dy, int quant_dir);
-  int forced_stem_count () const;
+  static Direction get_default_dir (Score_element*);
+  static  void set_stem_directions (Score_element*);
+  static  void auto_knees (Score_element*);
+  static  bool auto_knee (Score_element*,String gap_str, bool interstaff_b);
+  static void set_stem_shorten (Score_element*);
+  static  void calc_default_position_and_height (Score_element*,Real* y, Real* dy);
+  static  bool suspect_slope_b (Score_element*, Real y, Real dy);
+  static  Real calc_slope_damping_f (Score_element*, Real dy);
+  static  Real calc_stem_y_f (Score_element*, Item* s, Real y, Real dy);
+  static  Real check_stem_length_f (Score_element*, Real y, Real dy);
+  static  void set_stem_length (Score_element*, Real y, Real dy);
+  static   Real quantise_dy_f (Score_element*, Real dy);
+  static  Real quantise_y_f (Score_element*, Real y, Real dy, int quant_dir);
+  static int forced_stem_count (Score_element*);
 };
 
 #endif // BEAM_HH
index 7e0c3415444b82dd88000c1b59573954859fdb53..fa0b0d77709c51fde1c56a94fc989d439f07412e 100644 (file)
@@ -28,7 +28,7 @@ protected:
   Real linewidth_f_;
 
   /// search all pcols which are breakable.
-  Link_array<Paper_column> find_breaks() const;
+  Link_array<Score_element> find_breaks() const;
 
   Array<int> find_break_indices() const;
     
@@ -37,10 +37,10 @@ protected:
   void solve_line (Column_x_positions*) const;
 
   /// does curline fit on the paper?    
-  bool feasible (Link_array<Paper_column>) const;
+  bool feasible (Link_array<Score_element>) const;
     
 
-  Simple_spacer* generate_spacing_problem (Link_array<Paper_column>, Interval) const;
+  Simple_spacer* generate_spacing_problem (Link_array<Score_element>, Interval) const;
 
   virtual Array<Column_x_positions> do_solve() const=0;
 
index 469dfeacbd7873b8b99e16d3f558b1054a58bd15..10c5397a6eb57df8709a2b1131d966cc8643a7cf 100644 (file)
@@ -43,6 +43,6 @@ public:
   static SCM forced_shift (Score_element*);
   static Real force_shift_callback (Score_element *, Axis);
   static void do_shifts (Score_element*);
-  static void add_column (Score_element*me,Note_column*ncol_l);
+  static void add_column (Score_element*me,Score_element*ncol_l);
 };
 #endif // COLLISION_HH
index 23bea78d2ed195f37faeba5ef99c228df454e9ff..aec96022230b59c66d58338def47a914bf8e59b2 100644 (file)
@@ -13,7 +13,7 @@
 
 struct Column_x_positions
 {
-  Link_array<Paper_column> cols_;
+  Link_array<Score_element> cols_;
   Array<Real> config_;
   Real force_f_;
   bool satisfies_constraints_b_;
index c036dd2e524cd19bb8eacd4c472bb961f6c419a7..16f298f7f2361983d612975fcd699d3e6dfff2d2 100644 (file)
@@ -43,7 +43,7 @@ public:
   Item (SCM);
   Item (Item const &);
 
-  bool breakable_b () const;
+  static bool breakable_b (Score_element*me);
   bool broken_b () const;
   
   Direction break_status_dir () const;
index 9d510c692cfb172584e9f8dc26f6315b8c891c9b..96b3d6b265a8524b69478c46585afc70a1416201 100644 (file)
@@ -44,7 +44,7 @@ public:
   void output_lines ();
 
   Link_array<Item> broken_col_range (Item const*, Item const*) const;
-  Link_array<Paper_column> column_l_arr () const;
+  Link_array<Score_element> column_l_arr () const;
   
   void add_column (Paper_column*);
   void typeset_element (Score_element*);
index 71353da3b1b7c026e50f8360e88ab70972f905f5..4b57a9662c37ada2054729331612a3f97d2c156d 100644 (file)
 #ifndef MULTI_MEASURE_REST_HH
 #define MULTI_MEASURE_REST_HH
 
-#include "spanner.hh"
+#include "lily-proto.hh"
+#include "lily-guile.hh"
+#include "rod.hh"
 
-
-class Multi_measure_rest : public Spanner
+class Multi_measure_rest
 {
 public:
-  Multi_measure_rest (SCM);
-  
   static void set_interface (Score_element*);
   static bool has_interface (Score_element*);
   static SCM brew_molecule (SCM);
   static  void add_column (Score_element*,Item*);
-  VIRTUAL_COPY_CONS (Score_element);
-  virtual Array<Rod> get_rods () const;
+  static SCM set_spacing_rods (SCM);
 };
 
 #endif /* MULTI_MEASURE_REST_HH */
index 7bf51956d5144f9cd1e92810a563b3413f0eb755..855d655cd6596b2afe6de605a293781a41d8775d 100644 (file)
   UGR. Junkme.  refpoint should be the notehead, dir should come from stem.
 
 */
-class Note_column : public Item
+class Note_column
 {
 public:
-  static int shift_compare (Note_column *const &, Note_column*const&);
+  static int shift_compare (Score_element *const &, Score_element*const&);
   
   /** The relative position of the "voice" containing this
     chord. Normally this would be the same as the stem direction,
 
     JUNKME.
     */
-  Direction dir () const;
 
-
-  static Slice head_positions_interval(Score_element* me) ;
+  static Direction dir (Score_element*me);
+  static Slice head_positions_interval(Score_element* me);
   static Direction static_dir (Score_element*);
-  void translate_rests(int dy);
-  Score_element * first_head ()const;
-  Interval rest_dim ()const ;
-  Note_column (SCM);
-  void set_stem (Score_element*);
-  void set_dotcol (Score_element*);
-  void add_head (Score_element*);
-  bool rest_b () const;
-
+  static void translate_rests(Score_element*me,int dy);
+  static Score_element * first_head (Score_element*me);
+  static Interval rest_dim (Score_element*me);
+  static void set_stem (Score_element*me,Score_element*);
+  static void set_dotcol (Score_element*me,Score_element*);
+  static void add_head (Score_element*me,Score_element*);
+  static bool rest_b (Score_element*me);
   static bool has_interface (Score_element*);
-
-  Item *stem_l()const;
+  static void set_interface (Score_element*);
+  static Item *stem_l(Score_element*);
 };
 
 #endif // NOTE_COLUMN_HH
index 3b1756e8f1cb77ce9548e48152734f2e9ffdd36d..5633cb0fb236e48d8845d0fc2d9b30045479b5ce 100644 (file)
 #include "spring.hh"
 
 /**
-   stuff grouped vertically.
-    This is a class to address items vertically. It contains the data for:
-    \begin{itemize}
-    \item
-    unbroken score
-    \item
-    broken score
-    \item
-    the linespacing problem
-    \end{itemize}
+   bounded-by-me -- list of elts.
+
+   shortest-starter-duration -- rational signifying shortest moment that starts here
+
+
+   Interfaces:
+
+   axis-group, spaceable-element.
   */
 
 class Paper_column : public Item
@@ -32,29 +30,11 @@ class Paper_column : public Item
 public:
   VIRTUAL_COPY_CONS(Score_element);
 
-  /*
-    ugh.
-
-    TODO:
-    
-    * junk these after spacing is done.
-
-    * Put these in Scheme.
-   */
-
-
-  Array<Column_rod>  minimal_dists_;
-  Array<Column_spring > springs_;
-
-
   /*
     Not (yet) in scm, because of messy effects when a column commits suicide.
    */
   int  rank_i_;
-  /// set a minimum distance
-  void add_rod (Paper_column * to, Real distance);
-  void add_spring (Paper_column * to, Real dist, Real strength);
-
+  virtual void do_break_processing ();
   virtual Paper_column *column_l () const;
   virtual Line_of_score *line_l () const;
 
@@ -65,10 +45,10 @@ public:
   static int rank_i(Score_element*);
 
   Paper_column (SCM);
-  Moment when_mom ()const;
-
   bool musical_b () const;
-  bool used_b () const;
+  static Moment when_mom (Score_element*);
+
+  static bool used_b (Score_element*) ;
   void set_rank (int);
 };
      
index 39a9fcd120669a3db0e45052396f858908c91cfd..79b7b8aa72876bcbbd85d77f5da2be0c1273a41b 100644 (file)
@@ -16,7 +16,7 @@
 class Rest_collision           // interface
 {
 public:
-  static void add_column (Score_element*me,Note_column*);
+  static void add_column (Score_element*me,Score_element*);
   static void set_interface (Score_element*me);
   static bool has_interface (Score_element*);
   static Real force_shift_callback (Score_element *, Axis);
index f76a4e5b0c8d50c3e18ee86e0d94bed23a3e002f..d795f539ad3b1163af9df1e1a86ea926f2846d22 100644 (file)
 #include "direction.hh"
 #include "drul-array.hh"
 
-struct Column_rod
-{
-  Paper_column *other_l_;
-  Real distance_f_;
-
-  Column_rod ();
-};
 
 
 struct Rod
index 0fd7fd077fa701e616c08266cc7b31123f7d64dd..ebd656070d6d9ee485c602eb78e87da8fcd20dba 100644 (file)
@@ -139,8 +139,6 @@ public:
 
   virtual void do_break_processing ();
   virtual Score_element *find_broken_piece (Line_of_score*) const;
-  /// generate rods & springs
-  virtual void do_space_processing ();
   virtual void discretionary_processing ();
   virtual void do_derived_mark ();
 
index b983b54716bc57f99b6a31866e76d8ddbb935971..0e4dfae387c731f9634c5e67467bbbbe40eedc58 100644 (file)
 #ifndef SCRIPT_HH
 #define SCRIPT_HH
 
-#include "item.hh"
-#include "drul-array.hh"
+#include "lily-guile.hh"
+#include "lily-proto.hh"
 
 /**
    Articulation marks (and the like) that are attached to notes/stems.
    Needs support from Staff_side for proper operation.  Staff_side
    handles the positioning.
 */
-class Script : public Item
+class Script
 {
 public:
-  static  Molecule get_molecule (Score_element*,Direction d);
-  Script (SCM);
+  static Molecule get_molecule (Score_element*,Direction d);
+  static void set_interface (Score_element*);
+  static bool  has_interface (Score_element*);
   static SCM brew_molecule (SCM);
   static SCM after_line_breaking (SCM);
 };
index 5c46dc3f8d4266da647d6a3b81e3565e2153bdd0..d01b6dbb5182685c930032c8f429921f006ed77a 100644 (file)
 
 #include "spanner.hh"
 
-class Separating_group_spanner : public Spanner
+class Separating_group_spanner
 {
 public:
   static void add_spacing_unit (Score_element*me, Item*);
-  Separating_group_spanner(SCM);
-protected:
-  VIRTUAL_COPY_CONS(Score_element);
-  virtual Array<Rod> get_rods () const;
+  static void set_interface (Score_element*);
+  static SCM set_spacing_rods (SCM);
 };
 
 #endif /* SEPARATING_GROUP_SPANNER_HH */
index 0cc519fdbb3120a7426c165445c5028bb098b128..4f317b148abd251d8868ce49d240910aa96e7a10 100644 (file)
@@ -73,7 +73,7 @@ struct Simple_spacer
   Simple_spacer ();
   
   void solve (Column_x_positions *) const;
-  void add_columns (Link_array<Paper_column>);
+  void add_columns (Link_array<Score_element>);
   void my_solve_linelen ();
   void my_solve_natural_len ();
   Real active_springs_stiffness () const;
index c9f6052d5a6a4d13507fb83d3e91d8740267fd08..83d0900834b88ba1306d92a903a0d1646b6daa24 100644 (file)
@@ -7,34 +7,28 @@
 #ifndef SLUR_HH
 #define SLUR_HH
 
-#include "spanner.hh"
+#include "lily-guile.hh"
+#include "lily-proto.hh"
 #include "rod.hh"
 
-/**
-  A #Bow# which tries to drape itself around the stems too.
- */
-class Slur : public Spanner
+class Slur
 {
 public:
-  Slur (SCM);
-  VIRTUAL_COPY_CONS(Score_element);
-
-  void add_column (Note_column*);
- static SCM brew_molecule (SCM);
-  
-  Array<Offset> get_encompass_offset_arr () const;
-  Bezier get_curve () const;
-
-  Direction get_default_dir () const;
+  static void add_column (Score_element*me,Score_element*col);
+  static SCM brew_molecule (SCM);
+  static void set_interface (Score_element*);
+  static bool  has_interface (Score_element*);
+  static Array<Offset> get_encompass_offset_arr (Score_element*me) ;
+  static Bezier get_curve (Score_element*me) ;
+  static Direction get_default_dir (Score_element*me) ;
   static SCM after_line_breaking (SCM);
-  Array<Rod> get_rods () const;
-  Offset get_attachment (Direction dir, Score_element**common) const;
-
+  static SCM set_spacing_rods (SCM);
 private:  
-  void de_uglyfy (Slur_bezier_bow* bb, Real default_height);
-  void set_extremities ();
-  void set_control_points ();
-  Offset encompass_offset (Score_element *col,Score_element**common)const;
+  static Offset get_attachment (Score_element*me,Direction dir, Score_element**common) ;
+  static void de_uglyfy (Score_element*me,Slur_bezier_bow* bb, Real default_height);
+  static void set_extremities (Score_element*me);
+  static void set_control_points (Score_element*me);
+  static Offset encompass_offset (Score_element*me,Score_element *col,Score_element**common);
 };
 
 #endif // SLUR_HH
diff --git a/lily/include/spaceable-element.hh b/lily/include/spaceable-element.hh
new file mode 100644 (file)
index 0000000..72a713e
--- /dev/null
@@ -0,0 +1,29 @@
+/*   
+  spaceable-element.hh -- declare Spaceable_element
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#ifndef SPACEABLE_ELEMENT_HH
+#define SPACEABLE_ELEMENT_HH
+
+#include "lily-guile.hh"
+#include "lily-proto.hh"
+
+
+struct Spaceable_element
+{
+  /// set a minimum distance
+  static void add_rod (Score_element*me, Score_element * to, Real distance);
+  static void add_spring (Score_element*me,Score_element * to, Real dist, Real strength);
+  static void set_interface (Score_element*);
+  static void remove_interface (Score_element*);
+  static SCM get_minimum_distances (Score_element*);
+  static SCM get_ideal_distances (Score_element*);
+};
+
+#endif /* SPACEABLE_ELEMENT_HH */
+
diff --git a/lily/include/spacing-engraver.hh b/lily/include/spacing-engraver.hh
deleted file mode 100644 (file)
index be6c44f..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*   
-  spacing-engraver.hh -- declare Spacing_engraver
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1999--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-  
- */
-
-#ifndef SPACING_ENGRAVER_HH
-#define SPACING_ENGRAVER_HH
-
-#include "engraver.hh"
-#include "pqueue.hh"
-
-struct Rhythmic_tuple
-{
-  Score_element_info info_;
-  Moment end_;
-  
-  Rhythmic_tuple ()
-    {
-    }
-  Rhythmic_tuple (Score_element_info i, Moment m )
-    {
-      info_ = i;
-      end_ = m;
-    }
-  static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &);  
-};
-
-/**
-   Acknowledge rhythmic elements, for initializing spacing fields in
-   the columns.
-
-   should be the  last one of the toplevel context
-*/
-class Spacing_engraver : public Engraver
-{
-  PQueue<Rhythmic_tuple> playing_durations_;
-  Array<Rhythmic_tuple> now_durations_;
-  Array<Rhythmic_tuple> stopped_durations_;
-
-  Spacing_spanner * spacing_p_;
-protected:
-  VIRTUAL_COPY_CONS(Translator);
-  virtual void acknowledge_element (Score_element_info);
-  virtual void do_post_move_processing ();
-  virtual void do_pre_move_processing ();
-  virtual void do_creation_processing ();
-  virtual void do_removal_processing ();
-public:
-  Spacing_engraver ();
-};
-
-#endif /* SPACING_ENGRAVER_HH */
-
index c6e4bdd7cdf628e757c06b62c6885558e33a4cf1..917b5fdc89df4fd1a1910ca6c741a6ba4b5c1448 100644 (file)
 
 #include "spanner.hh"
 
-class Spacing_spanner : public Spanner
+class Spacing_spanner
 {
 public:
-  Spacing_spanner (SCM);
-
-  VIRTUAL_COPY_CONS(Score_element);
-  Array<Spring> do_measure (Link_array<Paper_column>) const;
-
-protected:
-  virtual  Array<Spring> get_springs () const;
-
-  Real stem_dir_correction (Paper_column*,Paper_column*)  const;
-  Real default_bar_spacing (Paper_column*,Paper_column*,Moment)  const;
-  Real note_spacing (Paper_column*,Paper_column*,Moment)  const;
-  Real get_duration_space (Moment dur, Moment shortest) const;
+  static void set_interface (Score_element*);
+  static void do_measure (Score_element*,Link_array<Score_element>) ;
+
+  static SCM set_springs (SCM);
+  static Real stem_dir_correction (Score_element*,Score_element*,Score_element*)  ;
+  static Real default_bar_spacing (Score_element*,Score_element*,Score_element*,Moment)  ;
+  static Real note_spacing (Score_element*,Score_element*,Score_element*,Moment)  ;
+  static Real get_duration_space (Score_element*,Moment dur, Moment shortest) ;
 };
 
 #endif /* SPACING_SPANNER_HH */
index 4ce355dd4c26add27d83492a1bd06d88c5fafad5..dd5a61b21b06e6336a8575d856e0efb866658d40 100644 (file)
@@ -47,16 +47,11 @@ public:
   Real spanner_length () const;
 
   static int compare (Spanner * const &,Spanner * const &);
-  virtual Array<Rod> get_rods () const;
-  virtual Array<Spring> get_springs () const;  
   virtual Score_element* find_broken_piece (Line_of_score*) const;
   virtual void do_derived_mark ();
 protected:
   void set_my_columns ();
   VIRTUAL_COPY_CONS(Score_element);
-
-
-  virtual void do_space_processing ();
   virtual void do_break_processing ();
   virtual Line_of_score*line_l () const;
 };
index d3b9eb8a1e7d494ea37e832664d75749dcd74aec..8c3e6f769134ae948a2a75999012541879533032 100644 (file)
@@ -7,10 +7,8 @@
 #ifndef STEM_HH
 #define STEM_HH
 
-#include "item.hh"
-#include "array.hh"
-#include "moment.hh"
-#include "molecule.hh"
+#include "lily-proto.hh"
+#include "lily-guile.hh"
 #include "stem-info.hh"
 
 /**the rule attached to the ball.
 
   /// how many abbrev beam don't reach stem?
   int beam_gap_i_;
-
-
   
   */
-class Stem : public Item
+class Stem 
 {
 public:
   static SCM brew_molecule (SCM);
 
   /// log of the duration. Eg. 4 -> 16th note -> 2 flags
   static  int flag_i (Score_element*) ;
-
   static int beam_count (Score_element*,Direction) ;
   static void set_beaming (Score_element*,int,  Direction d);
   /** 
       don't print flag when in beam.
       our beam, for aligning abbrev flags
   */
-  static Beam * beam_l (Score_element*);
+  static Score_element * beam_l (Score_element*);
   static Score_element * first_head (Score_element*) ;
   static Drul_array<Score_element*> extremal_heads (Score_element*);
-
   static Score_element * support_head (Score_element*) ;
-  Stem (SCM);
-
+  
   /// ensure that this Stem also encompasses the Notehead #n#
   static void add_head (Score_element*me, Score_element*n);
-
   static Stem_info calc_stem_info (Score_element *) ;
-
   static Real chord_start_f (Score_element *) ;
   static Direction get_direction (Score_element*) ;
   static int type_i (Score_element *) ;
@@ -73,13 +64,10 @@ public:
   static Direction get_default_dir(Score_element *) ;
   static int get_center_distance(Score_element *,Direction) ;
   static int heads_i (Score_element *) ;
-
   static bool invisible_b(Score_element *) ;
  
   /// heads that the stem encompasses (positions)
   static Interval head_positions(Score_element *) ;
-
-
   static Real get_default_stem_end_position (Score_element*me) ;
   static void position_noteheads(Score_element*);
   static Real stem_end_position (Score_element*) ;
index b5c500c6f70ef809cea94fdda28cd0e883a4a0e2..121713d9e6328d5820b3c5e45b1d01cdc270f815 100644 (file)
 #ifndef SYSTEM_START_DELIMITER_HH
 #define SYSTEM_START_DELIMITER_HH
 
-#include "spanner.hh"
+#include "lily-guile.hh"
+#include "lily-proto.hh"
 
 /*
   Braces/brackets across staffs.
  */
-class System_start_delimiter : public Spanner
+class System_start_delimiter
 {
 public:
-  System_start_delimiter (SCM);
   static SCM brew_molecule (SCM);
   
-  VIRTUAL_COPY_CONS (Score_element);
-
+  static void set_interface (Score_element*me);
+  static bool has_interface (Score_element*);
   static SCM after_line_breaking (SCM);
   static void try_collapse (Score_element*);
-  
-  Molecule staff_bracket (Real) const;
-  Molecule staff_brace (Real) const;
-  Molecule simple_bar (Real) const;
+  static Molecule staff_bracket (Score_element*,Real) ;
+  static Molecule staff_brace (Score_element*,Real) ;
+  static Molecule simple_bar (Score_element*,Real) ;
 };
 
 #endif /* SYSTEM_START_DELIMITER_HH */
index bbee8fede5287c4027df346da56255b9b096a753..8dfab669bda63ac0921237636b1a5542eb86111e 100644 (file)
 #ifndef TIE_COLUMN_HH
 #define TIE_COLUMN_HH
 
-#include "spanner.hh"
+#include "lily-proto.hh"
+#include "lily-guile.hh"
 
-class Tie_column : public Spanner
+class Tie_column
 {
 public:
-  Tie_column (SCM s);
-  VIRTUAL_COPY_CONS (Score_element);
   static void set_interface (Score_element*me);
   static bool has_interface (Score_element*);
   static void add_tie (Score_element*me,Tie*);
-
   static SCM after_line_breaking (SCM);
   static void set_directions (Score_element*me);
 };
index ea1f5f97f3237929198aa6d6cbaef3ba735b2b7e..422a9fa375b33162a944323a4da3e4ed812f135d 100644 (file)
@@ -38,7 +38,7 @@ public:
   Bezier get_curve () const;
   Drul_array<Real> dy_f_drul_;
   Drul_array<Real> dx_f_drul_;
-  virtual Array<Rod> get_rods () const;
+  static SCM set_spacing_rods (SCM);
   Array<Offset> get_controls () const;
 };
 
index 910a8f8ef5531286bbf1d8f6eef95d0a5cecb87f..8b65565b943c539794d8f881ad93be02c68814c4 100644 (file)
@@ -17,7 +17,7 @@
 class Instrument_name_engraver : public Engraver
 {
   Item *text_;
-  System_start_delimiter * delim_ ;
+  Spanner * delim_ ;
 
   void create_text (SCM s);
 public:
@@ -84,10 +84,10 @@ Instrument_name_engraver::acknowledge_element (Score_element_info i)
        }
     }
 
-  if (dynamic_cast <System_start_delimiter*> (i.elem_l_)
+  if (System_start_delimiter::has_interface (i.elem_l_)
       && i.origin_trans_l_->daddy_trans_l_ == daddy_trans_l_)
     {
-      delim_ = dynamic_cast<System_start_delimiter*> (i.elem_l_);
+      delim_ = dynamic_cast<Spanner*> (i.elem_l_);
     }
 }
 
index 319c4028427cfa493f7e90123c3132d6a9bd96ca..4e995bfd775c9c5fd03bd8cab90d40cba06020f7 100644 (file)
@@ -31,15 +31,23 @@ Item::Item (Item const &s)
 }
 
 
-
 bool
-Item::breakable_b () const
+Item::breakable_b (Score_element*me) 
 {
-  if (original_l_ )
+  if (me->original_l_)
     return false;
+
+  if (!dynamic_cast<Item*>(me))
+    programming_error ("only items can be breakable.");
   
-  Item * i  =dynamic_cast<Item*> (parent_l (X_AXIS));
-  return (i) ?  i->breakable_b () : to_boolean (get_elt_property ("breakable"));
+  Item * i  =dynamic_cast<Item*> (me->parent_l (X_AXIS));
+  return (i) ?  Item::breakable_b (i) : to_boolean (me->get_elt_property ("breakable"));
+}
+
+Paper_column *
+Item::column_l () const
+{
+  return dynamic_cast<Item*> (parent_l (X_AXIS))->column_l ();
 }
 
 Line_of_score *
@@ -83,7 +91,7 @@ Item::discretionary_processing()
   if (broken_b ())
     return;
 
-  if (breakable_b ())
+  if (Item::breakable_b (this))
     copy_breakable_items();
 }
 
@@ -114,11 +122,6 @@ Item::find_prebroken_piece (Direction d) const
   return dynamic_cast<Item*> (broken_to_drul_[d]);
 }
 
-Paper_column *
-Item::column_l () const
-{
-  return dynamic_cast<Item*> (parent_l (X_AXIS))->column_l ();
-}
 
 Direction
 Item::break_status_dir () const
index 464212d3cbf4cc2f2a7a5947045d2f7034dfdb7c..ff641c0c240f18e274437c627e1f0551bf16f191 100644 (file)
@@ -133,7 +133,7 @@ Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
       Line_of_score *line_l = dynamic_cast <Line_of_score*> (clone());
       line_l->rank_i_ = i;
       //      line_l->set_immutable_elt_property ("rank", gh_int2scm( i));
-      Link_array<Paper_column> c (breaking[i].cols_);
+      Link_array<Score_element> c (breaking[i].cols_);
       pscore_l_->typeset_line (line_l);
       
       line_l->set_bound(LEFT,c[0]);
@@ -141,7 +141,7 @@ Line_of_score::break_into_pieces (Array<Column_x_positions> const &breaking)
       for (int j=0; j < c.size(); j++)
        {
          c[j]->translate_axis (breaking[i].config_[j],X_AXIS);
-         c[j]->line_l_ = line_l;
+         dynamic_cast<Paper_column*> (c[j])->line_l_ = line_l;
        }
       
       broken_into_l_arr_.push (line_l);
@@ -233,7 +233,12 @@ Line_of_score::pre_processing ()
   
   progress_indication ("\n" + _ ("Calculating column positions...") + " " );
   for (SCM s = get_elt_property ("all-elements"); gh_pair_p (s); s = gh_cdr (s))
-    unsmob_element (gh_car (s))->do_space_processing ();
+    {
+      Score_element * e = unsmob_element (gh_car (s));
+      SCM proc = e->get_elt_property ("spacing-procedure");
+      if (gh_procedure_p (proc))
+       gh_call1 (proc, e->self_scm_);
+    }
 }
 
 void
@@ -325,9 +330,8 @@ Line_of_score::broken_col_range (Item const*l, Item const*r) const
   
   while (gh_pair_p (s) && gh_car (s) != l->self_scm_)
     {
-      Paper_column *c
-       = dynamic_cast<Paper_column*> (unsmob_element (gh_car (s)));
-      if (c->breakable_b () && !c->line_l_)
+      Paper_column*c = dynamic_cast<Paper_column*> ( unsmob_element (gh_car (s)));
+      if (Item::breakable_b (c) && !c->line_l_)
        ret.push (c);
 
       s = gh_cdr  (s);
@@ -341,15 +345,15 @@ Line_of_score::broken_col_range (Item const*l, Item const*r) const
    Return all columns, but filter out any unused columns , since they might
    disrupt the spacing problem.
  */
-Link_array<Paper_column>
+Link_array<Score_element>
 Line_of_score::column_l_arr ()const
 {
-  Link_array<Paper_column> acs
-    = Pointer_group_interface__extract_elements (this, (Paper_column*) 0, "columns");
+  Link_array<Score_element> acs
+    = Pointer_group_interface__extract_elements (this, (Score_element*) 0, "columns");
   bool bfound = false;
   for (int i= acs.size (); i -- ; )
     {
-      bool brb = acs[i]->breakable_b();
+      bool brb = Item::breakable_b (acs[i]);
       bfound = bfound || brb;
 
       /*
@@ -357,7 +361,7 @@ Line_of_score::column_l_arr ()const
        seem empty. We need to retain breakable columns, in case
        someone forced a breakpoint.
       */
-      if (!bfound || !acs[i]->used_b ())
+      if (!bfound || !Paper_column::used_b (acs[i]))
        acs.del (i);
     }
   return acs;
index fe92bbafa3a0ed71a3cdb9ccaee2ec86c6236559..d5752455707c7b65adade9bd7fbaa1c9014343de 100644 (file)
@@ -33,9 +33,6 @@
 #include <libintl.h>
 #endif
 
-extern "C" {
-#include <kpathsea/kpathsea.h>
-}
 
 bool verbose_global_b = false;
 bool no_paper_global_b = false;
@@ -312,12 +309,6 @@ main (int argc, char **argv)
   setenv ("GUILE_INIT_SEGMENT_SIZE_1", "4194304", 0);
   setenv ("GUILE_MAX_SEGMENT_SIZE", "8388608", 0);
 
-  /*
-   initialize kpathsea
-   */
-  kpse_set_program_name(argv[0], NULL);
-  kpse_maketex_option("tfm", TRUE);
-
   oparser_global_p = new Getopt_long(argc, argv,theopts);
   while (Long_option_init const * opt = (*oparser_global_p)())
     {
index 84d5061e7f32646692abfb949562bbc9dc91642c..6a5d06ed7d975d7cc47188bf62f9b07f7ac5b7c2 100644 (file)
@@ -111,7 +111,8 @@ Multi_measure_rest_engraver::do_process_music ()
 
   if (busy_span_req_l_ && !mmrest_p_)
     {
-      mmrest_p_ = new Multi_measure_rest (get_property ("basicMultiMeasureRestProperties"));
+      mmrest_p_ = new Spanner (get_property ("basicMultiMeasureRestProperties"));
+
       Multi_measure_rest::set_interface (mmrest_p_);
       Staff_symbol_referencer::set_interface (mmrest_p_);
 
index 6d95336d3ac1f81fb812f4b1a368e0841992acee..ba2e2cbc243e25d97b6d4eb4443c6fef3aafca2a 100644 (file)
 #include "debug.hh"
 #include "paper-def.hh"
 #include "paper-column.hh" // urg
-#include "bar.hh"
 #include "lookup.hh"
 #include "rest.hh"
 #include "molecule.hh"
 #include "misc.hh"
 #include "group-interface.hh"
-#include "stem.hh"
+#include "spanner.hh"
 #include "staff-symbol-referencer.hh"
+
 void
 Multi_measure_rest::set_interface (Score_element*me)
 {
   me->set_elt_property ("columns", SCM_EOL);
 }
 
-Multi_measure_rest::Multi_measure_rest (SCM s)
-  : Spanner(s)
-{}
-
 /*
    [TODO]                                      17
  * variable-sized multi-measure rest symbol: |====| ??
@@ -151,19 +147,22 @@ Multi_measure_rest::add_column (Score_element*me,Item* c)
 }
 
 
-Array<Rod>
-Multi_measure_rest::get_rods () const
+MAKE_SCHEME_CALLBACK (Multi_measure_rest, set_spacing_rods);
+
+SCM
+Multi_measure_rest::set_spacing_rods (SCM smob)
 {
-  Array<Rod> a;
+  Score_element*me = unsmob_element (smob);
 
-  if (!(get_bound (LEFT) && get_bound (RIGHT)))
+  Spanner*sp = dynamic_cast<Spanner*> (me);
+  if (!(sp->get_bound (LEFT) && sp->get_bound (RIGHT)))
     {
       programming_error ("Multi_measure_rest::get_rods (): I am not spanned!");
-      return a;
+      return SCM_UNDEFINED;
     }
 
-  Item * l = get_bound (LEFT)->column_l ();
-  Item * r = get_bound (RIGHT)->column_l ();
+  Item * l = sp->get_bound (LEFT)->column_l ();
+  Item * r = sp->get_bound (RIGHT)->column_l ();
   Item * lb = l->find_prebroken_piece (RIGHT);
   Item * rb = r->find_prebroken_piece (LEFT);      
   
@@ -184,11 +183,10 @@ Multi_measure_rest::get_rods () const
          should do something more advanced.
         */
       rod.distance_f_ = l->extent (X_AXIS)[BIGGER] - r->extent (X_AXIS)[SMALLER]
-       + paper_l ()->get_var ("multi_measure_rest_x_minimum");
+       + me->paper_l ()->get_var ("multi_measure_rest_x_minimum");
   
-      a.push (rod);
+      rod.add_to_cols ();
     }
-  
-  return a;
+  return SCM_UNDEFINED;
 }
 
index 7616a119b559a2687129fe698b6f1887a630f1bd..473c0146636dbcff21dd5d5e5c27df7ffa40b342 100644 (file)
 #include "note-head.hh"
 
 bool
-Note_column::rest_b () const
+Note_column::rest_b (Score_element*me) 
 {
-  return unsmob_element (get_elt_property ("rest"));
+  return unsmob_element (me->get_elt_property ("rest"));
 }
 
 int
-Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2)
+Note_column::shift_compare (Score_element *const &p1, Score_element *const&p2)
 {
   SCM s1 = p1->get_elt_property ("horizontal-shift");
   SCM s2 = p2->get_elt_property ("horizontal-shift");
@@ -34,10 +34,9 @@ Note_column::shift_compare (Note_column *const &p1, Note_column*const&p2)
   return h1 - h2;
 }
 
-Note_column::Note_column( SCM s)
-  : Item (s)
+void
+Note_column::set_interface (Score_element* me)
 {
-  Score_element* me = this;
   me->set_elt_property ("note-heads", SCM_EOL);  
   me->set_interface (ly_symbol2scm ("note-column-interface"));
   
@@ -46,12 +45,11 @@ Note_column::Note_column( SCM s)
 }
 
 Item *
-Note_column::stem_l () const
+Note_column::stem_l (Score_element*me) 
 {
-  SCM s = get_elt_property ("stem");
+  SCM s = me->get_elt_property ("stem");
   return  dynamic_cast<Item*>(unsmob_element (s));
 }
-
   
 Slice
 Note_column::head_positions_interval(Score_element *me)
@@ -72,7 +70,7 @@ Note_column::head_positions_interval(Score_element *me)
 }
 
 Direction
-Note_column::static_dir (Score_element*  me)
+Note_column::dir (Score_element*  me)
 {
   Score_element *stem = unsmob_element (me->get_elt_property ("stem"));
   if (stem && Stem::has_interface (stem))
@@ -85,43 +83,36 @@ Note_column::static_dir (Score_element*  me)
 }
 
 
-Direction
-Note_column::dir () const
-{
-  return static_dir ((Score_element*) this);
-}
-
 void
-Note_column::set_stem (Score_element * stem_l)
+Note_column::set_stem (Score_element*me,Score_element * stem_l)
 {
-  set_elt_property ("stem", stem_l->self_scm_);
-
-  add_dependency (stem_l);
-  Axis_group_interface::add_element (this, stem_l);
+  me->set_elt_property ("stem", stem_l->self_scm_);
+  me->add_dependency (stem_l);
+  Axis_group_interface::add_element (me, stem_l);
 }
 
 void
-Note_column::add_head (Score_element *h)
+Note_column::add_head (Score_element*me,Score_element *h)
 {
   if (Rest::has_interface (h))
     {
-      this->set_elt_property ("rest", h->self_scm_);
+      me->set_elt_property ("rest", h->self_scm_);
     }
   else if (Note_head::has_interface (h))
     {
-      Pointer_group_interface gi (this, "note-heads");
+      Pointer_group_interface gi (me, "note-heads");
       gi.add_element (h);
     }
-  Axis_group_interface::add_element (this, h);
+  Axis_group_interface::add_element (me, h);
 }
 
 /**
   translate the rest symbols vertically by amount DY_I.
  */
 void
-Note_column::translate_rests (int dy_i)
+Note_column::translate_rests (Score_element*me,int dy_i)
 {
-  Score_element * r = unsmob_element (get_elt_property ("rest"));
+  Score_element * r = unsmob_element (me->get_elt_property ("rest"));
   if (r)
     {
       r->translate_axis (dy_i * Staff_symbol_referencer::staff_space (r)/2.0, Y_AXIS);
@@ -130,24 +121,24 @@ Note_column::translate_rests (int dy_i)
 
 
 void
-Note_column::set_dotcol (Score_element *d)
+Note_column::set_dotcol (Score_element*me,Score_element *d)
 {
-  Axis_group_interface::add_element (this, d);
+  Axis_group_interface::add_element (me, d);
 }
 
 
 
 Interval
-Note_column::rest_dim () const
+Note_column::rest_dim (Score_element*me) 
 {
-  Score_element * r = unsmob_element (get_elt_property ("rest"));
+  Score_element * r = unsmob_element (me->get_elt_property ("rest"));
   return r->extent (Y_AXIS);
 }
 
 Score_element*
-Note_column::first_head () const
+Note_column::first_head (Score_element*me) 
 {
-  Score_element * st = stem_l ();
+  Score_element * st = stem_l (me);
   return st?  Stem::first_head (st): 0; 
 }
 
index 579d028256cd97edede31f93edd79a1d2699252d..fcdc933f9aa39c0eb43d1a8d245719c0cf207a4e 100644 (file)
 #include "paper-score.hh"
 #include "debug.hh"
 #include "axis-group-interface.hh"
+#include "spaceable-element.hh"
 
 void
-Paper_column::add_rod (Paper_column * p, Real d)
+Paper_column::do_break_processing ()
 {
-  Direction dir =  Direction (sign (rank_i(p)  -rank_i (this)));
-  
-  if (dir != RIGHT)
-    {
-      programming_error ("Must set minimum distance LTOR.");
-      return;
-    }
-  
-  for (int i=0; i < minimal_dists_.size (); i++)
-    {
-      Column_rod &rod = minimal_dists_[i];
-      if (rod.other_l_ == p)
-       {
-         rod.distance_f_ = rod.distance_f_ >? d;
-         return ;
-       }
-    }
-
-  Column_rod cr;
-  cr.distance_f_ = d;
-  cr.other_l_ = p;
-
-  minimal_dists_.push (cr);
-}
-
-void
-Paper_column::add_spring (Paper_column * p, Real d, Real s)
-{
-  Direction dir =  Direction (sign (rank_i(p)  -rank_i (this)));
-  
-  if (dir != RIGHT)
-    {
-      programming_error ("Must set springs LTOR");
-      return;
-    }
-  
-  for (int i=0; i < springs_.size (); i++)
-    {
-      Column_spring &spring = springs_[i];
-      if (spring.other_l_ == p)
-       {
-         spring.distance_f_ = spring.distance_f_ >? d;
-         return ;
-       }
-    }
-
-  Column_spring cr;
-  cr.distance_f_ = d;
-  cr.strength_f_ = s;  
-  cr.other_l_ = p;
-
-  springs_.push (cr);
+  Spaceable_element::remove_interface(this);
+  Item::do_break_processing ();
 }
 
 int
@@ -91,19 +42,20 @@ Paper_column::Paper_column (SCM l)
 {
   Axis_group_interface::set_interface (this);
   Axis_group_interface::set_axes (this, X_AXIS, X_AXIS);
+  Spaceable_element::set_interface (this);
   set_elt_property ("bounded-by-me", SCM_EOL);
   line_l_=0;
   rank_i_ = -1;
 }
 
 Moment
-Paper_column::when_mom () const
+Paper_column::when_mom (Score_element*me)
 {
-  SCM m = get_elt_property ("when");
+  SCM m = me->get_elt_property ("when");
   Moment s (0);
-  if (SMOB_IS_TYPE_B(Moment, m))
+  if (unsmob_moment (m))
     {
-      s = *SMOB_TO_TYPE (Moment,m);
+      return *unsmob_moment (m);
     }
   return s;
 }
@@ -113,17 +65,17 @@ Paper_column::musical_b () const
 {
   SCM m = get_elt_property ("shortest-starter-duration");
   Moment s (0);
-  if (SMOB_IS_TYPE_B(Moment, m))
+  if (unsmob_moment (m))
     {
-      s = *SMOB_TO_TYPE (Moment,m);
+      s = *unsmob_moment (m);
     }
   return s != Moment(0);
 }
 
 bool
-Paper_column::used_b ()const
+Paper_column::used_b (Score_element*me )
 {
-  return gh_pair_p (get_elt_property ("elements")) ||  breakable_b ()
-    || gh_pair_p (get_elt_property ("bounded-by-me"))
+  return gh_pair_p (me->get_elt_property ("elements")) ||  Item::breakable_b (me)
+    || gh_pair_p (me->get_elt_property ("bounded-by-me"))
     ;
 }
index 601ce748cb8b96da88836fc724e833ff49bfb8b4..86797de758a08224a8267f47cc5d7dba0959b66e 100644 (file)
@@ -79,7 +79,7 @@ Paper_score::process ()
   /*
     Be sure to set breakability on first & last column.
    */
-  Link_array<Paper_column> pc (line_l_->column_l_arr ());
+  Link_array<Score_element> pc (line_l_->column_l_arr ());
   
   pc[0]->set_elt_property ("breakable", SCM_BOOL_T);
   pc.top ()->set_elt_property ("breakable", SCM_BOOL_T);
index fc310aef059fcb8b2e016bc245a3415485c62945..e748b88c012a6421a7c939d0b8ed1038fa0feecc 100644 (file)
@@ -16,7 +16,7 @@ class Rest_collision_engraver : public Engraver
 {
   Item* rest_collision_p_;
 
-  Link_array<Note_column> note_column_l_arr_;
+  Link_array<Score_element> note_column_l_arr_;
 protected:
   virtual void acknowledge_element (Score_element_info);
   virtual void process_acknowledged ();
@@ -50,8 +50,8 @@ Rest_collision_engraver::process_acknowledged ()
 void
 Rest_collision_engraver::acknowledge_element (Score_element_info i)
 {
-  if (dynamic_cast<Note_column *> (i.elem_l_))
-    note_column_l_arr_.push (dynamic_cast<Note_column *> (i.elem_l_));
+  if (Note_column::has_interface (i.elem_l_))
+    note_column_l_arr_.push (i.elem_l_);
 }
 
 void
index 7a26dee1a984cfa2bd0bf97cea38a0d184bfd58a..9d86cbb81bbb5ceb96a92ecd298b2bbb2cba35f7 100644 (file)
@@ -41,7 +41,7 @@ Rest_collision::force_shift_callback (Score_element *them, Axis a)
 }
 
 void
-Rest_collision::add_column (Score_element*me,Note_column *p)
+Rest_collision::add_column (Score_element*me,Score_element *p)
 {
   me->add_dependency (p);
   Pointer_group_interface gi (me);  
@@ -72,16 +72,16 @@ Rest_collision::do_shift (Score_element *me, SCM elts)
   /*
     ugh. -> score  elt type
    */
-  Link_array<Note_column> rests;
-  Link_array<Note_column> notes;
+  Link_array<Score_element> rests;
+  Link_array<Score_element> notes;
 
   for (SCM s = elts; gh_pair_p (s); s = gh_cdr (s))
     {
       Score_element * e = unsmob_element (gh_car (s));
       if (e && unsmob_element (e->get_elt_property ("rest")))
-       rests.push (dynamic_cast<Note_column*> (e));
+       rests.push (e);
       else
-       notes.push (dynamic_cast<Note_column*> (e));
+       notes.push (e);
     }
 
   
@@ -147,8 +147,8 @@ Rest_collision::do_shift (Score_element *me, SCM elts)
       int dy = display_count > 2 ? 6 : 4;
       if (display_count > 1)
        {
-         rests[0]->translate_rests (dy);       
-         rests[1]->translate_rests (-dy);
+         Note_column::translate_rests (rests[0],dy);   
+         Note_column::translate_rests (rests[1], -dy);
        }
     }
   // meisjes met jongetjes
@@ -162,12 +162,12 @@ Rest_collision::do_shift (Score_element *me, SCM elts)
        {
          warning (_("too many notes for rest collision"));
        }
-      Note_column * rcol = rests[0];
+      Score_element * rcol = rests[0];
 
       // try to be opposite of noteheads. 
-      Direction dir = - notes[0]->dir();
+      Direction dir = - Note_column::dir (notes[0]);
 
-      Interval restdim = rcol->rest_dim ();
+      Interval restdim = Note_column::rest_dim (rcol);
       if (restdim.empty_b ())
        return SCM_UNDEFINED;
       
@@ -208,7 +208,7 @@ Rest_collision::do_shift (Score_element *me, SCM elts)
       if (discrete_dist < stafflines+1)
        discrete_dist = int (ceil (discrete_dist / 2.0)* 2.0);
       
-      rcol->translate_rests (dir * discrete_dist);
+      Note_column::translate_rests (rcol,dir * discrete_dist);
     }
   return SCM_UNDEFINED;
 }
index b83520535c0df17892c9450a1201c8232c63a739..82c02d9a4a7bced7fbf3f9f6be01cff20a1dad53 100644 (file)
@@ -19,9 +19,9 @@
 class Rhythmic_column_engraver :public Engraver
 {
   Link_array<Score_element> rhead_l_arr_;
-  Link_array<Slur> grace_slur_endings_;
+  Link_array<Score_element> grace_slur_endings_;
   Score_element * stem_l_;
-  Note_column *ncol_p_;
+  Score_element *ncol_p_;
   Score_element *dotcol_l_;
 
 protected:
@@ -52,14 +52,15 @@ Rhythmic_column_engraver::process_acknowledged ()
     {
       if (!ncol_p_)
        {
-         ncol_p_ = new Note_column (get_property("basicNoteColumnProperties"));
+         ncol_p_ = new Item (get_property("basicNoteColumnProperties"));
+         Note_column::set_interface (ncol_p_);
          announce_element (Score_element_info (ncol_p_, 0));
        }
 
       for (int i=0; i < rhead_l_arr_.size (); i++)
        {
          if (!rhead_l_arr_[i]->parent_l(X_AXIS))
-           ncol_p_->add_head (rhead_l_arr_[i]);
+           Note_column::add_head (ncol_p_, rhead_l_arr_[i]);
        }
       rhead_l_arr_.set_size (0);
     }
@@ -70,13 +71,13 @@ Rhythmic_column_engraver::process_acknowledged ()
       if (dotcol_l_
          && !dotcol_l_->parent_l (X_AXIS))
        {
-         ncol_p_->set_dotcol (dotcol_l_);
+         Note_column::set_dotcol (ncol_p_, dotcol_l_);
        }
 
       if (stem_l_
          && !stem_l_->parent_l(X_AXIS))
        {
-         ncol_p_->set_stem (stem_l_);
+         Note_column::set_stem (ncol_p_, stem_l_);
          stem_l_ = 0;
        }
 
@@ -85,7 +86,7 @@ Rhythmic_column_engraver::process_acknowledged ()
 
       if (!wegrace)
        for (int i=0; i < grace_slur_endings_.size(); i++)
-         grace_slur_endings_[i]->add_column (ncol_p_);
+         Slur::add_column (grace_slur_endings_[i], ncol_p_);
       grace_slur_endings_.clear ();
     }
 }
@@ -96,7 +97,7 @@ Rhythmic_column_engraver::acknowledge_element (Score_element_info i)
   SCM wg = get_property ("weAreGraceContext");
   bool wegrace = to_boolean (wg);
   if (wegrace != to_boolean (i.elem_l_->get_elt_property ("grace"))
-    && !dynamic_cast<Slur*> (i.elem_l_))
+    && !Slur::has_interface (i.elem_l_))
     return ;
   
   Item * item =  dynamic_cast <Item *> (i.elem_l_);
@@ -112,14 +113,14 @@ Rhythmic_column_engraver::acknowledge_element (Score_element_info i)
     {
       dotcol_l_ = item;
     }
-  else if (Slur *s = dynamic_cast<Slur*> (i.elem_l_))
+  else if (Slur::has_interface (i.elem_l_))
     {
       /*
        end slurs starting on grace notes
        */
       
-      if (to_boolean (s->get_elt_property ("grace")))
-       grace_slur_endings_.push (s);
+      if (to_boolean (i.elem_l_->get_elt_property ("grace")))
+       grace_slur_endings_.push (i.elem_l_);
    }
 }
 
index 9c8cb00b501f354aa2bff6b427c8cb9380d331fd..63006674fce24236e9fbea65d6eca5ddb9d51984 100644 (file)
@@ -16,6 +16,7 @@
 #include "paper-score.hh"
 #include "stem.hh"
 #include "staff-symbol-referencer.hh"
+#include "item.hh"
 
 
 Item*
index 15b4c7a8085bb13eb097178375d042e2aff5d622..621fd15de231fb93078ed9981d30809c74a67eae 100644 (file)
@@ -10,8 +10,7 @@
 #include "paper-column.hh"
 #include "debug.hh"
 #include "dimensions.hh"
-#include "separation-item.hh"
-
+#include "spaceable-element.hh"
 
 Rod::Rod ()
 {
@@ -20,11 +19,6 @@ Rod::Rod ()
 }
 
 
-Column_rod::Column_rod ()
-{
-  distance_f_ = 0;
-  other_l_ = 0;
-}
 
 void
 Rod::columnize ()
@@ -43,7 +37,8 @@ Rod::add_to_cols ()
 {
   columnize();
   if (item_l_drul_[LEFT] != item_l_drul_[RIGHT])
-    dynamic_cast<Paper_column*> (item_l_drul_[LEFT])->
-      add_rod(dynamic_cast<Paper_column*>(item_l_drul_[RIGHT]), distance_f_ );
+    Spaceable_element::add_rod (item_l_drul_[LEFT],
+                               item_l_drul_[RIGHT],
+                               distance_f_ );
 }
 
index 5b17ffbbd394104dc31ea29d6fada6f68f35b5c2..47ca5c9eea8f0659b090a9a8bbb520ad539630af 100644 (file)
@@ -265,10 +265,6 @@ Score_element::do_break_processing()
 {
 }
 
-void
-Score_element::do_space_processing ()
-{
-}
 
 void
 Score_element::do_add_processing()
index 842a896fb7faacd69d3c68e45fa4557d1c5aeea2..1e35503f42e88de3404ffff1f5101753e9186a3c 100644 (file)
@@ -195,7 +195,7 @@ Score_engraver::set_columns (Paper_column *new_command_l,
       if (*current[i])
        {
          scoreline_l_->add_column ((*current[i]));
-         if (!(*current[i])->used_b())
+         if (!Paper_column::used_b (*current[i]))
            {
              (*current[i])->suicide ();
              *current[i]  =0;
index 47c37cfcaae516660fc7bd62825c401bde7af358..02676f0145213d268214556ca4a6689aa0b75090 100644 (file)
@@ -60,7 +60,7 @@ Script_column_engraver::acknowledge_element( Score_element_info inf)
     {
       Item *thing = dynamic_cast<Item*> (inf.elem_l_);
       if (thing
-         && !thing->breakable_b ()
+         && !Item::breakable_b (thing)
          && Side_position::get_axis (inf.elem_l_) == Y_AXIS)
        {
          script_l_arr_.push (thing);
index 2f433d9d3776169796b765f3ee00298d1caa27d0..effd5b7123394ddb841d0f43245ba9102d21a44c 100644 (file)
 #include "musical-request.hh"
 #include "stem.hh"
 #include "rhythmic-head.hh"
-
-
 #include "engraver.hh"
 
 class Script_engraver : public Engraver {
-  Link_array<Script> script_p_arr_;
+  Link_array<Score_element> script_p_arr_;
   Link_array<Articulation_req> script_req_l_arr_;
 
 public:
@@ -69,7 +67,8 @@ Script_engraver::do_process_music()
          continue;
        }
       // todo -> use result of articulation-to-scriptdef directly as basic prop list.
-      Script *p =new Script (get_property ("basicScriptProperties"));
+      Score_element *p =new Item (get_property ("basicScriptProperties"));
+      Script::set_interface (p);
 
       p->add_offset_callback (Side_position::centered_on_parent, X_AXIS);
       
@@ -157,8 +156,8 @@ Script_engraver::do_pre_move_processing()
 {
   for (int i=0; i < script_p_arr_.size(); i++) 
     {
-      Script * sc = script_p_arr_[i];
-      if (to_boolean (sc->remove_elt_property ("staff-support")))
+      Score_element * sc = script_p_arr_[i];
+      if (to_boolean (sc->get_elt_property ("staff-support")))
        {
          Side_position::add_staff_support (sc);
        }
index c4dcc30cd401cfe2c03a4122d1bc03dfb17dd15e..c4b3e004dee3489bf0da50f3b7a37320598e612e 100644 (file)
 #include "lookup.hh"
 #include "side-position-interface.hh"
 #include "paper-def.hh"
-
-
-Script ::Script (SCM s)
-  : Item (s)
-{
-}
+#include "item.hh"
 
 Molecule
 Script::get_molecule(Score_element * me, Direction d)
@@ -41,8 +36,6 @@ Script::get_molecule(Score_element * me, Direction d)
   return Molecule ();
 }
 
-
-
 MAKE_SCHEME_CALLBACK(Script,after_line_breaking);
 SCM
 Script::after_line_breaking (SCM smob)
@@ -55,7 +48,6 @@ Script::after_line_breaking (SCM smob)
   return SCM_UNDEFINED;
 }
 
-
 MAKE_SCHEME_CALLBACK(Script,brew_molecule);
 
 SCM
@@ -70,5 +62,14 @@ Script::brew_molecule (SCM smob)
   return get_molecule (me, dir).create_scheme();
 }
 
+bool
+Script::has_interface (Score_element*me)
+{
+  return me->has_interface ("script-interface");
+}
 
-
+void
+Script::set_interface (Score_element*me)
+{
+  return me->set_interface ("script-interface");
+}
index 6b5c2302a82d96992e443e587bb8022ab18e2345..cc6f70c219ac5450617da42981eb1e009d08677b 100644 (file)
@@ -14,8 +14,8 @@
 #include "dimensions.hh"
 #include "group-interface.hh"
 
-static Rod
-make_rod (Item *l, Item *r)
+static void
+do_rod (Item *l, Item *r)
 {
   Rod rod;
 
@@ -31,16 +31,16 @@ make_rod (Item *l, Item *r)
     rod.distance_f_ = li[RIGHT] - ri[LEFT];
 
   rod.columnize ();
-  return rod;
+  rod.add_to_cols ();
 }
   
-
-Array<Rod>
-Separating_group_spanner::get_rods () const
+MAKE_SCHEME_CALLBACK(Separating_group_spanner,set_spacing_rods);
+SCM
+Separating_group_spanner::set_spacing_rods (SCM smob)
 {
-  Array<Rod> a;
+  Score_element*me = unsmob_element (smob);
   
-  for (SCM s = get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s))
+  for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s) && gh_pair_p (gh_cdr (s)); s = gh_cdr (s))
     {
       /*
        Order of elements is reversed!
@@ -60,29 +60,28 @@ Separating_group_spanner::get_rods () const
       Item *rb
        = dynamic_cast<Item*>(r->find_prebroken_piece (LEFT));
       
-      a.push (make_rod(l,  r));
+      do_rod(l,  r);
       if (lb)
        {
-         Rod rod(make_rod (lb, r));
-         a.push (rod);
+         do_rod (lb, r);
        }
       
       if (rb)
        {
-         a.push (make_rod (l, rb));
+         do_rod (l, rb);
        }
       
       if (lb && rb)
        {
-         Rod rod(make_rod (lb, rb));
-         a.push (rod);
+         do_rod (lb, rb);
+
        }
     }
 
   /*
     We've done our job, so we get lost. 
    */
-  for (SCM s = get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
+  for (SCM s = me->get_elt_property ("elements"); gh_pair_p (s); s = gh_cdr (s))
     {
       Item * it =dynamic_cast<Item*>(unsmob_element (gh_car (s)));
       if (it && it->broken_b ())
@@ -92,10 +91,8 @@ Separating_group_spanner::get_rods () const
        }
       it->suicide ();
     }
-  
-  ((Separating_group_spanner *)this)->suicide ();
-  
-  return a;
+  me->suicide ();
+  return SCM_UNDEFINED ;
 }
 
 void
@@ -106,8 +103,8 @@ Separating_group_spanner::add_spacing_unit (Score_element* me ,Item*i)
 }
 
 
-Separating_group_spanner::Separating_group_spanner (SCM s)
-  : Spanner (s)  
+void
+Separating_group_spanner::set_interface (Score_element*me)
 {
-  set_elt_property ("elements", SCM_EOL);
+  me->set_elt_property ("elements", SCM_EOL);
 }
index 96749f04102a1c2a41668a500de9196c3da9dca2..7cc7ad681a3f0438045b1f932a8e5998a1a6ec4b 100644 (file)
@@ -18,7 +18,7 @@ class Separating_line_group_engraver : public Engraver
 protected:
   Item * break_malt_p_;
   Item * nobreak_malt_p_;
-  Separating_group_spanner * sep_span_p_;
+  Spanner * sep_span_p_;
   
   virtual void acknowledge_element (Score_element_info);
   virtual void do_creation_processing ();
@@ -39,7 +39,8 @@ Separating_line_group_engraver::Separating_line_group_engraver ()
 void
 Separating_line_group_engraver::do_creation_processing ()
 {
-  sep_span_p_ = new Separating_group_spanner (get_property ("basicSeparatingGroupSpannerProperties"));
+  sep_span_p_ = new Spanner (get_property ("basicSeparatingGroupSpannerProperties"));
+  Separating_group_spanner::set_interface (sep_span_p_);
   announce_element (Score_element_info (sep_span_p_, 0));
   sep_span_p_->set_bound (LEFT, unsmob_element (get_property ("currentCommandColumn")));
 }
@@ -58,7 +59,7 @@ Separating_line_group_engraver::acknowledge_element (Score_element_info i)
   Item * it = dynamic_cast <Item *> (i.elem_l_);
   if (it && !it->parent_l (X_AXIS))
     {
-      bool ib =it->breakable_b ();
+      bool ib =Item::breakable_b (it);
       Item *&p_ref_ (ib ? break_malt_p_
                              : nobreak_malt_p_);
 
index e11b6c1dd6cb5f26abde9701a10eefa1762185d7..36971396df3c7229b3a83ae974a157992818ff9a 100644 (file)
@@ -19,6 +19,7 @@
 #include "rod.hh"
 #include "warn.hh"
 #include "column-x-positions.hh"
+#include "spaceable-element.hh"
 #include "dimensions.hh"
 
 Simple_spacer::Simple_spacer ()
@@ -164,26 +165,27 @@ Simple_spacer::my_solve_natural_len ()
 }
 
 void
-Simple_spacer::add_columns (Link_array<Paper_column> cols)
+Simple_spacer::add_columns (Link_array<Score_element> cols)
 {
   for (int i=0; i < cols.size () - 1; i++)
     {
-      Paper_column * c = cols [i];
-      Column_spring *to_next = 0;
-      for (int j =0; !to_next && j < c->springs_.size( ); j++)
+      SCM spring_params = SCM_UNDEFINED;
+      for (SCM s = Spaceable_element::get_ideal_distances (cols[i]);
+          spring_params == SCM_UNDEFINED && gh_pair_p (s);
+          s = gh_cdr (s))
        {
-         Column_spring &sp = c->springs_ [j];
-         if (sp.other_l_ != cols[i+1])
+         Score_element *other = unsmob_element (gh_caar (s));
+         if (other != cols[i+1])
            continue;
 
-         to_next = &sp;
+         spring_params = gh_cdar (s);
        }
 
       Spring_description desc;
-      if (to_next)
+      if (spring_params != SCM_UNDEFINED)
        {
-         desc.hooke_f_ = to_next->strength_f_;
-         desc.ideal_f_ = to_next->distance_f_;
+         desc.ideal_f_ = gh_scm2double (gh_car (spring_params));
+         desc.hooke_f_ = gh_scm2double (gh_cdr (spring_params));
        }
       else
        {
@@ -204,13 +206,14 @@ Simple_spacer::add_columns (Link_array<Paper_column> cols)
   
   for (int i=0; i < cols.size () - 1; i++)
     {
-      Array<Column_rod> * rods = &cols [i]->minimal_dists_;
-      for (int j =0; j < rods->size( ); j++)
+      for (SCM s = Spaceable_element::get_minimum_distances (cols[i]);
+          gh_pair_p (s); s = gh_cdr (s))
        {
-         int oi = cols.find_i (rods->elem (j).other_l_ );
+         Score_element * other = unsmob_element (gh_caar (s));
+         int oi = cols.find_i (other);
          if (oi >= 0)
            {
-             add_rod (i, oi, rods->elem (j).distance_f_);
+             add_rod (i, oi, gh_scm2double (gh_cdar (s)));
            }
        }
     }
index 7987187335586ec8c050ca8b8301939f5808d101..8cd767edcd94f619e5e3a0e00148aff526a4c0c3 100644 (file)
 #include "note-column.hh"
 #include "translator-group.hh"
 #include "engraver.hh"
+#include "spanner.hh"
 
 class Slur_engraver :public Engraver {
   Link_array<Span_req> requests_arr_;
   Link_array<Span_req> new_slur_req_l_arr_;
-  Link_array<Slur> slur_l_stack_;
-  Link_array<Slur> end_slur_l_arr_;
+  Link_array<Score_element> slur_l_stack_;
+  Link_array<Score_element> end_slur_l_arr_;
 
   void set_melisma (bool);
 protected:
@@ -56,13 +57,13 @@ Slur_engraver::set_melisma (bool m)
 void
 Slur_engraver::acknowledge_element (Score_element_info info)
 {
-  if (dynamic_cast<Note_column *> (info.elem_l_))
+  if (Note_column::has_interface (info.elem_l_))
     {
-      Note_column *col_l =dynamic_cast<Note_column *> (info.elem_l_) ;// ugh
+      Score_element *e =info.elem_l_;
       for (int i = 0; i < slur_l_stack_.size (); i++)
-       slur_l_stack_[i]->add_column (col_l);
+       Slur::add_column (slur_l_stack_[i], e);
       for (int i = 0; i < end_slur_l_arr_.size (); i++)
-       end_slur_l_arr_[i]->add_column (col_l);
+       Slur::add_column (end_slur_l_arr_[i], e);
     }
 }
 
@@ -86,7 +87,7 @@ Slur_engraver::do_removal_processing ()
 void
 Slur_engraver::do_process_music ()
 {
-  Array<Slur*> start_slur_l_arr_;
+  Link_array<Score_element> start_slur_l_arr_;
   for (int i=0; i< new_slur_req_l_arr_.size (); i++)
     {
       Span_req* slur_req_l = new_slur_req_l_arr_[i];
@@ -98,7 +99,7 @@ Slur_engraver::do_process_music ()
            slur_req_l->warning (_f ("can't find both ends of %s", _ ("slur")));
          else
            {
-             Slur* slur = slur_l_stack_.pop ();
+             Score_element* slur = slur_l_stack_.pop ();
              SCM s = get_property ("slurEndAttachment");
              if (gh_symbol_p (s))
                {
@@ -112,7 +113,8 @@ Slur_engraver::do_process_music ()
        {
          // push a new slur onto stack.
          // (use temp. array to wait for all slur STOPs)
-         Slur* slur = new Slur (get_property ("basicSlurProperties"));
+         Score_element* slur = new Spanner (get_property ("basicSlurProperties"));
+         Slur::set_interface (slur);
          SCM s = get_property ("slurBeginAttachment");
          if (gh_symbol_p (s))
            {
index 5b702323bd3e72460db1da68378b5aa0ad4885cf..9b751ab6e87f75268f45b611d30e9ce2ad31cd23 100644 (file)
 #include "main.hh"
 #include "group-interface.hh"
 #include "staff-symbol-referencer.hh"
+#include "spanner.hh"
 
-Slur::Slur (SCM s)
-  : Spanner (s)
+
+void
+Slur::set_interface (Score_element*me)
 {
-  set_elt_property ("attachment", gh_cons (SCM_BOOL_F, SCM_BOOL_F));
-  set_elt_property ("note-columns", SCM_EOL);
-  set_elt_property ("control-points", SCM_EOL);
+  me-> set_elt_property ("attachment", gh_cons (SCM_BOOL_F, SCM_BOOL_F));
+  me->set_elt_property ("note-columns", SCM_EOL);
+  me->set_elt_property ("control-points", SCM_EOL);
+  me->set_interface (ly_symbol2scm ("slur-interface"));
 }
 
 void
-Slur::add_column (Note_column*n)
+Slur::add_column (Score_element*me, Score_element*n)
 {
   if (!gh_pair_p (n->get_elt_property ("note-heads")))
     warning (_ ("Putting slur over rest.  Ignoring."));
   else
     {
-      Pointer_group_interface (this, "note-columns").add_element (n);
-      add_dependency (n);
+      Pointer_group_interface (me, "note-columns").add_element (n);
+      me->add_dependency (n);
     }
 
-  add_bound_item (this, n);
+  add_bound_item (dynamic_cast<Spanner*> (me), dynamic_cast<Item*>(n));
 }
 
 void
-Slur::de_uglyfy (Slur_bezier_bow* bb, Real default_height)
+Slur::de_uglyfy (Score_element*me, Slur_bezier_bow* bb, Real default_height)
 {
   Real length = bb->curve_.control_[3][X_AXIS] ; 
   Real ff = bb->fit_factor ();
@@ -66,9 +69,9 @@ Slur::de_uglyfy (Slur_bezier_bow* bb, Real default_height)
       Real h = bb->curve_.control_[i][Y_AXIS] * ff / length;
 
       Real f = default_height / length;
-      Real c1 = paper_l ()->get_var ("bezier_control1");
-      Real c2 = paper_l ()->get_var ("bezier_control2");
-      Real c3 = paper_l ()->get_var ("bezier_control3");
+      Real c1 = me->paper_l ()->get_var ("bezier_control1");
+      Real c2 = me->paper_l ()->get_var ("bezier_control2");
+      Real c3 = me->paper_l ()->get_var ("bezier_control3");
       if (h > c1 * f)
        {
          h = c1 * f; 
@@ -85,15 +88,15 @@ Slur::de_uglyfy (Slur_bezier_bow* bb, Real default_height)
 }
 
 Direction
-Slur::get_default_dir () const
+Slur::get_default_dir (Score_element*me) 
 {
-  Link_array<Note_column> encompass_arr =
-    Pointer_group_interface__extract_elements (this, (Note_column*)0, "note-columns");
+  Link_array<Score_element> encompass_arr =
+    Pointer_group_interface__extract_elements (me, (Score_element*)0, "note-columns");
   
   Direction d = DOWN;
   for (int i=0; i < encompass_arr.size (); i ++) 
     {
-      if (encompass_arr[i]->dir () < 0) 
+      if (Note_column::dir (encompass_arr[i]) < 0) 
        {
          d = UP;
          break;
@@ -107,13 +110,14 @@ Slur::get_default_dir () const
 
 
 Offset
-Slur::encompass_offset (Score_element* col,
-                       Score_element **common) const
+Slur::encompass_offset (Score_element*me,
+                       Score_element* col,
+                       Score_element **common) 
 {
   Offset o;
   Score_element* stem_l = unsmob_element (col->get_elt_property ("stem"));
   
-  Direction dir = Directional_element_interface (this).get ();
+  Direction dir = Directional_element_interface (me).get ();
   
   if (!stem_l)
     {
@@ -144,7 +148,7 @@ Slur::encompass_offset (Score_element* col,
   /*
    leave a gap: slur mustn't touch head/stem
    */
-  o[Y_AXIS] += dir * paper_l ()->get_var ("slur_y_free");
+  o[Y_AXIS] += dir * me->paper_l ()->get_var ("slur_y_free");
   return o;
 }
 
@@ -154,33 +158,32 @@ SCM
 Slur::after_line_breaking (SCM smob)
 {
   Score_element *me = unsmob_element (smob);
-  Slur * sl = dynamic_cast<Slur*>(me);
-  sl->set_extremities ();
-  sl->set_control_points ();
+  set_extremities (me);
+  set_control_points (me);
   return SCM_UNDEFINED;
 } 
 
 void
-Slur::set_extremities ()
+Slur::set_extremities (Score_element*me)
 {
-  if (!Directional_element_interface (this).get ())
-    Directional_element_interface (this).set (get_default_dir ());
+  if (!Directional_element_interface (me).get ())
+    Directional_element_interface (me).set (get_default_dir (me));
 
   Direction dir = LEFT;
   do 
     {
-      if (!gh_symbol_p (index_cell (get_elt_property ("attachment"), dir)))
+      if (!gh_symbol_p (index_cell (me->get_elt_property ("attachment"), dir)))
        {
          
          // for (SCM s = get_elt_property ("slur-extremity-rules"); s != SCM_EOL; s = gh_cdr (s))
          for (SCM s = scm_eval (ly_symbol2scm ("slur-extremity-rules"));
               s != SCM_EOL; s = gh_cdr (s))
            {
-             SCM r = gh_call2 (gh_caar (s), this->self_scm_,
+             SCM r = gh_call2 (gh_caar (s), me->self_scm_,
                                 gh_int2scm ((int)dir));
              if (r != SCM_BOOL_F)
                {
-                 index_set_cell (get_elt_property ("attachment"), dir,
+                 index_set_cell (me->get_elt_property ("attachment"), dir,
                                  gh_cdar (s));
                  break;
                }
@@ -191,22 +194,24 @@ Slur::set_extremities ()
 }
 
 Offset
-Slur::get_attachment (Direction dir,
-                     Score_element **common) const
+Slur::get_attachment (Score_element*me,Direction dir,
+                     Score_element **common) 
 {
-  SCM s = get_elt_property ("attachment");
+  Spanner*sp = dynamic_cast<Spanner*>(me);
+  SCM s = me->get_elt_property ("attachment");
   SCM a = dir == LEFT ? gh_car (s) : gh_cdr (s);
   String str = ly_symbol2string (a);
-  Real ss = Staff_symbol_referencer::staff_space ((Score_element*)this);
+  Real ss = Staff_symbol_referencer::staff_space ((Score_element*)me);
   Real hs = ss / 2.0;
   Offset o;
 
-  
-  if (Note_column* n = dynamic_cast<Note_column*> (get_bound (dir)))
+
+  if (Note_column::has_interface (sp->get_bound (dir)))
     {
-      if (n->stem_l ())
+      Score_element * n =sp->get_bound (dir);
+      if (Score_element*st = Note_column::stem_l (n))
        {
-         Score_element*st = n->stem_l();
+
          if (str == "head")
            {
              o = Offset (0, Stem::chord_start_f (st ));
@@ -214,7 +219,7 @@ Slur::get_attachment (Direction dir,
                Default position is centered in X, on outer side of head Y
               */
              o += Offset (0.5 * n->extent (X_AXIS).length (),
-                          0.5 * ss * Directional_element_interface (this).get ());
+                          0.5 * ss * Directional_element_interface (me).get ());
            }
          else if (str == "alongside-stem")
            {
@@ -224,7 +229,7 @@ Slur::get_attachment (Direction dir,
               */
              o += Offset (n->extent (X_AXIS).length ()
                           * (1 + Stem::get_direction (st )),
-                          0.5 * ss * Directional_element_interface (this).get ());
+                          0.5 * ss * Directional_element_interface (me).get ());
            }
          else if (str == "stem")
            {
@@ -243,7 +248,7 @@ Slur::get_attachment (Direction dir,
              SCM other_a = dir == LEFT ? gh_cdr (s) : gh_car (s);
              if (ly_symbol2string (other_a) != "loose-end")
                {
-                 o = Offset (0, get_attachment (-dir, common)[Y_AXIS]);
+                 o = Offset (0, get_attachment (me, -dir, common)[Y_AXIS]);
                }
            }
 
@@ -251,7 +256,7 @@ Slur::get_attachment (Direction dir,
          SCM l = scm_assoc
            (scm_listify (a,
                          gh_int2scm (Stem::get_direction (st ) * dir),
-                         gh_int2scm (Directional_element_interface (this).get () * dir),
+                         gh_int2scm (Directional_element_interface (me).get () * dir),
                          SCM_UNDEFINED),
             scm_eval (ly_symbol2scm ("slur-extremity-offset-alist")));
          
@@ -267,24 +272,25 @@ Slur::get_attachment (Direction dir,
     What if get_bound () is not a note-column?
    */
   if (str != "loose-end"
-      && get_bound (dir)->common_refpoint (common[Y_AXIS], Y_AXIS) == common[Y_AXIS])
+      && sp->get_bound (dir)->common_refpoint (common[Y_AXIS], Y_AXIS) == common[Y_AXIS])
     {      
-      o[Y_AXIS] += get_bound (dir)->relative_coordinate (common[Y_AXIS], Y_AXIS) 
-       - relative_coordinate (common[Y_AXIS], Y_AXIS);
+      o[Y_AXIS] += sp->get_bound (dir)->relative_coordinate (common[Y_AXIS], Y_AXIS) 
+       - me->relative_coordinate (common[Y_AXIS], Y_AXIS);
     }
   return o;
 }
 
 Array<Offset>
-Slur::get_encompass_offset_arr () const
+Slur::get_encompass_offset_arr (Score_element*me) 
 {
-  SCM eltlist = get_elt_property ("note-columns");
-  Score_element *common[] = {common_refpoint (eltlist,X_AXIS),
-                            common_refpoint (eltlist,Y_AXIS)};
+    Spanner*sp = dynamic_cast<Spanner*>(me);
+  SCM eltlist = me->get_elt_property ("note-columns");
+  Score_element *common[] = {me->common_refpoint (eltlist,X_AXIS),
+                            me->common_refpoint (eltlist,Y_AXIS)};
 
 
-  common[X_AXIS] = common[X_AXIS]->common_refpoint (get_bound (RIGHT), X_AXIS);
-  common[X_AXIS] = common[X_AXIS]->common_refpoint (get_bound (LEFT), X_AXIS);
+  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (RIGHT), X_AXIS);
+  common[X_AXIS] = common[X_AXIS]->common_refpoint (sp->get_bound (LEFT), X_AXIS);
   
   Link_array<Score_element>  encompass_arr;
   while (gh_pair_p (eltlist))
@@ -297,66 +303,68 @@ Slur::get_encompass_offset_arr () const
   
   Array<Offset> offset_arr;
 
-  Offset origin (relative_coordinate (common[X_AXIS], X_AXIS),
-                relative_coordinate (common[Y_AXIS], Y_AXIS)); 
+  Offset origin (me->relative_coordinate (common[X_AXIS], X_AXIS),
+                me->relative_coordinate (common[Y_AXIS], Y_AXIS)); 
 
   int first = 1;
   int last = encompass_arr.size () - 2;
 
-  offset_arr.push (get_attachment (LEFT, common));
+  offset_arr.push (get_attachment (me, LEFT, common));
 
   /*
     left is broken edge
   */
 
-  if (encompass_arr[0] != get_bound (LEFT))
+  if (encompass_arr[0] != sp->get_bound (LEFT))
     {
       first--;
 
       // ?
       offset_arr[0][Y_AXIS] -=
        encompass_arr[0]->relative_coordinate (common[Y_AXIS], Y_AXIS) 
-       - relative_coordinate (common[Y_AXIS], Y_AXIS); 
+       - me->relative_coordinate (common[Y_AXIS], Y_AXIS); 
     }
 
   /*
     right is broken edge
   */
-  if (encompass_arr.top () != get_bound (RIGHT))
+  if (encompass_arr.top () != sp->get_bound (RIGHT))
     {
       last++;
     }
 
   for (int i = first; i <= last; i++)
     {
-      Offset o (encompass_offset (encompass_arr[i], common));
+      Offset o (encompass_offset (me, encompass_arr[i], common));
       offset_arr.push (o - origin);
     }
 
-  offset_arr.push (Offset (spanner_length (), 0) + get_attachment (RIGHT,common));
+  offset_arr.push (Offset (sp->spanner_length (), 0) + get_attachment (me, RIGHT,common));
 
-  if (encompass_arr[0] != get_bound (LEFT))
+  if (encompass_arr[0] != sp->get_bound (LEFT))
     {
       offset_arr.top ()[Y_AXIS] -= encompass_arr.top ()->relative_coordinate (common[Y_AXIS], Y_AXIS) 
-       - relative_coordinate (common[Y_AXIS], Y_AXIS);
+       - me->relative_coordinate (common[Y_AXIS], Y_AXIS);
     }
 
   return offset_arr;
 }
 
 
-Array<Rod>
-Slur::get_rods () const
+MAKE_SCHEME_CALLBACK(Slur,set_spacing_rods);
+SCM
+Slur::set_spacing_rods (SCM smob)
 {
-  Array<Rod> a;
+  Score_element*me = unsmob_element (smob);
+
   Rod r;
-  
-  r.item_l_drul_[LEFT] = get_bound (LEFT);
-  r.item_l_drul_[RIGHT] = get_bound (RIGHT);
-  r.distance_f_ = paper_l ()->get_var ("slur_x_minimum");
+  Spanner*sp = dynamic_cast<Spanner*>(me);
+  r.item_l_drul_[LEFT] = sp->get_bound (LEFT);
+  r.item_l_drul_[RIGHT] = sp->get_bound (RIGHT);
+  r.distance_f_ = me->paper_l ()->get_var ("slur_x_minimum");
 
-  a.push (r);
-  return a;
+  r.add_to_cols ();
+  return SCM_UNDEFINED;
 }
 
 
@@ -367,11 +375,9 @@ MAKE_SCHEME_CALLBACK(Slur,brew_molecule);
 SCM
 Slur::brew_molecule (SCM smob)
 {
-  Slur * me = dynamic_cast<Slur*> (unsmob_element (smob));
-
-  
+  Score_element * me = unsmob_element (smob);
   Real thick = me->paper_l ()->get_var ("slur_thickness");
-  Bezier one = me->get_curve ();
+  Bezier one = get_curve (me);
 
   Molecule a;
   SCM d =  me->get_elt_property ("dashed");
@@ -384,14 +390,14 @@ Slur::brew_molecule (SCM smob)
 }
 
 void
-Slur::set_control_points ()
+Slur::set_control_points (Score_element*me)
 {
-  Slur_bezier_bow bb (get_encompass_offset_arr (),
-                     Directional_element_interface (this).get ());
+  Slur_bezier_bow bb (get_encompass_offset_arr (me),
+                     Directional_element_interface (me).get ());
 
-  Real staff_space = Staff_symbol_referencer::staff_space (this);
-  Real h_inf = paper_l ()->get_var ("slur_height_limit_factor") * staff_space;
-  Real r_0 = paper_l ()->get_var ("slur_ratio");
+  Real staff_space = Staff_symbol_referencer::staff_space (me);
+  Real h_inf = me->paper_l ()->get_var ("slur_height_limit_factor") * staff_space;
+  Real r_0 = me->paper_l ()->get_var ("slur_ratio");
 
   bb.set_default_bezier (h_inf, r_0);
 
@@ -399,14 +405,14 @@ Slur::set_control_points ()
     {
       Real length = bb.curve_.control_[3][X_AXIS]; 
       Real default_height = bb.get_default_height (h_inf, r_0, length);
-      bb.minimise_enclosed_area (paper_l(), default_height);
+      bb.minimise_enclosed_area (me->paper_l(), default_height);
       
-      Real bff = paper_l ()->get_var ("slur_force_blowfit");
+      Real bff = me->paper_l ()->get_var ("slur_force_blowfit");
       bb.curve_.control_[1][Y_AXIS] *= bff;
       bb.curve_.control_[2][Y_AXIS] *= bff;
       bb.blow_fit ();
 
-      Real sb = paper_l ()->get_var ("slur_beautiful");
+      Real sb = me->paper_l ()->get_var ("slur_beautiful");
       Real beautiful = length * default_height * sb;
       Real area = bb.enclosed_area_f ();
       
@@ -414,7 +420,7 @@ Slur::set_control_points ()
        Slurs that fit beautifully are not ugly
       */
       if (area > beautiful)
-       de_uglyfy (&bb, default_height);
+       de_uglyfy (me, &bb, default_height);
     }
 
   Bezier b = bb.get_bezier ();
@@ -424,32 +430,32 @@ Slur::set_control_points ()
   for (int i= 4; i--;)
     controls = gh_cons ( ly_offset2scm (b.control_[i]), controls);
 
-  set_elt_property ("control-points", controls);
+  me->set_elt_property ("control-points", controls);
 }
   
   
 Bezier
-Slur::get_curve () const
+Slur::get_curve (Score_element*me) 
 {
   Bezier b;
   int i = 0;
 
-  if (!Directional_element_interface (this).get ()
-      || ! gh_symbol_p (index_cell (get_elt_property ("attachment"), LEFT)))
-    ((Slur*)this)->set_extremities ();
+  if (!Directional_element_interface (me).get ()
+      || ! gh_symbol_p (index_cell (me->get_elt_property ("attachment"), LEFT)))
+    set_extremities (me);
   
-  if (!gh_pair_p (get_elt_property ("control-points")))
-    ((Slur*)this)->set_control_points ();
+  if (!gh_pair_p (me->get_elt_property ("control-points")))
+    set_control_points (me);
   
   
-  for (SCM s= get_elt_property ("control-points"); s != SCM_EOL; s = gh_cdr (s))
+  for (SCM s= me->get_elt_property ("control-points"); s != SCM_EOL; s = gh_cdr (s))
     {
       b.control_[i] = ly_scm2offset (gh_car (s));
       i++;
     }
   
-  Array<Offset> enc (get_encompass_offset_arr ());
-  Direction dir = Directional_element_interface (this).get ();
+  Array<Offset> enc (get_encompass_offset_arr (me));
+  Direction dir = Directional_element_interface (me).get ();
   
   Real x1 = enc[0][X_AXIS];
   Real x2 = enc.top ()[X_AXIS];
@@ -468,3 +474,11 @@ Slur::get_curve () const
   return b;
 }
 
+
+bool
+Slur::has_interface (Score_element*me)
+{
+  return me->has_interface ("slur-interface");
+}
+
+
diff --git a/lily/spaceable-element.cc b/lily/spaceable-element.cc
new file mode 100644 (file)
index 0000000..7f746ee
--- /dev/null
@@ -0,0 +1,84 @@
+/*   
+  spaceable-element.cc --  implement Spaceable_element
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#include "spaceable-element.hh"
+#include "score-element.hh"
+#include "warn.hh"
+
+SCM
+Spaceable_element::get_minimum_distances ( Score_element*me)
+{
+  return me->get_elt_property ("minimum-distances");
+}
+
+void
+Spaceable_element::add_rod (Score_element *me , Score_element * p, Real d)
+{
+  SCM mins = get_minimum_distances (me);
+  SCM newdist=                        gh_double2scm (d);
+  for (; gh_pair_p (mins); mins = gh_cdr (mins))
+    {
+      SCM dist = gh_car (mins);
+      if (gh_car (dist) == p->self_scm_)
+       {
+         gh_set_cdr_x (dist, scm_max (gh_cdr (dist),
+                                      newdist));
+         return ;
+       }
+    }
+
+  mins = gh_cons (gh_cons (p->self_scm_, newdist), mins);
+  me->set_elt_property ("minimum-distances", mins);
+}
+
+SCM
+Spaceable_element::get_ideal_distances (Score_element*me)
+{
+  return me->get_elt_property ("ideal-distances");
+}
+
+void
+Spaceable_element::add_spring (Score_element*me, Score_element * p, Real d, Real s)
+{
+  SCM mins = get_ideal_distances (me);
+  SCM newdist= gh_double2scm (d);
+  for (; gh_pair_p (mins); mins = gh_cdr (mins))
+    {
+      SCM dist = gh_car (mins);
+      if (gh_car (dist) == p->self_scm_)
+       {
+         programming_error("already have that spring");
+         /*      gh_set_car_x (gh_cdr (dist), scm_max (gh_cadr (dist),
+                 newdist));*/
+         return ;
+       }
+    }
+  SCM newstrength= gh_double2scm (s);  
+  
+  mins = gh_cons (gh_cons (p->self_scm_, gh_cons (newdist, newstrength)), mins);
+  me->set_elt_property ("ideal-distances", mins);
+}
+
+
+void
+Spaceable_element::remove_interface (Score_element*me)
+{
+  me->remove_elt_property ("minimum-distances");
+  me->remove_elt_property ("ideal-distances");
+  me->remove_elt_property ("dir-list");
+}
+
+
+void
+Spaceable_element::set_interface (Score_element*me)
+{
+  me->set_elt_property ("minimum-distances", SCM_EOL);
+  me->set_elt_property ("ideal-distances", SCM_EOL);
+  me->set_elt_property ("dir-list",SCM_EOL) ;  
+}
index a61b79a2235a2f94d2388551659b8508655db6c9..df45ee44f690b44807b76ba8b492016a6d3b91b8 100644 (file)
 #include "paper-column.hh"
 #include "spacing-engraver.hh"
 #include "spacing-spanner.hh"
+#include "engraver.hh"
+#include "pqueue.hh"
+
+struct Rhythmic_tuple
+{
+  Score_element_info info_;
+  Moment end_;
+  
+  Rhythmic_tuple ()
+    {
+    }
+  Rhythmic_tuple (Score_element_info i, Moment m )
+    {
+      info_ = i;
+      end_ = m;
+    }
+  static int time_compare (Rhythmic_tuple const &, Rhythmic_tuple const &);  
+};
+
+/**
+   Acknowledge rhythmic elements, for initializing spacing fields in
+   the columns.
+
+   should be the  last one of the toplevel context
+*/
+class Spacing_engraver : public Engraver
+{
+  PQueue<Rhythmic_tuple> playing_durations_;
+  Array<Rhythmic_tuple> now_durations_;
+  Array<Rhythmic_tuple> stopped_durations_;
+
+  Spanner * spacing_p_;
+protected:
+  VIRTUAL_COPY_CONS(Translator);
+  virtual void acknowledge_element (Score_element_info);
+  virtual void do_post_move_processing ();
+  virtual void do_pre_move_processing ();
+  virtual void do_creation_processing ();
+  virtual void do_removal_processing ();
+public:
+  Spacing_engraver ();
+};
 
 inline int
 compare (Rhythmic_tuple const &a, Rhythmic_tuple const &b)
@@ -33,7 +75,8 @@ Spacing_engraver::Spacing_engraver()
 void
 Spacing_engraver::do_creation_processing ()
 {
-  spacing_p_  =new Spacing_spanner (SCM_EOL);
+  spacing_p_  =new Spanner (get_property ("basicSpacingSpannerProperties"));
+  Spacing_spanner::set_interface (spacing_p_);
   spacing_p_->set_bound (LEFT, unsmob_element (get_property ("currentCommandColumn")));  
   announce_element (Score_element_info (spacing_p_, 0));
 }
index 827213d9fd089b1046a4a5d2f614c6576a89fa6a..9ba71190341dc939b9675c05bdfcd3d6e339f49d 100644 (file)
 #include "line-of-score.hh"
 #include "misc.hh"
 
-Spacing_spanner::Spacing_spanner (SCM s)
-  : Spanner (s)
+void
+Spacing_spanner::set_interface (Score_element*me)
 {
-  set_extent_callback (0, X_AXIS);
-  set_extent_callback (0, Y_AXIS);  
+  me->set_extent_callback (0, X_AXIS);
+  me->set_extent_callback (0, Y_AXIS);  
 }
 
 /*
@@ -36,8 +36,8 @@ Spacing_spanner::Spacing_spanner (SCM s)
   TODO: write comments 
   
  */
-Array<Spring>
-Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
+void
+Spacing_spanner::do_measure (Score_element*me, Link_array<Score_element> cols) 
 {
   Moment shortest;
   Moment mean_shortest;
@@ -46,7 +46,7 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
   int n = 0;
   for (int i =0 ; i < cols.size (); i++)  
     {
-      if (cols[i]->musical_b ())
+      if (dynamic_cast<Paper_column*> (cols[i])->musical_b ())
        {
          SCM  st = cols[i]->get_elt_property ("shortest-starter-duration");
          Moment this_shortest = (*SMOB_TO_TYPE(Moment, st));
@@ -60,15 +60,13 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
     }
   mean_shortest /= n;
 
-  Array<Spring> meas_springs;
-
-  Real non_musical_space_strength = paper_l ()->get_var ("breakable_column_space_strength");
+  Real non_musical_space_strength = me->paper_l ()->get_var ("breakable_column_space_strength");
   for (int i= 0; i < cols.size () - 1; i++)
     {
-      Item * l = cols[i];
-      Item * r = cols[i+1];
-      Item * lb = l->find_prebroken_piece (RIGHT);
-      Item * rb = r->find_prebroken_piece (LEFT);      
+      Item * l = dynamic_cast<Item*> (cols[i]);
+      Item * r =  dynamic_cast<Item*> (cols[i+1]);
+      Item * lb = dynamic_cast<Item*> ( l->find_prebroken_piece (RIGHT));
+      Item * rb = dynamic_cast<Item*> ( r->find_prebroken_piece (LEFT));
 
       Item* combinations[4][2]={{l,r}, {lb,r}, {l,rb},{lb,rb}};
 
@@ -96,11 +94,11 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
           // 2nd condition should be (i+1 < col_count()), ie. not the last column in score.  FIXME
          else if (!lc->musical_b() && i+1 < cols.size ()) 
            {
-             left_distance= default_bar_spacing (lc,rc,shortest);
+             left_distance= default_bar_spacing (me,lc,rc,shortest);
            }
          else if (lc->musical_b())
            {
-             left_distance  = note_spacing (lc, rc, shortest);
+             left_distance  = note_spacing (me,lc, rc, shortest);
            }
 
          s.distance_f_ = left_distance;
@@ -112,10 +110,10 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
            We want the space before barline to be like the note
            spacing in the measure.
          */
-         if (lc->breakable_b () || lc->original_l_)
+         if (Item::breakable_b (lc) || lc->original_l_)
            s.strength_f_ = non_musical_space_strength;
          else if (!lc->musical_b ())
-           left_distance *= paper_l ()->get_var ("decrease_nonmus_spacing_factor");
+           left_distance *= me->paper_l ()->get_var ("decrease_nonmus_spacing_factor");
 
          
          Real right_dist = 0.0;
@@ -135,11 +133,11 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
          if (lc->musical_b () && rc->musical_b ())
            {
              if (!to_boolean (rc->get_elt_property ("contains-grace")))
-               right_dist *= paper_l ()->get_var ("musical_to_musical_left_spacing_factor");
+               right_dist *= me->paper_l ()->get_var ("musical_to_musical_left_spacing_factor");
            }
 
          if (rc->musical_b () && to_boolean (rc->get_elt_property ("contains-grace")))
-           right_dist *= paper_l ()->get_var ("before_grace_spacing_factor");
+           right_dist *= me->paper_l ()->get_var ("before_grace_spacing_factor");
  
          s.distance_f_ = left_distance + right_dist;
            
@@ -170,30 +168,29 @@ Spacing_spanner::do_measure (Link_array<Paper_column> cols) const
          else
            s.strength_f_ /= stretch_dist;
          
-         meas_springs.push (s);        
+         s.add_to_cols ();
        }
     }
-
-  return meas_springs;
+  
 }
 
 /**
    Do something if breakable column has no spacing hints set.
  */
 Real
-Spacing_spanner::default_bar_spacing (Paper_column *lc, Paper_column *rc,
-                                     Moment shortest) const
+Spacing_spanner::default_bar_spacing (Score_element*me, Score_element *lc, Score_element *rc,
+                                     Moment shortest) 
 {
   Real symbol_distance = lc->extent (X_AXIS)[RIGHT] ;
   Real durational_distance = 0;
-  Moment delta_t =  rc->when_mom () - lc->when_mom () ;
+  Moment delta_t = Paper_column::when_mom (rc) - Paper_column::when_mom (lc);
 
   /*
                ugh should use shortest_playing distance
   */
   if (delta_t)
     {
-      durational_distance =  get_duration_space (delta_t, shortest);
+      durational_distance =  get_duration_space (me, delta_t, shortest);
     }
 
   return  symbol_distance >? durational_distance;
@@ -201,7 +198,7 @@ Spacing_spanner::default_bar_spacing (Paper_column *lc, Paper_column *rc,
 
 
 /**
-  Get the measure wide constant for arithmetic spacing.
+  Get the measure wide ant for arithmetic spacing.
 
   @see
   John S. Gourlay. ``Spacing a Line of Music,'' Technical Report
@@ -210,42 +207,47 @@ Spacing_spanner::default_bar_spacing (Paper_column *lc, Paper_column *rc,
 
   */
 Real
-Spacing_spanner::get_duration_space (Moment d, Moment shortest) const
+Spacing_spanner::get_duration_space (Score_element*me, Moment d, Moment shortest) 
 {
   Real log = log_2 (Moment (1,8) <? shortest);
-  Real k=   paper_l ()->get_var ("arithmetic_basicspace")
+  Real k=   me->paper_l ()->get_var ("arithmetic_basicspace")
     - log;
   
-  return (log_2 (d) + k) * paper_l ()->get_var ("arithmetic_multiplier");
+  return (log_2 (d) + k) * me->paper_l ()->get_var ("arithmetic_multiplier");
 }
 
 
 Real
-Spacing_spanner::note_spacing (Paper_column *lc, Paper_column *rc, Moment shortest) const
+Spacing_spanner::note_spacing (Score_element*me, Score_element *lc, Score_element *rc, Moment shortest) 
 {
   Moment shortest_playing_len = 0;
   SCM s = lc->get_elt_property ("shortest-playing-duration");
-  //  SCM s = lc->get_elt_property ("mean-playing-duration");  
-  if (SMOB_IS_TYPE_B(Moment, s))
-    shortest_playing_len = *SMOB_TO_TYPE (Moment, s);
 
+  //  SCM s = lc->get_elt_property ("mean-playing-duration");  
+  if (unsmob_moment (s))
+    shortest_playing_len = *unsmob_moment(s);
   
   if (! shortest_playing_len)
     {
-      programming_error ("can't find a ruling note at " + lc->when_mom ().str ());
+      programming_error ("can't find a ruling note at " + Paper_column::when_mom (lc).str ());
       shortest_playing_len = 1;
     }
   
   if (! shortest)
     {
-      programming_error ("no minimum in measure at " + lc->when_mom ().str ());
+      programming_error ("no minimum in measure at " + Paper_column::when_mom (lc).str ());
       shortest = 1;
     }
-  Moment delta_t = rc->when_mom () - lc->when_mom ();
-  Real dist = get_duration_space (shortest_playing_len, shortest);
+  Moment delta_t = Paper_column::when_mom (rc) - Paper_column::when_mom (lc);
+  Real dist = get_duration_space (me, shortest_playing_len, shortest);
   dist *= (double)(delta_t / shortest_playing_len);
 
-  dist += stem_dir_correction (lc,rc);
+  /*
+    UGH: KLUDGE!
+  */
+  
+  if (delta_t > Moment (1,32))
+    dist += stem_dir_correction (me, lc,rc);
   return dist;
 }
 
@@ -264,17 +266,16 @@ Spacing_spanner::note_spacing (Paper_column *lc, Paper_column *rc, Moment shorte
    TODO: lookup correction distances?  More advanced correction?
    Possibly turn this off?
 
+   TODO: have to check wether the stems are in the same staff.
+
    This routine reads the DIR-LIST property of both its L and R arguments.  */
 Real
-Spacing_spanner::stem_dir_correction (Paper_column*l, Paper_column*r) const
+Spacing_spanner::stem_dir_correction (Score_element*me, Score_element*l, Score_element*r) 
 {
   SCM dl = l->get_elt_property ("dir-list");
   SCM dr = r->get_elt_property ("dir-list");
-  if (dl == SCM_UNDEFINED || dr == SCM_UNDEFINED)
-    return 0.0;
-
-
-  if (scm_ilength (dl) != 1 && scm_ilength (dr) != 1)
+  
+  if (scm_ilength (dl) != 1 || scm_ilength (dr) != 1)
     return 0.;
 
   dl = gh_car (dl);
@@ -289,44 +290,35 @@ Spacing_spanner::stem_dir_correction (Paper_column*l, Paper_column*r) const
 
   bool err = false;
   Real correction = 0.0;
-  Real ssc = paper_l ()->get_var("stemSpacingCorrection");
+  Real ssc = me->paper_l ()->get_var("stemSpacingCorrection");
 
 
-  if (d1 && d2)
+  if (d1 && d2 && d1 * d2 == -1)
     {
-      if (d1 == 1 && d2 == -1)
-       correction = ssc;
-      else if (d1 == -1 && d2 == 1)
-       correction = -ssc;
-      else
-       err = true;
+      correction = d1 * ssc;
     }
-  
   else
-    err = true;
-
-  if (err)
     programming_error ("Stem directions not set correctly for optical correction");
   return correction;
 }
   
 
-Array<Spring>
-Spacing_spanner::get_springs () const
+MAKE_SCHEME_CALLBACK(Spacing_spanner, set_springs);
+SCM
+Spacing_spanner::set_springs (SCM smob)
 {
-  Array<Spring> springs;
-
-  Link_array<Paper_column> all (pscore_l_->line_l_->column_l_arr ()) ;
+  Score_element *me = unsmob_element (smob);
+  Link_array<Score_element> all (me->pscore_l_->line_l_->column_l_arr ()) ;
 
   int j = 0;
 
   for (int i = 1; i < all.size (); i++)
     {
-      Paper_column* sc = dynamic_cast<Paper_column*> (all[i]);
-      if (sc->breakable_b ())
+      Score_element *sc = all[i];
+      if (Item::breakable_b (sc))
         {
-         Link_array<Paper_column> measure (all.slice (j, i+1));          
-          springs.concat (do_measure (measure));
+         Link_array<Score_element> measure (all.slice (j, i+1));         
+          do_measure (me, measure);
          j = i;
         }
     }
@@ -334,9 +326,8 @@ Spacing_spanner::get_springs () const
   /*
     farewell, cruel world
    */
-  ((Spacing_spanner*)this)->suicide ();
-  
-  return springs;
+  me->suicide ();
+  return SCM_UNDEFINED;
 }
 
 
index b272827ba4e22d758828e88ede2b942f89a89890..f9cb12f4c1ae7dbaddf0329cfa4c1fb777aafa0a 100644 (file)
@@ -232,38 +232,6 @@ Spanner::broken_b() const
   return broken_into_l_arr_.size();
 }
 
-Array<Rod>
-Spanner::get_rods () const
-{
-  Array<Rod> r;
-  return r;
-}
-
-Array<Spring>
-Spanner::get_springs () const
-{
-  Array<Spring> s;
-  return s;    
-}
-
-void
-Spanner::do_space_processing ()
-{
-  Array<Rod> rs (get_rods ());
-  for (int i=0; i < rs.size (); i++)
-    {
-      rs[i].add_to_cols ();
-    }
-
-  Array<Spring> ss (get_springs ());
-  for (int i=0; i < ss.size (); i++)
-    {
-      if (isinf (ss[i].distance_f_))
-       programming_error ("weird spring");
-      else
-       ss[i].add_to_cols ();
-    }
-}
 
 /*
   If this is a broken spanner, return the amount the left end is to be
index 41a7e1772ddce17c1612325a003ab6cd5ec42624..e5136a82ffb3e9ad4e47f468a160699648b87774 100644 (file)
@@ -10,6 +10,7 @@
 #include "spring.hh"
 #include "debug.hh"
 #include "item.hh"
+#include "spaceable-element.hh"
 #include "paper-column.hh"
 
 Spring::Spring ()
@@ -22,7 +23,9 @@ Spring::Spring ()
 void
 Spring::add_to_cols ()
 {
-  item_l_drul_[LEFT]->column_l ()->add_spring (item_l_drul_[RIGHT]->column_l (), distance_f_, strength_f_);
+  Spaceable_element::add_spring (item_l_drul_[LEFT]->column_l (),
+                                item_l_drul_[RIGHT]->column_l (),
+                                distance_f_, strength_f_);
 }
 
 
index 259d69feebe6336380f039454b4933fd64e75d7b..2b5367aab276018ca567abbcca6990c22ec63048 100644 (file)
@@ -12,7 +12,7 @@
 #include "musical-request.hh"
 #include "misc.hh"
 #include "stem-tremolo.hh"
-
+#include "item.hh"
 #include "translator-group.hh"
 #include "engraver.hh"
 
@@ -34,7 +34,7 @@ protected:
   
 private:
   int default_tremolo_type_i_;
-  Stem *stem_p_;
+  Score_element  *stem_p_;
   Score_element *tremolo_p_;
   Rhythmic_req *rhythmic_req_l_;
   Tremolo_req* tremolo_req_l_;
@@ -77,7 +77,8 @@ Stem_engraver::acknowledge_element(Score_element_info i)
       int duration_log = r->duration_.durlog_i_;      
       if (!stem_p_) 
        {
-         stem_p_ = new Stem (get_property ("basicStemProperties"));
+         stem_p_ = new Item (get_property ("basicStemProperties"));
+         Stem::set_interface (stem_p_);
          Staff_symbol_referencer::set_interface(stem_p_);
 
          
index a0797cff862b4cc905f3181649b12b05743a76ae..fff6f5c056729e2aadd355b67fd8601ca95728ea 100644 (file)
@@ -13,8 +13,7 @@
 #include "paper-def.hh"
 #include "lookup.hh"
 #include "stem.hh"
-#include "offset.hh"
-
+#include "item.hh"
 #include "staff-symbol-referencer.hh"
 #include "directional-element-interface.hh"
 
@@ -45,7 +44,7 @@ Stem_tremolo::brew_molecule (SCM smob)
 {
   Score_element *me= unsmob_element (smob);
   Score_element * stem = unsmob_element (me->get_elt_property ("stem"));
-  Beam * beam = Stem::beam_l (stem);
+  Score_element * beam = Stem::beam_l (stem);
   
   Real dydx;
   if (beam)
@@ -54,8 +53,8 @@ Stem_tremolo::brew_molecule (SCM smob)
       SCM s = beam->get_elt_property ("height");
       if (gh_number_p (s))
        dy = gh_scm2double (s);
-      Real dx = beam->last_visible_stem ()->relative_coordinate (0, X_AXIS)
-       - beam->first_visible_stem ()->relative_coordinate (0, X_AXIS);
+      Real dx = Beam::last_visible_stem (beam)->relative_coordinate (0, X_AXIS)
+       - Beam::first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
       dydx = dx ? dy/dx : 0;
     }
   else
@@ -79,7 +78,7 @@ Stem_tremolo::brew_molecule (SCM smob)
     // huh?
     tremolo_flags = 1;
 
-  int mult = beam ? beam->get_multiplicity () : 0;
+  int mult = beam ? Beam::get_multiplicity (beam) : 0;
   Real interbeam_f = me->paper_l ()->interbeam_f (mult);
   Molecule mol; 
   for (int i = 0; i < tremolo_flags; i++)
index 1b7d72042af9257576eb60527717ee5f0787a04d..a8583c450a91b2bd1d3899cc751e806d498d6d29 100644 (file)
@@ -25,7 +25,7 @@
 #include "group-interface.hh"
 #include "cross-staff.hh"
 #include "staff-symbol-referencer.hh"
-
+#include "spanner.hh"
 
 
 void
@@ -213,16 +213,6 @@ Stem::add_head (Score_element*me, Score_element *n)
     }
 }
 
-Stem::Stem (SCM s)
-  : Item (s)
-{
-  Score_element * me = this;
-  
-  me->set_elt_property ("heads", SCM_EOL);
-  Stem::set_interface (me);
-  me->add_offset_callback ( &Stem::off_callback, X_AXIS);
-}
-
 bool
 Stem::invisible_b (Score_element*me)
 {
@@ -516,11 +506,11 @@ Stem::off_callback (Score_element * me, Axis)
 
 
 
-Beam*
+Score_element*
 Stem::beam_l (Score_element*me)
 {
   SCM b=  me->get_elt_property ("beam");
-  return dynamic_cast<Beam*> (unsmob_element (b));
+  return unsmob_element (b);
 }
 
 
@@ -528,7 +518,7 @@ Stem::beam_l (Score_element*me)
 Stem_info
 Stem::calc_stem_info (Score_element*me) 
 {
-  Beam * beam = beam_l (me);
+  Score_element * beam = beam_l (me);
 
   Direction beam_dir = Directional_element_interface (beam).get ();
   if (!beam_dir)
@@ -540,9 +530,9 @@ Stem::calc_stem_info (Score_element*me)
 
   Real staff_space = Staff_symbol_referencer::staff_space (me);
   Real half_space = staff_space / 2;
-  Real interbeam_f = me->paper_l ()->interbeam_f (beam->get_multiplicity ());
+  Real interbeam_f = me->paper_l ()->interbeam_f (Beam::get_multiplicity (beam));
   Real thick = gh_scm2double (beam->get_elt_property ("beam-thickness"));
-  int multiplicity = beam->get_multiplicity ();
+  int multiplicity = Beam::get_multiplicity (beam);
 
   Stem_info info; 
   info.idealy_f_ = chord_start_f (me);
@@ -626,7 +616,7 @@ Stem::calc_stem_info (Score_element*me)
   if (gh_number_p (s))
     info.idealy_f_ -= gh_scm2double (s);
 
-  Real interstaff_f = -beam_dir* calc_interstaff_dist (dynamic_cast<Item*> (me), beam);
+  Real interstaff_f = -beam_dir* calc_interstaff_dist (dynamic_cast<Item*> (me), dynamic_cast<Spanner*> (beam));
 
   info.idealy_f_ += interstaff_f;
   info.miny_f_ += interstaff_f;
@@ -642,7 +632,9 @@ Stem::has_interface (Score_element*m)
 }
 
 void
-Stem::set_interface (Score_element*m)
-{
-  return m->set_interface (ly_symbol2scm ("stem-interface"));
+Stem::set_interface (Score_element*me)
+{    
+  me->set_elt_property ("heads", SCM_EOL);
+  me->add_offset_callback ( &Stem::off_callback, X_AXIS);
+  me->set_interface (ly_symbol2scm ("stem-interface"));
 }
index 323b502845726c005b28a795e6e43b9e002c2813..2f9c36619510abaed27a0ef626bb39b8937d7f58 100644 (file)
@@ -14,6 +14,7 @@
 #include "group-interface.hh"
 #include "paper-column.hh"
 #include "paper-def.hh"
+#include "spanner.hh"
 
 class System_start_delimiter_engraver : public Engraver
 {
@@ -41,9 +42,9 @@ System_start_delimiter_engraver::acknowledge_element (Score_element_info inf)
          
       Pointer_group_interface (delim_).add_element (inf.elem_l_);
     }
-  else if (System_start_delimiter * b = dynamic_cast<System_start_delimiter *> (inf.elem_l_))
+  else if (System_start_delimiter::has_interface (inf.elem_l_))
     {
-      SCM gl = b->get_elt_property ("glyph");
+      SCM gl = inf.elem_l_->get_elt_property ("glyph");
       SCM my_gl = delim_->get_elt_property ("glyph");
 
       /*
@@ -51,7 +52,7 @@ System_start_delimiter_engraver::acknowledge_element (Score_element_info inf)
        */
       if (gh_symbol_p (gl) && gl  == ly_symbol2scm ("brace")
          && gh_symbol_p (my_gl) && my_gl == ly_symbol2scm ("bracket"))
-       b->translate_axis ( -paper_l ()->get_var ("interline"), X_AXIS); // ugh
+       inf.elem_l_->translate_axis ( -paper_l ()->get_var ("interline"), X_AXIS); // ugh
     }
 
 }
@@ -64,7 +65,8 @@ System_start_delimiter_engraver::System_start_delimiter_engraver()
 void
 System_start_delimiter_engraver::do_creation_processing()
 {
-  delim_ = new System_start_delimiter (get_property ("basicSystemStartDelimiterProperties"));
+  delim_ = new Spanner (get_property ("basicSystemStartDelimiterProperties"));
+  System_start_delimiter::set_interface (delim_);
   delim_->set_bound (LEFT, unsmob_element (get_property ("currentCommandColumn")));
 
   /*
index 20bb3fc306d8f14261508cd345b343c885595ea7..23bf7e7facd6a6c17ad572e9c8d5e1f646336930 100644 (file)
@@ -8,29 +8,30 @@
  */
 #include <math.h>
 
+#include "axis-group-interface.hh"
 #include "system-start-delimiter.hh"
 #include "paper-def.hh"
 #include "molecule.hh"
-#include "axis-group-interface.hh"
 #include "lookup.hh"
 #include "all-font-metrics.hh"
+#include "spanner.hh"
 
 Molecule
-System_start_delimiter::staff_bracket (Real height) const 
+System_start_delimiter::staff_bracket (Score_element*me,Real height)  
 {
-  Paper_def* p= paper_l ();
+  Paper_def* p= me->paper_l ();
   SCM scmss = p->get_scmvar ("staffspace");
   Real ss = gh_scm2double (scmss);
-  Real arc_height = gh_scm2double (get_elt_property("arch-height")) * ss ;
+  Real arc_height = gh_scm2double (me->get_elt_property("arch-height")) * ss ;
   
   SCM at = gh_list (ly_symbol2scm ("bracket"),
-                   scm_product (get_elt_property ("arch-angle"), scmss),
-                   scm_product (get_elt_property ("arch-width"), scmss),
+                   scm_product (me->get_elt_property ("arch-angle"), scmss),
+                   scm_product (me->get_elt_property ("arch-width"), scmss),
                    gh_double2scm (arc_height),
-                   scm_product (get_elt_property ("bracket-width"),scmss),
+                   scm_product (me->get_elt_property ("bracket-width"),scmss),
                    gh_double2scm (height),
-                   scm_product (get_elt_property ("arch-thick"),scmss),
-                   scm_product (get_elt_property ("bracket-thick"),scmss),
+                   scm_product (me->get_elt_property ("arch-thick"),scmss),
+                   scm_product (me->get_elt_property ("bracket-thick"),scmss),
                    SCM_UNDEFINED);
 
   Real h = height + 2 * arc_height;
@@ -40,19 +41,26 @@ System_start_delimiter::staff_bracket (Real height) const
   return mol;
 }
 
-System_start_delimiter::System_start_delimiter (SCM s)
-  : Spanner (s)
+void
+System_start_delimiter::set_interface (Score_element*me)
+{
+  me->set_extent_callback (0, Y_AXIS);
+  Pointer_group_interface (me).set_interface();
+  me->set_interface (ly_symbol2scm ("system-start-delimiter-interface"));
+}
+
+bool
+System_start_delimiter::has_interface (Score_element*me)
 {
-  set_extent_callback (0, Y_AXIS);
-  Pointer_group_interface (this).set_interface();
+  return  me->has_interface (ly_symbol2scm ("system-start-delimiter-interface"));
 }
 
 Molecule
-System_start_delimiter::simple_bar (Real h) const
+System_start_delimiter::simple_bar (Score_element*me,Real h) 
 {
-  Real w = paper_l ()->get_var ("stafflinethickness") *
-    gh_scm2double (get_elt_property ("thickness"));
-  return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
+  Real w = me->paper_l ()->get_var ("stafflinethickness") *
+    gh_scm2double (me->get_elt_property ("thickness"));
+  return me->lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
 }
 
 MAKE_SCHEME_CALLBACK(System_start_delimiter,after_line_breaking);
@@ -82,31 +90,28 @@ MAKE_SCHEME_CALLBACK(System_start_delimiter,brew_molecule);
 SCM
 System_start_delimiter::brew_molecule (SCM smob)
 {
-  Score_element * sc = unsmob_element (smob);
-
-  System_start_delimiter * ssd= dynamic_cast<System_start_delimiter*> (sc);
-  
-  Interval ext = Axis_group_interface::group_extent_callback (sc, Y_AXIS);
+  Score_element * me = unsmob_element (smob);
+  Interval ext = Axis_group_interface::group_extent_callback (me, Y_AXIS);
   Real l = ext.length (); 
   Molecule m;
 
-  SCM s = sc->get_elt_property ("collapse-height");
+  SCM s = me->get_elt_property ("collapse-height");
   if (gh_number_p (s) && l < gh_scm2double (s))
     {
-      sc->suicide();
+      me->suicide();
       return SCM_EOL;
     }
 
-  s = sc->get_elt_property ("glyph");
+  s = me->get_elt_property ("glyph");
   if (!gh_symbol_p(s))
     return SCM_EOL;
   
   if (s == ly_symbol2scm ("bracket"))
-    m = ssd->staff_bracket (l);
+    m = staff_bracket (me,l);
   else if (s == ly_symbol2scm ("brace"))
-    m = ssd-> staff_brace (l);
+    m =  staff_brace (me,l);
   else if (s == ly_symbol2scm ("bar-line"))
-    m = ssd->simple_bar (l);
+    m = simple_bar (me,l);
   
   
   m.translate_axis (ext.center (), Y_AXIS);
@@ -117,9 +122,9 @@ System_start_delimiter::brew_molecule (SCM smob)
   Ugh. Suck me plenty.
  */
 Molecule
-System_start_delimiter::staff_brace (Real y)  const
+System_start_delimiter::staff_brace (Score_element*me,Real y)  
 {
-  Real staffht  = paper_l ()->get_var ("staffheight");
+  Real staffht  = me->paper_l ()->get_var ("staffheight");
   int staff_size  = int (rint (staffht ));
 
   // URG
index 10008dc2fae6ab37688dedb72067cbdf3e1adbce..cd3badc526d83dd2cae796d88b3a89d40e500a27 100644 (file)
 #include "directional-element-interface.hh"
 #include "rhythmic-head.hh"
 
-Tie_column::Tie_column (SCM s)
-  : Spanner (s)
-{
 
-}
+
 void
 Tie_column::set_interface (Score_element*me)
 {
- me-> set_elt_property ("ties", SCM_EOL);
+  me-> set_elt_property ("ties", SCM_EOL);
+  me->set_interface (ly_symbol2scm ("tie-column"));
   me->set_extent_callback (0, X_AXIS);
   me->set_extent_callback (0, Y_AXIS);  
 }
 
+bool
+Tie_column::has_interface (Score_element*me)
+{
+  return  me->has_interface (ly_symbol2scm ("tie-column"));
+}
+
 void
 Tie_column::add_tie (Score_element*me,Tie *s)
 {
index 4f619e27ae2d5738fd68a631f9b9b2e20be3db9e..09c4d47c6015084fa9eba1be843d9a7c043e24c1 100644 (file)
@@ -49,7 +49,7 @@ class Tie_engraver : public Engraver
   Array<CHead_melodic_tuple> stopped_heads_;
   Link_array<Tie> tie_p_arr_;
 
-  Tie_column * tie_column_p_;
+  Spanner * tie_column_p_;
   
   void set_melisma (bool);
   
@@ -199,7 +199,7 @@ Tie_engraver::process_acknowledged ()
        }
       else if (tie_p_arr_.size () > 1 && !tie_column_p_)
        {
-         tie_column_p_ = new Tie_column (get_property ("basicTieColumnProperties"));
+         tie_column_p_ = new Spanner (get_property ("basicTieColumnProperties"));
          Tie_column::set_interface (tie_column_p_);
          for (int i = tie_p_arr_.size (); i--; )
            Tie_column::add_tie (tie_column_p_,tie_p_arr_ [i]);
index 9b655230a036bf1cca72a88761a8a6c03d639a18..13acee6ea7957b41a617583393b1a6b675f19576 100644 (file)
@@ -168,23 +168,28 @@ Tie::after_line_breaking (SCM smob)
 }
 
 
-
-Array<Rod>
-Tie::get_rods () const
+MAKE_SCHEME_CALLBACK(Tie,set_spacing_rods);
+SCM
+Tie::set_spacing_rods (SCM smob)  
 {
-  Array<Rod> a;
+  Score_element*me = unsmob_element (smob);
+  Spanner*sp = dynamic_cast<Spanner*> (me);
   Rod r;
 
-  r.item_l_drul_ [LEFT]=get_bound (LEFT);
-  r.item_l_drul_ [RIGHT]=get_bound (RIGHT);  
+  r.item_l_drul_ [LEFT]=sp->get_bound (LEFT);
+  r.item_l_drul_ [RIGHT]=sp->get_bound (RIGHT);  
   
-  r.distance_f_ = paper_l ()->get_var ("tie_x_minimum");
-  a.push (r);
-  return a;
+  r.distance_f_ = me->paper_l ()->get_var ("tie_x_minimum");
+  r.add_to_cols ();
+  return SCM_UNDEFINED;
 }
 
-MAKE_SCHEME_CALLBACK(Tie,brew_molecule);
 
+
+
+
+
+MAKE_SCHEME_CALLBACK(Tie,brew_molecule);
 SCM
 Tie::brew_molecule (SCM smob) 
 {
index 071e55e03bf5e49f5b87f5acf719581eb1cdeac1..6fcdba950e6b37657129a10c303980ec763b02ed 100644 (file)
@@ -15,6 +15,7 @@
 #include "beam.hh"
 #include "music-list.hh"
 #include "engraver.hh"
+#include "spanner.hh"
 
 class Tuplet_engraver : public Engraver
 {
@@ -96,17 +97,17 @@ Tuplet_engraver::acknowledge_element (Score_element_info i)
   if (grace != wgb)
     return;
   
-  if (Note_column *nc = dynamic_cast<Note_column *> (i.elem_l_))
+  if (Note_column::has_interface(i.elem_l_))
     {
       for (int j =0; j  <started_span_p_arr_.size (); j++)
        if (started_span_p_arr_[j]) 
-         Tuplet_spanner::add_column (started_span_p_arr_[j],nc);
+         Tuplet_spanner::add_column (started_span_p_arr_[j], dynamic_cast<Item*>(i.elem_l_));
     }
-  else if (Beam *b = dynamic_cast<Beam *> (i.elem_l_))
+  else if (Beam::has_interface (i.elem_l_))
     {
       for (int j = 0; j < started_span_p_arr_.size (); j++)
        if (started_span_p_arr_[j]) 
-         Tuplet_spanner::add_beam (started_span_p_arr_[j],b);
+         Tuplet_spanner::add_beam (started_span_p_arr_[j],i.elem_l_);
     }
 }
 
index 87a528f12b8424cc432530f92f86a4f5c85b1d96..10ddf988768e54c2b3fb197c59789bd22f357b7d 100644 (file)
@@ -20,6 +20,7 @@
 #include "dimensions.hh"
 #include "group-interface.hh"
 #include "directional-element-interface.hh"
+#include "spanner.hh"
 
 
 
@@ -65,8 +66,8 @@ Tuplet_spanner::brew_molecule (SCM smob)
   
   if (gh_pair_p (me->get_elt_property ("columns")))
     {
-      Link_array<Note_column> column_arr=
-       Pointer_group_interface__extract_elements (me, (Note_column*)0, "columns");
+      Link_array<Score_element> column_arr=
+       Pointer_group_interface__extract_elements (me, (Score_element*)0, "columns");
        
       Real ncw = column_arr.top ()->extent(X_AXIS).length ();
       Real w = dynamic_cast<Spanner*>(me)->spanner_length () + ncw;
@@ -123,8 +124,8 @@ Tuplet_spanner::brew_molecule (SCM smob)
 void
 Tuplet_spanner::calc_position_and_height (Score_element*me,Real *offset, Real * dy) 
 {
-  Link_array<Note_column> column_arr=
-    Pointer_group_interface__extract_elements (me, (Note_column*)0, "columns");
+  Link_array<Score_element> column_arr=
+    Pointer_group_interface__extract_elements (me, (Score_element*)0, "columns");
 
 
   Score_element * common = me->common_refpoint (me->get_elt_property ("columns"), Y_AXIS);
@@ -135,11 +136,11 @@ Tuplet_spanner::calc_position_and_height (Score_element*me,Real *offset, Real *
     Use outer non-rest columns to determine slope
    */
   int l = 0;
-  while (l <column_arr.size() && column_arr[l]->rest_b())
+  while (l <column_arr.size() && Note_column::rest_b(column_arr[l]))
     l ++;
 
   int r = column_arr.size ()- 1;
-  while (r >= l && column_arr[r]->rest_b())
+  while (r >= l && Note_column::rest_b(column_arr[r]))
     r--;
   
   if (l < r)
@@ -180,9 +181,8 @@ Tuplet_spanner::calc_position_and_height (Score_element*me,Real *offset, Real *
 void
 Tuplet_spanner::calc_dy (Score_element*me,Real * dy)
 {
-  Link_array<Note_column> column_arr=
-    Pointer_group_interface__extract_elements (me, (Note_column*)0, "columns");
-
+  Link_array<Score_element> column_arr=
+    Pointer_group_interface__extract_elements (me, (Score_element*)0, "columns");
  
   Direction d = Directional_element_interface (me).get ();
   *dy = column_arr.top ()->extent (Y_AXIS) [d]
@@ -224,7 +224,7 @@ Tuplet_spanner::after_line_breaking (SCM smob)
     {
       SCM bs = me->get_elt_property ("beams");
       Score_element *b = unsmob_element (gh_car (bs));
-      Beam * beam_l = dynamic_cast<Beam*> (b);
+      Spanner * beam_l = dynamic_cast<Spanner *> (b);
       if (!sp->broken_b () 
          && sp->get_bound (LEFT)->column_l () == beam_l->get_bound (LEFT)->column_l ()
          && sp->get_bound (RIGHT)->column_l () == beam_l->get_bound (RIGHT)->column_l ())
@@ -249,9 +249,8 @@ Tuplet_spanner::get_default_dir (Score_element*me)
   d = UP ;
   for (SCM s = me->get_elt_property ("columns"); gh_pair_p (s); s = gh_cdr (s))
     {
-      Score_element * sc = unsmob_element (gh_car (s));
-      Note_column * nc = dynamic_cast<Note_column*> (sc);
-      if (nc->dir () < 0) 
+      Score_element * nc = unsmob_element (gh_car (s));
+      if (Note_column::dir (nc) < 0) 
        {
          d = DOWN;
          break;
@@ -264,7 +263,7 @@ Tuplet_spanner::get_default_dir (Score_element*me)
 void
 Tuplet_spanner::add_beam (Score_element*me, Score_element *b)
 {
-me->add_dependency (b);
+  me->add_dependency (b);
   Pointer_group_interface gi (me, "beams");
   gi.add_element (b);
 }
index a5412bf776d8cf40f330e21f69d2ce6122b3dcde..da81fa71ef47c2062146e0e8f325e8225bc89d09 100644 (file)
@@ -482,7 +482,7 @@ ScoreContext = \translator {
                (interfaces . (dot-interface))
        )
        basicDynamicLineSpannerProperties = #`(
-               (interfaces (dynamic-interface))
+               (interfaces (dynamic-interface axis-group-interface))
                (axes . ( 1))
        )
        basicDynamicTextProperties       = # `(
@@ -498,6 +498,7 @@ ScoreContext = \translator {
        )
        basicGraceAlignItemProperties = #`(
                (axes . (0))
+               (interfaces . (axis-group-interface align-interface))
                (before-line-breaking-callback . ,Grace_align_item::before_line_breaking)
        )
        basicHaraKiriVerticalGroupspannerProperties = #`(
@@ -523,11 +524,10 @@ ScoreContext = \translator {
                (right-padding . 0.4)
                (interfaces . (accidentals-interface ))
        )
-       basicLineOfScoreProperties = #`( )
-%{;            (axes . (0 1))
-;              (interfaces . (axis-group))
-       ;       (rank . -1)
-       ; )%}
+       basicLineOfScoreProperties = #`(
+               (axes . (0 1))
+               (interfaces . (axis-group-interface))
+       )
        basicLyricExtenderProperties = #`(
                (molecule-callback . ,Lyric_extender::brew_molecule)
        )
@@ -544,12 +544,13 @@ ScoreContext = \translator {
          (visibility-lambda . ,end-of-line-invisible)
        )
        basicMultiMeasureRestProperties = #`(
+               (spacing-procedure . ,Multi_measure_rest::set_spacing_rods)             
                (molecule-callback . ,Multi_measure_rest::brew_molecule)
                (staff-position . 0)
        )
        basicNoteColumnProperties = #`(
                (axes 0 1)
-               (interfaces . (note-column-interface))
+               (interfaces . (axis-group-interface note-column-interface))
        )
        basicNoteHeadProperties = #`(
                (interfaces . (note-head-interface rhythmic-head-interface))
@@ -566,7 +567,7 @@ ScoreContext = \translator {
                (style . "italic")
        )
        basicPaperColumnProperties = #`(
-               (interfaces . (paper-column-interface))
+               (interfaces . (paper-column-interface axis-group-interface))
                (axes 0)
                (rank . -1)
        )
@@ -597,8 +598,12 @@ ScoreContext = \translator {
        )
        basicSlurProperties = #`(
                (molecule-callback . ,Slur::brew_molecule)
+               (spacing-procedure . ,Slur::set_spacing_rods)           
                (after-line-breaking-callback . ,Slur::after_line_breaking) 
        )
+       basicSpacingSpannerProperties =#`(
+               (spacing-procedure . ,Spacing_spanner::set_springs)
+       )
        basicSpanBarProperties = #`(
                (break-align-symbol . Staff_bar)
                (barsize-procedure . ,Span_bar::get_bar_size) 
@@ -658,6 +663,7 @@ ScoreContext = \translator {
        basicTieProperties = #`(
                (molecule-callback . ,Tie::brew_molecule)
                (after-line-breaking-callback . ,Tie::after_line_breaking)
+               (spacing-procedure . ,Tie::set_spacing_rods)                            
                (interfaces . (tie-interface))
        )
        basicTieColumnProperties = #`(
@@ -689,7 +695,8 @@ ScoreContext = \translator {
                (interfaces . (separation-item-interface))
        )
        basicSeparatingGroupSpannerProperties = #`(
-               (interfaces . (separation-spanner-interface))   
+               (interfaces . (separation-spanner-interface))
+               (spacing-procedure . ,Separating_group_spanner::set_spacing_rods)
        )
        basicInstrumentNameProperties = #`(
                (breakable . #t)
@@ -699,6 +706,7 @@ ScoreContext = \translator {
        )
        basicVerticalAxisGroupProperties = #`(
                (axes 1)
+               (interfaces . (axis-group-interface))
        )
        basicVoltaSpannerProperties = #`(
                (molecule-callback . ,Volta_spanner::brew_molecule)
index 76274fd3f14429067233b7d74316fa573eda31ef..34d3753697795718b88651877d786cbca2081b58 100644 (file)
@@ -1,15 +1,15 @@
 Begin3
 Title: LilyPond
-Version: 1.3.69
-Entered-date: 04JUL00
+Version: 1.3.70
+Entered-date: 05JUL00
 Description: 
 Keywords: music notation typesetting midi fonts engraving
 Author: hanwen@cs.uu.nl (Han-Wen Nienhuys)
        janneke@gnu.org (Jan Nieuwenhuizen)
 Maintained-by: hanwen@stack.nl (Han-Wen Nienhuys)
 Primary-site: sunsite.unc.edu /pub/Linux/apps/sound/convert
-       1000k lilypond-1.3.69.tar.gz 
+       1000k lilypond-1.3.70.tar.gz 
 Original-site: ftp.cs.uu.nl /pub/GNU/LilyPond/development/
-       1000k lilypond-1.3.69.tar.gz 
+       1000k lilypond-1.3.70.tar.gz 
 Copying-policy: GPL
 End
index 50c4436a70a51f6149d5ff72380b8ff80e6a30b3..2195bd605148bc5177c16e4997ec61a703a46ec9 100644 (file)
@@ -1,9 +1,9 @@
 Name: lilypond
-Version: 1.3.69
+Version: 1.3.70
 Release: 1
 Copyright: GPL
 Group: Applications/Publishing
-Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.69.tar.gz
+Source0: ftp.cs.uu.nl:/pub/GNU/LilyPond/development/lilypond-1.3.70.tar.gz
 Summary: A program for printing sheet music.
 URL: http://www.cs.uu.nl/~hanwen/lilypond
 # Icon: lilypond-icon.gif