2 bar.cc -- implement Bar
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "dimensions.hh"
12 #include "dimension-cache.hh"
15 #include "molecule.hh"
16 #include "paper-def.hh"
19 #include "all-font-metrics.hh"
23 set_elt_property ("breakable", SCM_BOOL_T);
28 Bar::get_bar_size () const
36 Bar::do_brew_molecule () const
38 SCM s = get_elt_property ("glyph");
41 String str =ly_scm2string (s);
43 return staff_bracket (get_bar_size ());
44 else if (str == "brace")
45 return staff_brace (get_bar_size ());
47 return compound_barline (str, get_bar_size ());
54 Bar::staff_bracket (Real height) const
56 Paper_def* p= paper_l ();
57 Real arc_height = p->get_var("bracket_arch_height");
58 SCM at = gh_list (ly_symbol2scm ("bracket"),
59 gh_double2scm (p->get_var("bracket_arch_angle")),
60 gh_double2scm (p->get_var("bracket_arch_width")),
61 gh_double2scm (arc_height),
62 gh_double2scm (p->get_var("bracket_width")),
63 gh_double2scm (height),
64 gh_double2scm (p->get_var("bracket_arch_thick")),
65 gh_double2scm (p->get_var("bracket_thick")),
68 Real staff_space = p->get_var ("interline");
69 Real h = height + 2 * arc_height;
70 Box b (Interval (0, 1.5 * staff_space), Interval (-h/2, h/2));
73 mol.translate_axis (- mol.dim_[X_AXIS].length () / 2, X_AXIS);
78 Bar::compound_barline (String str, Real h) const
80 Real kern = paper_l()->get_var ("bar_kern");
81 Real thinkern = paper_l()->get_var ("bar_thinkern");
83 Molecule thin = simple_barline (paper_l()->get_var ("barthick_thin"), h);
84 Molecule thick = simple_barline (paper_l()->get_var ("barthick_thick"), h);
85 Molecule colon = lookup_l ()->afm_find ("dots-repeatcolon");
91 return lookup_l ()->blank (Box (Interval(0, 0), Interval (-h/2, h/2)));
93 if (str == "scorepostbreak")
95 return simple_barline (paper_l ()->get_var ("barthick_score"), h);
101 else if (str == "|.")
103 m.add_at_edge (X_AXIS, LEFT, thick, 0);
104 m.add_at_edge (X_AXIS, LEFT, thin, kern);
106 else if (str == ".|")
108 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
109 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
111 else if (str == ":|")
113 m.add_at_edge (X_AXIS, LEFT, thick, 0);
114 m.add_at_edge (X_AXIS, LEFT, thin, kern);
115 m.add_at_edge (X_AXIS, LEFT, colon, kern);
117 else if (str == "|:")
119 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
120 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
121 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
123 else if (str == ":|:")
125 // m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
126 // m.add_at_edge (X_AXIS, LEFT, colon, kern);
127 // m.add_at_edge (X_AXIS, RIGHT, thick, kern);
128 // m.add_at_edge (X_AXIS, RIGHT, colon, kern);
129 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
130 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
131 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
132 m.add_at_edge (X_AXIS, LEFT, thin, kern);
133 m.add_at_edge (X_AXIS, LEFT, colon, kern);
135 else if (str == ";|;")
137 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
138 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
139 m.add_at_edge (X_AXIS, LEFT, thin, kern);
141 else if (str == ".|.")
143 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
144 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
146 else if (str == "||")
148 m.add_at_edge (X_AXIS, RIGHT, thin, 0);
149 m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
159 Bar::staff_brace (Real y) const
161 Real staffht = paper_l ()->get_var ("staffheight");
162 int staff_size = int (rint (staffht ));
166 int minht = 2 * staff_size;
167 int maxht = 7 * minht;
168 int idx = int (((maxht - step) <? y - minht) / step);
171 SCM l = scm_eval (gh_list (ly_symbol2scm ("style-to-cmr"),
172 ly_str02scm ("brace"),
175 String nm = "feta-braces";
177 nm = ly_scm2string (gh_cdr (l));
178 nm += to_str (staff_size);
179 SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
182 at = fontify_atom (all_fonts_global_p->find_font (nm), at);
184 Box b (Interval (0,0), Interval (-y/2, y/2));
186 return Molecule(b, at);
191 Bar::simple_barline (Real w, Real h) const
193 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
198 Bar::before_line_breaking ()
200 SCM g = get_elt_property ("glyph");
201 Direction bsd = break_status_dir ();
206 SCM breakdir = gh_int2scm (bsd);
207 g = scm_eval (gh_list (ly_symbol2scm ("break-barline"),
218 if (!gh_string_p (g))
220 set_elt_property ("transparent", SCM_BOOL_T);
224 set_elt_property ("glyph", g);