2 system-start-delimiter.cc -- implement System_start_delimiter
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "system-start-delimiter.hh"
14 #include "axis-group-interface.hh"
15 #include "output-def.hh"
16 #include "font-interface.hh"
17 #include "all-font-metrics.hh"
18 #include "staff-symbol-referencer.hh"
23 System_start_delimiter::old_staff_bracket (Grob *me, Real height)
25 Real arc_height = scm_to_double (me->get_property ("arch-height"));
27 SCM at = scm_list_n (ly_symbol2scm ("bracket"),
28 me->get_property ("arch-angle"),
29 me->get_property ("arch-width"),
30 scm_make_real (arc_height),
31 scm_make_real (height),
32 me->get_property ("arch-thick"),
33 me->get_property ("thickness"),
40 In system-start-delimiter.cc I see the line
42 Real h = height + 2 * arc_height;
44 But I really think that you mean
46 Real h = height + 2 * arc_width;
48 (arc_height changes the x-axis-size of arc ; arc_width changes the
50 Will not fix it since I'm not sure.
54 Real h = height + 2 * arc_height;
55 Box b (Interval (0, 1.5), Interval (-h / 2, h / 2));
57 mol.align_to (X_AXIS, CENTER);
64 System_start_delimiter::staff_bracket (Grob *me, Real height)
66 Font_metric *fm = Font_interface::get_default_font (me);
67 Drul_array<Stencil> tips (fm->find_by_name ("brackettips.down"),
68 fm->find_by_name ("brackettips.up"));
70 Real thickness = robust_scm2double (me->get_property ("thickness"), 0.25);
72 Stencil bracket = Lookup::filled_box (Box (Interval (0, thickness),
73 Interval (-height/2, height/2)));
78 bracket.add_at_edge (Y_AXIS, d, tips[d], 0.0, 0.0);
80 while (flip (&d) != DOWN);
82 bracket.translate_axis (-1.0, X_AXIS); // ugh.
88 System_start_delimiter::simple_bar (Grob *me, Real h)
90 Real lt = me->get_layout ()->get_dimension (ly_symbol2scm ("linethickness"));
91 Real w = lt * robust_scm2double (me->get_property ("thickness"), 1);
92 return Lookup::round_filled_box (Box (Interval (0, w), Interval (-h / 2, h / 2)),
96 MAKE_SCHEME_CALLBACK (System_start_delimiter, after_line_breaking, 1);
99 System_start_delimiter::after_line_breaking (SCM smob)
101 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
103 SCM gl = me->get_property ("glyph");
104 if (ly_c_equal_p (gl, scm_makfrom0str ("bar-line")))
107 Paper_column *left_column = me->get_bound (LEFT)->get_column ();
110 Get all coordinates, to trigger Hara kiri.
112 SCM elts = me->get_property ("elements");
113 Grob *common = common_refpoint_of_list (elts, me, Y_AXIS);
114 for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
116 Spanner *staff = dynamic_cast<Spanner*> (unsmob_grob (scm_car (s)));
118 staff->get_bound (LEFT)->get_column () != left_column)
121 Interval v = staff->extent (common, Y_AXIS);
132 return SCM_UNSPECIFIED;
135 MAKE_SCHEME_CALLBACK (System_start_delimiter, print, 1);
137 System_start_delimiter::print (SCM smob)
139 Spanner *me = unsmob_spanner (smob);
143 SCM s = me->get_property ("glyph");
144 if (!scm_is_string (s))
146 SCM gsym = scm_string_to_symbol (s);
148 Real staff_space = Staff_symbol_referencer::staff_space (me);
150 SCM elts = me->get_property ("elements");
151 Grob *common = common_refpoint_of_list (elts, me, Y_AXIS);
154 for (SCM s = elts; scm_is_pair (s); s = scm_cdr (s))
156 Spanner *sp = unsmob_spanner (scm_car (s));
158 && sp->get_bound (LEFT) == me->get_bound (LEFT))
160 Interval dims = sp->extent (common, Y_AXIS);
161 if (!dims.is_empty ())
166 ext -= me->relative_coordinate (common, Y_AXIS);
168 Real len = ext.length () / staff_space;
171 || (robust_scm2double (me->get_property ("collapse-height"), 0.0) >= len))
179 if (gsym == ly_symbol2scm ("bracket"))
180 m = staff_bracket (me, len);
181 else if (gsym == ly_symbol2scm ("brace"))
182 m = staff_brace (me, len);
183 else if (gsym == ly_symbol2scm ("bar-line"))
184 m = simple_bar (me, len);
186 m.translate_axis (ext.center (), Y_AXIS);
187 return m.smobbed_copy ();
191 System_start_delimiter::staff_brace (Grob *me, Real y)
194 /* We go through the style sheet to lookup the font file
195 name. This is better than using find_font directly,
196 esp. because that triggers mktextfm for non-existent
198 SCM fam = scm_cons (ly_symbol2scm ("font-encoding"),
199 ly_symbol2scm ("fetaBraces"));
201 SCM alist = scm_list_n (fam, SCM_UNDEFINED);
202 fm = select_font (me->get_layout (), scm_list_n (alist, SCM_UNDEFINED));
205 int hi = max (fm->count () - 1,2);
208 /* do a binary search for each Y, not very efficient, but passable? */
211 int cmp = (lo + hi) / 2;
212 b = fm->get_indexed_char (cmp);
213 if (b[Y_AXIS].is_empty () || b[Y_AXIS].length () > y)
220 Stencil stil (fm->find_by_name ("brace" + to_string (lo)));
221 b = stil.extent_box ();
222 b[X_AXIS] = Interval (0, 0);
224 return Stencil (b, stil.expr ());
227 ADD_INTERFACE (System_start_delimiter, "system-start-delimiter-interface",
228 "The brace, bracket or bar in front of the system. "
229 "It is implemented as a spanner.",
230 "collapse-height thickness "
231 "arch-height arch-angle arch-thick arch-width bracket-thick glyph");