2 paper-column.cc -- implement Paper_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
9 #include "paper-column.hh"
12 #include "paper-score.hh"
14 #include "axis-group-interface.hh"
15 #include "spaceable-grob.hh"
16 #include "text-interface.hh"
18 #include "font-interface.hh"
19 #include "output-def.hh"
20 #include "pointer-group-interface.hh"
21 #include "grob-array.hh"
24 Paper_column::clone (int count) const
26 return new Paper_column (*this, count);
30 Paper_column::do_break_processing ()
32 Spaceable_grob::remove_interface (this);
33 Item::do_break_processing ();
37 Paper_column::get_rank (Grob *me)
39 return dynamic_cast<Paper_column *> (me)->rank_;
43 Paper_column::get_system () const
49 Paper_column::set_system (System *s)
55 Paper_column::get_column () const
57 return (Paper_column *) (this);
60 Paper_column::Paper_column (SCM l, Object_key const *key)
61 : Item (l, key) // guh.?
67 Paper_column::Paper_column (Paper_column const &src, int count)
75 Paper_column::compare (Grob * const &a,
78 return sign (dynamic_cast<Paper_column*> (a)->rank_
79 - dynamic_cast<Paper_column*> (b)->rank_);
83 Paper_column::when_mom (Grob *me)
85 SCM m = me->get_property ("when");
86 if (Moment *when = unsmob_moment (m))
92 Paper_column::is_musical (Grob *me)
94 SCM m = me->get_property ("shortest-starter-duration");
96 if (unsmob_moment (m))
97 s = *unsmob_moment (m);
98 return s != Moment (0);
102 Paper_column::is_used (Grob *me)
104 extract_grob_set (me, "elements", elts);
108 extract_grob_set (me, "bounded-by-me", bbm);
112 if (Paper_column::is_breakable (me))
115 if (to_boolean (me->get_property ("used")))
121 Paper_column::is_breakable (Grob *me)
123 return scm_is_symbol (me->get_property ("line-break-permission"));
127 Print a vertical line and the rank number, to aid debugging.
130 MAKE_SCHEME_CALLBACK (Paper_column, print, 1);
132 Paper_column::print (SCM p)
134 Grob *me = unsmob_grob (p);
136 string r = to_string (Paper_column::get_rank (me));
138 Moment *mom = unsmob_moment (me->get_property ("when"));
139 string when = mom ? mom->to_string () : "?/?";
141 SCM properties = Font_interface::text_font_alist_chain (me);
143 SCM scm_mol = Text_interface::interpret_markup (me->layout ()->self_scm (),
145 scm_makfrom0str (r.c_str ()));
146 SCM when_mol = Text_interface::interpret_markup (me->layout ()->self_scm (),
148 scm_makfrom0str (when.c_str ()));
149 Stencil t = *unsmob_stencil (scm_mol);
150 t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1, 0.1);
151 t.align_to (X_AXIS, CENTER);
152 t.align_to (Y_AXIS, DOWN);
154 Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01),
158 return t.smobbed_copy ();
162 This is all too hairy. We use bounded-by-me to make sure that some
163 columns are kept "alive". Unfortunately, when spanners are suicided,
164 this falls apart again, because suicided spanners are still in
167 THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER.
169 MAKE_SCHEME_CALLBACK (Paper_column, before_line_breaking, 1);
171 Paper_column::before_line_breaking (SCM grob)
173 Grob *me = unsmob_grob (grob);
175 SCM bbm = me->get_object ("bounded-by-me");
176 Grob_array *ga = unsmob_grob_array (bbm);
178 return SCM_UNSPECIFIED;
180 vector<Grob*> &array (ga->array_reference ());
182 for (vsize i = array.size (); i--;)
186 if (!g || !g->is_live ())
187 /* UGH . potentially quadratic. */
188 array.erase (array.begin () + i);
191 return SCM_UNSPECIFIED;
195 ADD_INTERFACE (Paper_column,
197 "paper-column-interface",
198 "@code{Paper_column} objects form the top-most X-parents for items."
199 " The are two types of columns: musical columns, where are attached to, and "
200 " non-musical columns, where bar-lines, clefs etc. are attached to. "
201 " The spacing engine determines the X-positions of these objects."
205 " numbered, the first (leftmost) is column 0. Numbering happens before\n"
206 " line-breaking, and columns are not renumbered after line breaking.\n"
207 " Since many columns go unused, you should only use the rank field to\n"
208 " get ordering information. Two adjacent columns may have\n"
209 " non-adjacent numbers.\n",
216 "line-break-system-details "
217 "line-break-penalty "
218 "line-break-permission "
219 "page-break-penalty "
220 "page-break-permission "
222 "page-turn-permission "
223 "shortest-playing-duration "
224 "shortest-starter-duration "