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 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(System_start_delimiter,after_line_breaking);
61 System_start_delimiter::after_line_breaking (SCM smob)
63 try_collapse (unsmob_element (smob));
68 System_start_delimiter::try_collapse (Score_element*me)
70 SCM gl = me->get_elt_property ("glyph");
72 if (scm_ilength (me->get_elt_pointer ("elements")) <= 1 && gl == ly_symbol2scm ("bar-line"))
80 MAKE_SCHEME_SCORE_ELEMENT_CALLBACK(System_start_delimiter,brew_molecule);
83 System_start_delimiter::brew_molecule (SCM smob)
85 Score_element * sc = unsmob_element (smob);
87 System_start_delimiter * ssd= dynamic_cast<System_start_delimiter*> (sc);
89 Interval ext = Axis_group_interface::group_extent_callback (sc, Y_AXIS);
90 Real l = ext.length ();
93 SCM s = sc->get_elt_property ("collapse-height");
94 if (gh_number_p (s) && l < gh_scm2double (s))
100 s = sc->get_elt_property ("glyph");
104 if (s == ly_symbol2scm ("bracket"))
105 m = ssd->staff_bracket (l);
106 else if (s == ly_symbol2scm ("brace"))
107 m = ssd-> staff_brace (l);
108 else if (s == ly_symbol2scm ("bar-line"))
109 m = ssd->simple_bar (l);
112 m.translate_axis (ext.center (), Y_AXIS);
113 return m.create_scheme ();
120 System_start_delimiter::staff_brace (Real y) const
122 Real staffht = paper_l ()->get_var ("staffheight");
123 int staff_size = int (rint (staffht ));
127 int minht = 2 * staff_size;
128 int maxht = 7 * minht;
129 int idx = int (((maxht - step) <? y - minht) / step);
132 SCM l = scm_assoc (ly_str02scm ("brace"),
133 scm_eval (ly_symbol2scm ("cmr-alist")));
135 String nm = "feta-braces";
137 nm = ly_scm2string (gh_cdr (l));
138 nm += to_str (staff_size);
139 SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
142 at = fontify_atom (find_font (nm), at);
144 Box b (Interval (0,0), Interval (-y/2, y/2));
146 return Molecule(b, at);