2 system-start-delimiter.cc -- implement System_start_delimiter
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "axis-group-interface.hh"
12 #include "system-start-delimiter.hh"
13 #include "paper-def.hh"
14 #include "molecule.hh"
15 #include "font-interface.hh"
16 #include "all-font-metrics.hh"
18 #include "staff-symbol-referencer.hh"
22 System_start_delimiter::staff_bracket (Grob*me,Real height)
24 Real arc_height = gh_scm2double (me->get_grob_property ("arch-height")) ;
26 SCM at = gh_list (ly_symbol2scm ("bracket"),
27 me->get_grob_property ("arch-angle"),
28 me->get_grob_property ("arch-width"),
29 gh_double2scm (arc_height),
30 gh_double2scm (height),
31 me->get_grob_property ("arch-thick"),
32 me->get_grob_property ("bracket-thick"),
39 In system-start-delimiter.cc I see the line
41 Real h = height + 2 * arc_height;
43 But I really think that you mean
45 Real h = height + 2 * arc_width;
47 (arc_height changes the x-axis-size of arc ; arc_width changes the
49 Will not fix it since I'm not sure.
53 Real h = height + 2 * arc_height;
54 Box b (Interval (0, 1.5), Interval (-h/2, h/2));
56 mol.align_to (X_AXIS, CENTER);
61 System_start_delimiter::set_interface (Grob*me)
63 me->set_interface (ly_symbol2scm ("system-start-delimiter-interface"));
67 System_start_delimiter::has_interface (Grob*me)
69 return me->has_interface (ly_symbol2scm ("system-start-delimiter-interface"));
73 System_start_delimiter::simple_bar (Grob*me,Real h)
75 Real w = me->paper_l ()->get_var ("stafflinethickness") *
76 gh_scm2double (me->get_grob_property ("thickness"));
77 return Lookup::filledbox (Box (Interval (0,w), Interval (-h/2, h/2)));
80 MAKE_SCHEME_CALLBACK (System_start_delimiter,after_line_breaking,1);
83 System_start_delimiter::after_line_breaking (SCM smob)
85 try_collapse (unsmob_grob (smob));
86 return SCM_UNSPECIFIED;
90 System_start_delimiter::try_collapse (Grob*me)
92 SCM gl = me->get_grob_property ("glyph");
94 if (scm_ilength (me->get_grob_property ("elements")) <= 1 && gl == ly_symbol2scm ("bar-line"))
102 MAKE_SCHEME_CALLBACK (System_start_delimiter,brew_molecule,1);
105 System_start_delimiter::brew_molecule (SCM smob)
107 Grob * me = unsmob_grob (smob);
109 SCM s = me->get_grob_property ("glyph");
110 if (!gh_symbol_p (s))
113 SCM c = me->get_grob_property ((ly_symbol2string (s) + "-collapse-height")
116 Real staff_space = Staff_symbol_referencer::staff_space (me);
117 Interval ext = ly_scm2interval (Axis_group_interface::group_extent_callback
118 (me->self_scm (), gh_int2scm (Y_AXIS)));
119 Real l = ext.length () / staff_space;
122 || (gh_number_p (c) && l <= gh_scm2double (c)))
129 if (s == ly_symbol2scm ("bracket"))
130 m = staff_bracket (me,l);
131 else if (s == ly_symbol2scm ("brace"))
132 m = staff_brace (me,l);
133 else if (s == ly_symbol2scm ("bar-line"))
134 m = simple_bar (me,l);
136 m.translate_axis (ext.center (), Y_AXIS);
137 return m.smobbed_copy ();
141 System_start_delimiter::staff_brace (Grob*me, Real y)
143 Font_metric *fm = Font_interface::get_default_font (me);
146 int hi = 255; //arg, urg == 0: fm->count () >? 2;
149 SCM bigger = gh_list (me->mutable_property_alist_,
150 me->immutable_property_alist_,
153 /* do a binary search for each Y, not very efficient, but passable? */
156 int cmp = (lo + hi) / 2;
158 b = fm->get_char (cmp);
159 if (b[Y_AXIS].empty_b () || b[Y_AXIS].length () > y)
167 We have four fonts: feta-braces0-3.mf
169 In the style-sheet, all paper relative sizes need to start
170 looking at the feta-braces0 font.
172 The smallest paper size, feta11 or -3, has to make 5 steps
173 to get to feta26 or +2. Only after that, from +3 to +5 are
174 the real bigger sizes, so worst case we need 8 steps to get
175 to the font we need. */
178 bigger = gh_cons (gh_cons (ly_symbol2scm ("font-relative-size"),
181 me->set_grob_property ("font", bigger);
182 fm = Font_interface::get_default_font (me);
184 hi = 255; //fm->count () >? 2;
192 SCM at = gh_list (ly_symbol2scm ("char"), gh_int2scm (lo), SCM_UNDEFINED);
193 at = fontify_atom (fm, at);
195 b = fm->get_char (lo);
196 b[X_AXIS] = Interval (0,0);
198 return Molecule (b, at);