#ifndef SPACING_SPANNER_HH
#define SPACING_SPANNER_HH
-#include "spanner.hh"
-#include "spring.hh"
-
-class New_spacing_spanner
-{
-public:
- static void set_interface (Grob*);
- static void do_measure (Grob*,Link_array<Grob> *) ;
- static void stretch_to_regularity (Grob*, Array<Spring> *, Link_array<Grob> const &);
- static void breakable_column_spacing (Item* l, Item *r);
- DECLARE_SCHEME_CALLBACK (set_springs, (SCM ));
- static Real stem_dir_correction (Grob*,Grob*,Grob*) ;
- static Real default_bar_spacing (Grob*,Grob*,Grob*,Moment) ;
- static Real note_spacing (Grob*,Grob*,Grob*,Moment) ;
- static Real get_duration_space (Grob*,Moment dur, Moment shortest) ;
-};
-
-#endif /* SPACING_SPANNER_HH */
-
*/
-#include "new-spacing-spanner.hh"
#include "paper-column.hh"
#include "dimensions.hh"
#include "paper-def.hh"
#include "line-of-score.hh"
#include "misc.hh"
#include "separation-item.hh"
+#include "spanner.hh"
+#include "spring.hh"
+class New_spacing_spanner
+{
+public:
+ static void set_interface (Grob*);
+ static void do_measure (Grob*,Link_array<Grob> *) ;
+ static void stretch_to_regularity (Grob*, Array<Spring> *, Link_array<Grob> const &);
+ static void breakable_column_spacing (Item* l, Item *r);
+ DECLARE_SCHEME_CALLBACK (set_springs, (SCM ));
+ static Real stem_dir_correction (Grob*,Grob*,Grob*) ;
+ static Real default_bar_spacing (Grob*,Grob*,Grob*,Moment) ;
+ static Real note_spacing (Grob*,Grob*,Grob*,Moment) ;
+ static Real get_duration_space (Grob*,Moment dur, Moment shortest) ;
+ static void prune_loose_colunms (Link_array<Grob>*);
+};
void
New_spacing_spanner::set_interface (Grob*me)
me->set_extent_callback (SCM_EOL, Y_AXIS) ;
}
+/*
+ Remove all columns that are not tightly
+ fitting part of the spacing problem.
+ */
+void
+New_spacing_spanner::prune_loose_colunms (Link_array<Grob> *cols)
+{
+ for (int i = cols->size(); i--;)
+ {
+ SCM between = cols->elem(i)->get_grob_property ("between-cols");
+ if (!gh_pair_p (between))
+ continue;
+
+ Item * l = dynamic_cast<Item*> (unsmob_grob (gh_car (between)));
+ Item * r = dynamic_cast<Item*> (unsmob_grob (gh_cdr (between)));
+ if (l->column_l () != cols->elem (i-1)
+ || r->column_l () != cols->elem (i +1))
+ {
+ cols->del (i);
+ }
+ }
+}
+
/*
The algorithm is partly taken from :
Moment base_shortest_duration = *unsmob_moment (me->get_grob_property ("maximum-duration-for-spacing"));
shortest_in_measure.set_infinite (1);
- for (int i = cols->size(); i--;)
- {
- if (gh_pair_p (cols->elem(i)->get_grob_property ("between-cols")))
- cols->del (i);
- }
-
+ prune_loose_colunms (cols);
for (int i =0 ; i < cols->size (); i++)
{
Direction dir = LEFT;
do
{
- if (!gh_symbol_p (index_cell (me->get_grob_property ("attachment"), dir)))
+ SCM att = me->get_grob_property ("attachment");
+ /*
+ */
+ if (!gh_pair_p (att))
+ {
+ programming_error ("attachment is not a cons?!");
+ att = gh_cons (SCM_EOL, SCM_EOL);
+ me->set_grob_property ("attachment", att);
+ }
+
+ if (!gh_symbol_p (index_cell (att, dir)))
{
for (SCM s = me->get_grob_property ("extremity-rules");
s != SCM_EOL; s = ly_cdr (s))
gh_int2scm ((int)dir));
if (r != SCM_BOOL_F)
{
- index_set_cell (me->get_grob_property ("attachment"), dir,
+ index_set_cell (att, dir,
ly_cdar (s));
break;
}
me->set_extent_callback (SCM_EOL, Y_AXIS) ;
}
-#if 0
-struct Note_run
-{
- Array<int> idxes;
- int start, end;
- Moment duration;
- int count;
-};
-
-int
-column_compare (Grob *const &t1, Grob *const &t2)
-{
- return Moment::compare (Paper_column::when_mom (t1),
- Paper_column::when_mom (t2));
-}
-
-
-Note_run
-run_length (Moment dt, int i, Array<Moment> const &moms,
- Link_array<Note_run> runs)
-{
- int k = 0;
- Array<int> idxes;
-
- idxes.push (i);
- while (1)
- {
- Moment next = moms[i] + dt;
- while (i < moms.size () && moms[i] < next)
- i++;
- if (i == moms.size () || moms[i] != next)
- break;
-
- idxes.push (i);
- k++;
- }
-
- Moment dur = idxes.size ()
-}
-
-void
-find_runs (Grob*me, Link_array<Grob> cols)
-{
- Link_array<Grob> filter_cols;
- Array<Moment> col_moments;
- for (int i = 0; i < cols.size (); i++)
- {
- Moment w = Paper_column::when_mom (cols[i]);
-
- if (!w.grace_part_ && Paper_column::musical_b (cols[i]))
- {
- filter_cols.push (cols[i]);
- col_moments.push (w);
- }
- }
-
- Moment end_mom = col_moments.top ();
- for (int i = 0; i < col_moments.size () ; i++)
- {
- for (int j = i+1; j < col_moments.size (); j++)
- {
- Moment dt = Paper_column::col_momentsfilter_cols
- }
- }
-}
-#endif
-
/*
The algorithm is partly taken from :
;;; Jan Nieuwenhuizen <janneke@gnu.org>
-(eval-string (ly-gulp-file "translator-description.scm"))
;; alist of translater descriptions
(define (document-translator-property sym)