2 paper-column.cc -- implement Paper_column
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2004 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"
16 #include "text-item.hh"
18 #include "font-interface.hh"
19 #include "paper-def.hh"
24 ADD_INTERFACE (Paper_column
, "paper-column-interface",
25 "@code{Paper_column} objects form the top-most X-parents for items. "
26 " The are two types of columns: musical columns, where are attached to, and "
27 " non-musical columns, where bar-lines, clefs etc. are attached to. "
28 " The spacing engine determines the X-positions of these objects."
31 " numbered, the first (leftmost) is column 0. Numbering happens before\n"
32 " line-breaking, and columns are not renumbered after line breaking.\n"
33 " Since many columns go unused, you should only use the rank field to\n"
34 " get ordering information. Two adjacent columns may have\n"
35 " non-adjacent numbers.\n"
38 "between-cols between-system-string when bounded-by-me "
39 "shortest-playing-duration shortest-starter-duration");
42 Paper_column::do_break_processing ()
44 Spaceable_grob::remove_interface (this);
45 Item::do_break_processing ();
50 Paper_column::get_rank (Grob
*me
)
52 return dynamic_cast<Paper_column
*> (me
)->rank_
;
56 Paper_column::get_system () const
62 Paper_column::get_column () const
64 return (Paper_column
*) (this);
67 Paper_column::Paper_column (SCM l
)
75 Paper_column::when_mom (Grob
*me
)
77 SCM m
= me
->get_property ("when");
79 if (unsmob_moment (m
))
81 return *unsmob_moment (m
);
87 Paper_column::is_musical (Grob
*me
)
89 SCM m
= me
->get_property ("shortest-starter-duration");
91 if (unsmob_moment (m
))
93 s
= *unsmob_moment (m
);
95 return s
!= Moment (0);
100 Paper_column::is_used (Grob
*me
)
102 return gh_pair_p (me
->get_property ("elements")) || Item::is_breakable (me
)
103 || gh_pair_p (me
->get_property ("bounded-by-me"))
108 Print a vertical line and the rank number, to aid debugging.
111 MAKE_SCHEME_CALLBACK (Paper_column
,print
,1);
113 Paper_column::print (SCM p
)
115 Grob
*me
= unsmob_grob (p
);
117 String r
= to_string (Paper_column::get_rank (me
));
118 SCM properties
= Font_interface::text_font_alist_chain (me
);
120 SCM scm_mol
= Text_item::interpret_markup (me
->get_paper ()->self_scm (),
122 scm_makfrom0str (r
.to_str0 ()));
123 Stencil t
= *unsmob_stencil (scm_mol
);
124 t
.align_to (X_AXIS
, CENTER
);
125 t
.align_to (Y_AXIS
, DOWN
);
127 Stencil l
= Lookup::filled_box (Box (Interval (-0.01, 0.01),
131 return t
.smobbed_copy ();
135 This is all too hairy. We use bounded-by-me to make sure that some
136 columns are kept "alive". Unfortunately, when spanners are suicided,
137 this falls apart again. (sigh.)
139 THIS IS BROKEN KLUDGE. WE SHOULD INVENT SOMETHING BETTER.
141 MAKE_SCHEME_CALLBACK (Paper_column
,before_line_breaking
,1);
143 Paper_column::before_line_breaking (SCM grob
)
145 Grob
*me
= unsmob_grob (grob
);
147 SCM c
= me
->get_property ("bounded-by-me");
150 while (gh_pair_p (*ptrptr
))
152 Grob
* g
= unsmob_grob (gh_car (*ptrptr
));
154 if (!g
|| !g
->live ())
156 *ptrptr
= gh_cdr (*ptrptr
);
160 ptrptr
= SCM_CDRLOC (*ptrptr
);
164 me
->set_property ("bounded-by-me", c
);
165 return SCM_UNSPECIFIED
;