2 staff-spacing.cc -- implement Staff_spacing
4 source file of the GNU LilyPond music typesetter
6 (c) 2001--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "paper-column.hh"
10 #include "separation-item.hh"
12 #include "staff-spacing.hh"
17 Staff_spacing::has_interface (Grob* g)
19 return g && g->has_interface (ly_symbol2scm ("staff-spacing-interface"));
26 Staff_spacing::get_spacing_params (Grob *me, Real * space, Real * fixed)
33 Grob * separation_item=0;
35 for (SCM s = me->get_grob_property ("left-items");
36 gh_pair_p (s); s = gh_cdr(s))
38 Grob * cand = unsmob_grob(gh_car (s));
39 if (cand && Separation_item::has_interface (cand))
40 separation_item = cand ;
43 Grob *left_col = dynamic_cast<Item*> (me)->column_l ();
50 programming_error ("no sep item");
54 for (SCM s = separation_item->get_grob_property ("elements");
55 gh_pair_p (s); s = gh_cdr (s))
57 Grob * break_item = unsmob_grob (gh_car (s));
60 if (!gh_symbol_p (break_item->get_grob_property ("break-align-symbol")))
63 Interval ext = break_item->extent (left_col, X_AXIS);
68 || (last_grob && ext[RIGHT] > last_ext[RIGHT]))
71 last_grob = break_item;
77 programming_error ("empty break column? --fixme");
81 *fixed = last_ext[RIGHT];
82 *space = *fixed + 1.0;
84 SCM alist = last_grob->get_grob_property ("space-alist");
85 if (!scm_list_p (alist))
88 SCM space_def = scm_sloppy_assq (ly_symbol2scm ("begin-of-note"), alist);
89 if (!gh_pair_p (space_def))
91 programming_error ("Unknown prefatory spacing. ");
95 space_def = gh_cdr (space_def);
96 Real distance = gh_scm2double (gh_cdr (space_def));
97 SCM type = gh_car (space_def) ;
99 *fixed = last_ext[RIGHT];
100 if (type == ly_symbol2scm ("extra-space"))
101 *space = *fixed + distance;
102 else if (type == ly_symbol2scm("minimum-space"))
103 *space = last_ext[LEFT] + (last_ext.length () >? distance);