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"
27 Bar::get_bar_size () const
35 Bar::do_brew_molecule () const
37 SCM s = get_elt_property ("glyph");
40 String str =ly_scm2string (s);
41 return compound_barline (str, get_bar_size ());
48 Bar::compound_barline (String str, Real h) const
50 Real kern = paper_l()->get_var ("bar_kern");
51 Real thinkern = paper_l()->get_var ("bar_thinkern");
53 Molecule thin = simple_barline (paper_l()->get_var ("barthick_thin"), h);
54 Molecule thick = simple_barline (paper_l()->get_var ("barthick_thick"), h);
55 Molecule colon = lookup_l ()->afm_find ("dots-repeatcolon");
61 return lookup_l ()->blank (Box (Interval(0, 0), Interval (-h/2, h/2)));
63 if (str == "scorepostbreak")
65 return simple_barline (paper_l ()->get_var ("barthick_score"), h);
73 m.add_at_edge (X_AXIS, LEFT, thick, 0);
74 m.add_at_edge (X_AXIS, LEFT, thin, kern);
78 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
79 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
83 m.add_at_edge (X_AXIS, LEFT, thick, 0);
84 m.add_at_edge (X_AXIS, LEFT, thin, kern);
85 m.add_at_edge (X_AXIS, LEFT, colon, kern);
89 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
90 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
91 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
93 else if (str == ":|:")
95 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
96 m.add_at_edge (X_AXIS, LEFT, colon, kern);
97 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
98 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
100 else if (str == ".|.")
102 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
103 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
105 else if (str == "||")
107 m.add_at_edge (X_AXIS, RIGHT, thin, 0);
108 m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
116 Bar::simple_barline (Real w, Real h) const
118 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
123 Bar::before_line_breaking ()
125 SCM g = get_elt_property ("glyph");
126 Direction bsd = break_status_dir ();
131 SCM breakdir = gh_int2scm (bsd);
132 g = scm_eval (gh_list (ly_symbol2scm ("break-barline"),
143 if (!gh_string_p (g))
145 set_elt_property ("transparent", SCM_BOOL_T);
146 set_extent_callback (0, X_AXIS);
149 set_elt_property ("glyph", g);