2 paper-column.cc -- implement Paper_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2005 Han-Wen Nienhuys <hanwen@cs.uu.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::get_column () const
51 return (Paper_column *) (this);
54 Paper_column::Paper_column (SCM l, Object_key const *key)
55 : Item (l, key) // guh.?
61 Paper_column::Paper_column (Paper_column const &src, int count)
69 Paper_column::when_mom (Grob *me)
71 SCM m = me->get_property ("when");
72 if (Moment *when = unsmob_moment (m))
78 Paper_column::is_musical (Grob *me)
80 SCM m = me->get_property ("shortest-starter-duration");
82 if (unsmob_moment (m))
83 s = *unsmob_moment (m);
84 return s != Moment (0);
88 Paper_column::is_used (Grob *me)
90 extract_grob_set (me, "elements", elts);
94 extract_grob_set (me, "bounded-by-me", bbm);
98 if (Item::is_breakable (me))
101 if (to_boolean (me->get_property ("used")))
107 Print a vertical line and the rank number, to aid debugging.
110 MAKE_SCHEME_CALLBACK (Paper_column, print, 1);
112 Paper_column::print (SCM p)
114 Grob *me = unsmob_grob (p);
116 String r = to_string (Paper_column::get_rank (me));
118 Moment *mom = unsmob_moment (me->get_property ("when"));
119 String when = mom ? mom->to_string () : "?/?";
121 SCM properties = Font_interface::text_font_alist_chain (me);
123 SCM scm_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (),
125 scm_makfrom0str (r.to_str0 ()));
126 SCM when_mol = Text_interface::interpret_markup (me->get_layout ()->self_scm (),
128 scm_makfrom0str (when.to_str0 ()));
129 Stencil t = *unsmob_stencil (scm_mol);
130 t.add_at_edge (Y_AXIS, DOWN, *unsmob_stencil (when_mol), 0.1, 0.1);
131 t.align_to (X_AXIS, CENTER);
132 t.align_to (Y_AXIS, DOWN);
134 Stencil l = Lookup::filled_box (Box (Interval (-0.01, 0.01),
138 return t.smobbed_copy ();
142 This is all too hairy. We use bounded-by-me to make sure that some
143 columns are kept "alive". Unfortunately, when spanners are suicided,
144 this falls apart again, because suicided spanners are still in
147 THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER.
149 MAKE_SCHEME_CALLBACK (Paper_column, before_line_breaking, 1);
151 Paper_column::before_line_breaking (SCM grob)
153 Grob *me = unsmob_grob (grob);
155 SCM bbm = me->get_object ("bounded-by-me");
156 Grob_array *ga = unsmob_grob_array (bbm);
158 return SCM_UNSPECIFIED;
160 Link_array<Grob> &array (ga->array_reference ());
162 for (int i = array.size (); i--;)
166 if (!g || !g->is_live ())
167 { // UGH . potentially quadratic.
172 return SCM_UNSPECIFIED;
176 ADD_INTERFACE (Paper_column,
178 "paper-column-interface",
179 "@code{Paper_column} objects form the top-most X-parents for items."
180 " The are two types of columns: musical columns, where are attached to, and "
181 " non-musical columns, where bar-lines, clefs etc. are attached to. "
182 " The spacing engine determines the X-positions of these objects."
186 " numbered, the first (leftmost) is column 0. Numbering happens before\n"
187 " line-breaking, and columns are not renumbered after line breaking.\n"
188 " Since many columns go unused, you should only use the rank field to\n"
189 " get ordering information. Two adjacent columns may have\n"
190 " non-adjacent numbers.\n",
196 "line-break-system-details "
198 "shortest-playing-duration "
199 "shortest-starter-duration "