2 system-start-delimiter.cc -- implement System_start_delimiter
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 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"
16 #include "all-font-metrics.hh"
17 #include "score-element.hh"
20 System_start_delimiter::staff_bracket (Score_element*me,Real height)
22 Paper_def* p= me->paper_l ();
23 SCM scmss = p->get_scmvar ("staffspace");
24 Real ss = gh_scm2double (scmss);
25 Real arc_height = gh_scm2double (me->get_elt_property("arch-height")) * ss ;
27 SCM at = gh_list (ly_symbol2scm ("bracket"),
28 scm_product (me->get_elt_property ("arch-angle"), scmss),
29 scm_product (me->get_elt_property ("arch-width"), scmss),
30 gh_double2scm (arc_height),
31 scm_product (me->get_elt_property ("bracket-width"),scmss),
32 gh_double2scm (height),
33 scm_product (me->get_elt_property ("arch-thick"),scmss),
34 scm_product (me->get_elt_property ("bracket-thick"),scmss),
37 Real h = height + 2 * arc_height;
38 Box b (Interval (0, 1.5 * ss), Interval (-h/2, h/2));
40 mol.align_to (X_AXIS, CENTER);
45 System_start_delimiter::set_interface (Score_element*me)
47 me->set_extent_callback (SCM_EOL, Y_AXIS);
48 me->set_interface (ly_symbol2scm ("system-start-delimiter-interface"));
52 System_start_delimiter::has_interface (Score_element*me)
54 return me->has_interface (ly_symbol2scm ("system-start-delimiter-interface"));
58 System_start_delimiter::simple_bar (Score_element*me,Real h)
60 Real w = me->paper_l ()->get_var ("stafflinethickness") *
61 gh_scm2double (me->get_elt_property ("thickness"));
62 return me->lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
65 MAKE_SCHEME_CALLBACK(System_start_delimiter,after_line_breaking,1);
68 System_start_delimiter::after_line_breaking (SCM smob)
70 try_collapse (unsmob_element (smob));
71 return SCM_UNSPECIFIED;
75 System_start_delimiter::try_collapse (Score_element*me)
77 SCM gl = me->get_elt_property ("glyph");
79 if (scm_ilength (me->get_elt_property ("elements")) <= 1 && gl == ly_symbol2scm ("bar-line"))
87 MAKE_SCHEME_CALLBACK(System_start_delimiter,brew_molecule,1);
90 System_start_delimiter::brew_molecule (SCM smob)
92 Score_element * me = unsmob_element (smob);
93 Interval ext = ly_scm2interval (Axis_group_interface::group_extent_callback (me->self_scm(), gh_int2scm (Y_AXIS)));
94 Real l = ext.length ();
97 SCM s = me->get_elt_property ("collapse-height");
98 if (gh_number_p (s) && l < gh_scm2double (s))
104 s = me->get_elt_property ("glyph");
108 if (s == ly_symbol2scm ("bracket"))
109 m = staff_bracket (me,l);
110 else if (s == ly_symbol2scm ("brace"))
111 m = staff_brace (me,l);
112 else if (s == ly_symbol2scm ("bar-line"))
113 m = simple_bar (me,l);
116 m.translate_axis (ext.center (), Y_AXIS);
117 return m.create_scheme ();
124 System_start_delimiter::staff_brace (Score_element*me,Real y)
126 Real staffht = me->paper_l ()->get_var ("staffheight");
127 int staff_size = int (rint (staffht ));
131 int minht = 2 * staff_size;
132 int maxht = 7 * minht;
133 int idx = int (((maxht - step) <? y - minht) / step);
136 SCM l = scm_assoc (ly_str02scm ("brace"),
137 scm_eval2 (ly_symbol2scm ("cmr-alist"), SCM_EOL));
139 String nm = "feta-braces";
141 nm = ly_scm2string (gh_cdr (l));
142 nm += to_str (staff_size);
143 SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
146 at = fontify_atom (find_font (nm), at);
148 Box b (Interval (0,0), Interval (-y/2, y/2));
150 return Molecule(b, at);