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 SCM at = gh_list (ly_symbol2scm ("bracket"),
58 gh_double2scm (p->get_var("bracket_arch_angle")),
59 gh_double2scm (p->get_var("bracket_arch_width")),
60 gh_double2scm (p->get_var("bracket_arch_height")),
61 gh_double2scm (p->get_var("bracket_width")),
62 gh_double2scm (height),
63 gh_double2scm (p->get_var("bracket_arch_thick")),
64 gh_double2scm (p->get_var("bracket_thick")),
67 Real staff_space = p->get_var ("interline");
68 Box b (Interval (0, 1.5 * staff_space), Interval (-height/2,height/2));
71 mol.translate_axis (- mol.dim_[X_AXIS].length () / 2, X_AXIS);
76 Bar::compound_barline (String str, Real h) const
78 Real kern = paper_l()->get_var ("bar_kern");
79 Real thinkern = paper_l()->get_var ("bar_thinkern");
81 Molecule thin = simple_barline (paper_l()->get_var ("barthick_thin"), h);
82 Molecule thick = simple_barline (paper_l()->get_var ("barthick_thick"), h);
83 Molecule colon = lookup_l ()->afm_find ("dots-repeatcolon");
89 return lookup_l ()->blank (Box (Interval(0, 0), Interval (-h/2, h/2)));
91 if (str == "scorepostbreak")
93 return simple_barline (paper_l ()->get_var ("barthick_score"), h);
101 m.add_at_edge (X_AXIS, LEFT, thick, 0);
102 m.add_at_edge (X_AXIS, LEFT, thin, kern);
104 else if (str == ".|")
106 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
107 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
109 else if (str == ":|")
111 m.add_at_edge (X_AXIS, LEFT, thick, 0);
112 m.add_at_edge (X_AXIS, LEFT, thin, kern);
113 m.add_at_edge (X_AXIS, LEFT, colon, kern);
115 else if (str == "|:")
117 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
118 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
119 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
121 else if (str == ":|:")
123 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
124 m.add_at_edge (X_AXIS, LEFT, colon, kern);
125 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
126 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
128 else if (str == ".|.")
130 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
131 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
133 else if (str == "||")
135 m.add_at_edge (X_AXIS, RIGHT, thin, 0);
136 m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
146 Bar::staff_brace (Real y) const
148 Real staffht = paper_l ()->get_var ("staffheight");
149 int staff_size = int (rint (staffht ));
153 int minht = 2 * staff_size;
154 int maxht = 7 * minht;
155 int idx = int (((maxht - step) <? y - minht) / step);
158 SCM l = ly_eval_str ("(style-to-cmr \"brace\")");
159 String nm = "feta-braces";
161 nm = ly_scm2string (gh_cdr (l));
162 nm += to_str (staff_size);
163 SCM e =gh_list (ly_symbol2scm ("char"), gh_int2scm (idx), SCM_UNDEFINED);
166 at = fontify_atom (all_fonts_global_p->find_font (nm), at);
168 Box b ( Interval (-y/2,y/2),
170 return Molecule(b, at);
175 Bar::simple_barline (Real w, Real h) const
177 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
182 Bar::before_line_breaking ()
184 SCM g = get_elt_property ("glyph");
185 Direction bsd = break_status_dir ();
190 SCM breakdir = gh_int2scm (bsd);
191 g = scm_eval (gh_list (ly_symbol2scm ("break-barline"),
202 if (!gh_string_p (g))
204 set_elt_property ("transparent", SCM_BOOL_T);
208 set_elt_property ("glyph", g);