2 paper-column.cc -- implement Paper_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
10 #include "paper-column.hh"
11 #include "paper-score.hh"
13 #include "axis-group-interface.hh"
14 #include "spaceable-grob.hh"
15 #include "molecule.hh"
16 #include "text-item.hh"
18 #include "font-interface.hh"
24 ADD_INTERFACE (Paper_column, "paper-column-interface",
25 " Paper_columns form the top-most item parent. (The Paper_columns X
26 parent is System, which is a spanner.)
28 Paper_columns form the units for the spacing engine. They are
29 numbered, the first (leftmost) is column 0. Numbering happens before
30 line-breaking, and columns are not renumbered after line breaking.
32 Since many columns go unused, you should only use the rank field to
33 get ordering information. Two adjacent columns may have
36 Don't be confused by right-items: each spacing wish can also contain
37 a number of items, with which a spacing constraint may be kept. It's
38 a little baroque, but it might come in handy later on?
41 "between-cols between-system-string when bounded-by-me shortest-playing-duration shortest-starter-duration");
45 Paper_column::do_break_processing ()
47 Spaceable_grob::remove_interface (this);
48 Item::do_break_processing ();
53 Paper_column::rank_i (Grob*me)
55 return dynamic_cast<Paper_column*> (me)->rank_i_;
59 Paper_column::line_l () const
65 Paper_column::column_l () const
67 return (Paper_column*) (this);
70 Paper_column::Paper_column (SCM l)
78 Paper_column::when_mom (Grob*me)
80 SCM m = me->get_grob_property ("when");
82 if (unsmob_moment (m))
84 return *unsmob_moment (m);
90 Paper_column::musical_b (Grob *me)
92 SCM m = me->get_grob_property ("shortest-starter-duration");
94 if (unsmob_moment (m))
96 s = *unsmob_moment (m);
98 return s != Moment (0);
104 Paper_column::used_b (Grob*me)
106 return gh_pair_p (me->get_grob_property ("elements")) || Item::breakable_b (me)
107 || gh_pair_p (me->get_grob_property ("bounded-by-me"))
112 Print a vertical line and the rank number, to aid debugging.
115 MAKE_SCHEME_CALLBACK(Paper_column,brew_molecule,1);
117 Paper_column::brew_molecule (SCM p)
119 Grob *me = unsmob_grob (p);
121 String r = to_str (Paper_column::rank_i (me));
122 SCM properties = Font_interface::font_alist_chain (me);
124 Molecule t = Text_item::text2molecule (me, ly_str02scm (r.ch_C()),
126 t.align_to (X_AXIS, CENTER);
127 t.align_to (Y_AXIS, DOWN);
129 Molecule l = Lookup::filledbox (Box (Interval (-0.01, 0.01),
133 return t.smobbed_copy ();
137 This is all too hairy. We use bounded-by-me to make sure that some
138 columns are kept "alive". Unfortunately, when spanners are suicided,
139 this falls apart again. (sigh.)
141 THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER.
143 MAKE_SCHEME_CALLBACK(Paper_column,before_line_breaking,1);
145 Paper_column::before_line_breaking (SCM grob)
147 Grob *me = unsmob_grob (grob);
149 SCM c = me->get_grob_property ("bounded-by-me");
152 while (gh_pair_p (*ptrptr))
154 Grob * g = unsmob_grob (gh_car (*ptrptr));
156 if (!g || !g->live ())
158 *ptrptr = gh_cdr (*ptrptr);
162 ptrptr = SCM_CDRLOC (*ptrptr);
166 me->set_grob_property ("bounded-by-me", c);
167 return SCM_UNSPECIFIED;