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 "system-start-delimiter.hh"
12 #include "paper-def.hh"
13 #include "molecule.hh"
14 #include "axis-group-interface.hh"
16 #include "all-font-metrics.hh"
19 System_start_delimiter::staff_bracket (Real height) const
21 Paper_def* p= paper_l ();
22 SCM scmss = p->get_scmvar ("staffspace");
23 Real ss = gh_scm2double (scmss);
24 Real arc_height = gh_scm2double (get_elt_property("arch-height")) * ss ;
26 SCM at = gh_list (ly_symbol2scm ("bracket"),
27 scm_product (get_elt_property ("arch-angle"), scmss),
28 scm_product (get_elt_property ("arch-width"), scmss),
29 gh_double2scm (arc_height),
30 scm_product (get_elt_property ("bracket-width"),scmss),
31 gh_double2scm (height),
32 scm_product (get_elt_property ("arch-thick"),scmss),
33 scm_product (get_elt_property ("bracket-thick"),scmss),
36 Real h = height + 2 * arc_height;
37 Box b (Interval (0, 1.5 * ss), Interval (-h/2, h/2));
39 mol.align_to (X_AXIS, CENTER);
43 System_start_delimiter::System_start_delimiter (SCM s)
46 set_extent_callback (0, Y_AXIS);
47 Pointer_group_interface (this).set_interface();
51 System_start_delimiter::simple_bar (Real h) const
53 Real w = paper_l ()->get_var ("stafflinethickness") *
54 gh_scm2double (get_elt_property ("thickness"));
55 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
58 GLUE_SCORE_ELEMENT(System_start_delimiter,after_line_breaking);
60 System_start_delimiter::member_after_line_breaking ()
62 SCM gl = get_elt_property ("glyph");
64 if (scm_ilength (get_elt_pointer ("elements")) <= 1 && gl == ly_symbol2scm ("bar-line"))
71 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(System_start_delimiter,brew_molecule);
74 System_start_delimiter::brew_molecule (SCM smob)
76 Score_element * sc = unsmob_element (smob);
78 System_start_delimiter * ssd= dynamic_cast<System_start_delimiter*> (sc);
80 Interval ext = Axis_group_interface::group_extent_callback (sc, Y_AXIS);
81 Real l = ext.length ();
84 SCM s = sc->get_elt_property ("collapse-height");
85 if (gh_number_p (s) && l < gh_scm2double (s))
91 s = sc->get_elt_property ("glyph");
95 if (s == ly_symbol2scm ("bracket"))
96 m = ssd->staff_bracket (l);
97 else if (s == ly_symbol2scm ("brace"))
98 m = ssd-> staff_brace (l);
99 else if (s == ly_symbol2scm ("bar-line"))
100 m = ssd->simple_bar (l);
103 m.translate_axis (ext.center (), Y_AXIS);
104 return m.create_scheme ();
111 System_start_delimiter::staff_brace (Real y) const
113 Real staffht = paper_l ()->get_var ("staffheight");
114 int staff_size = int (rint (staffht ));
118 int minht = 2 * staff_size;
119 int maxht = 7 * minht;
120 int idx = int (((maxht - step) <? y - minht) / step);
123 SCM l = scm_assoc (ly_str02scm ("brace"),
124 scm_eval (ly_symbol2scm ("cmr-alist")));
126 String nm = "feta-braces";
128 nm = ly_scm2string (gh_cdr (l));
129 nm += to_str (staff_size);
130 SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
133 at = fontify_atom (find_font (nm), at);
135 Box b (Interval (0,0), Interval (-y/2, y/2));
137 return Molecule(b, at);