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 ());
47 MAKE_SCHEME_SCORE_ELEMENT_CALLBACKS(Bar);
50 Bar::compound_barline (String str, Real h) const
52 Real kern = paper_l()->get_var ("bar_kern");
53 Real thinkern = paper_l()->get_var ("bar_thinkern");
55 Molecule thin = simple_barline (paper_l()->get_var ("barthick_thin"), h);
56 Molecule thick = simple_barline (paper_l()->get_var ("barthick_thick"), h);
57 Molecule colon = lookup_l ()->afm_find ("dots-repeatcolon");
63 return lookup_l ()->blank (Box (Interval(0, 0), Interval (-h/2, h/2)));
65 if (str == "scorepostbreak")
67 return simple_barline (paper_l ()->get_var ("barthick_score"), h);
75 m.add_at_edge (X_AXIS, LEFT, thick, 0);
76 m.add_at_edge (X_AXIS, LEFT, thin, kern);
80 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
81 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
85 m.add_at_edge (X_AXIS, LEFT, thick, 0);
86 m.add_at_edge (X_AXIS, LEFT, thin, kern);
87 m.add_at_edge (X_AXIS, LEFT, colon, kern);
91 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
92 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
93 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
95 else if (str == ":|:")
97 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
98 m.add_at_edge (X_AXIS, LEFT, colon, kern);
99 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
100 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
102 else if (str == ".|.")
104 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
105 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
107 else if (str == "||")
109 m.add_at_edge (X_AXIS, RIGHT, thin, 0);
110 m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
118 Bar::simple_barline (Real w, Real h) const
120 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
125 Bar::before_line_breaking ()
127 SCM g = get_elt_property ("glyph");
129 Direction bsd = break_status_dir ();
134 SCM breakdir = gh_int2scm (bsd);
135 g = scm_eval (gh_list (ly_symbol2scm ("break-barline"),
146 if (!gh_string_p (g))
148 set_elt_property ("molecule-callback", SCM_BOOL_T);
149 set_extent_callback (0, X_AXIS);
150 // leave y_extent for spanbar?
152 else if (! gh_equal_p (g, orig))
153 set_elt_property ("glyph", g);