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"
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);
42 return compound_barline (str, get_bar_size ());
49 Bar::compound_barline (String str, Real h) const
51 Real kern = paper_l()->get_var ("bar_kern");
52 Real thinkern = paper_l()->get_var ("bar_thinkern");
54 Molecule thin = simple_barline (paper_l()->get_var ("barthick_thin"), h);
55 Molecule thick = simple_barline (paper_l()->get_var ("barthick_thick"), h);
56 Molecule colon = lookup_l ()->afm_find ("dots-repeatcolon");
62 return lookup_l ()->blank (Box (Interval(0, 0), Interval (-h/2, h/2)));
64 if (str == "scorepostbreak")
66 return simple_barline (paper_l ()->get_var ("barthick_score"), h);
74 m.add_at_edge (X_AXIS, LEFT, thick, 0);
75 m.add_at_edge (X_AXIS, LEFT, thin, kern);
79 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
80 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
84 m.add_at_edge (X_AXIS, LEFT, thick, 0);
85 m.add_at_edge (X_AXIS, LEFT, thin, kern);
86 m.add_at_edge (X_AXIS, LEFT, colon, kern);
90 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
91 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
92 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
94 else if (str == ":|:")
96 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
97 m.add_at_edge (X_AXIS, LEFT, colon, kern);
98 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
99 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
101 else if (str == ".|.")
103 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
104 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
106 else if (str == "||")
108 m.add_at_edge (X_AXIS, RIGHT, thin, 0);
109 m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
117 Bar::simple_barline (Real w, Real h) const
119 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
124 Bar::before_line_breaking ()
126 SCM g = get_elt_property ("glyph");
128 Direction bsd = break_status_dir ();
133 SCM breakdir = gh_int2scm (bsd);
134 g = scm_eval (gh_list (ly_symbol2scm ("break-barline"),
145 if (!gh_string_p (g))
147 set_elt_property ("transparent", SCM_BOOL_T);
148 set_extent_callback (0, X_AXIS);
150 else if (! gh_equal_p (g, orig))
151 set_elt_property ("glyph", g);