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::scheme_molecule (SCM smob)
38 Score_element * self = unsmob_element (smob);
39 Bar * fly = dynamic_cast<Bar*> (self);
40 SCM s = self->get_elt_property ("glyph");
43 String str =ly_scm2string (s);
44 return fly->compound_barline (str, fly->get_bar_size ()).create_scheme ();
49 MAKE_SCHEME_SCORE_ELEMENT_NON_DEFAULT_CALLBACKS(Bar);
52 Bar::compound_barline (String str, Real h) const
54 Real kern = gh_scm2double (get_elt_property ("kern"));
55 Real thinkern = gh_scm2double (get_elt_property ("thin-kern"));
56 Real hair = gh_scm2double (get_elt_property ("hair-thickness"));
57 Real fatline = gh_scm2double (get_elt_property ("thick-thickness"));
59 Real staffline = paper_l ()->get_var ("stafflinethickness");
62 thinkern *= staffline;
66 Molecule thin = simple_barline (hair, h);
67 Molecule thick = simple_barline (fatline, h);
68 Molecule colon = lookup_l ()->afm_find ("dots-repeatcolon");
74 return lookup_l ()->blank (Box (Interval(0, 0), Interval (-h/2, h/2)));
76 if (str == "scorepostbreak")
78 return simple_barline (paper_l ()->get_var ("barthick_score"), h);
86 m.add_at_edge (X_AXIS, LEFT, thick, 0);
87 m.add_at_edge (X_AXIS, LEFT, thin, kern);
91 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
92 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
96 m.add_at_edge (X_AXIS, LEFT, thick, 0);
97 m.add_at_edge (X_AXIS, LEFT, thin, kern);
98 m.add_at_edge (X_AXIS, LEFT, colon, kern);
100 else if (str == "|:")
102 m.add_at_edge (X_AXIS, RIGHT, thick, 0);
103 m.add_at_edge (X_AXIS, RIGHT, thin, kern);
104 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
106 else if (str == ":|:")
108 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
109 m.add_at_edge (X_AXIS, LEFT, colon, kern);
110 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
111 m.add_at_edge (X_AXIS, RIGHT, colon, kern);
113 else if (str == ".|.")
115 m.add_at_edge (X_AXIS, LEFT, thick, thinkern);
116 m.add_at_edge (X_AXIS, RIGHT, thick, kern);
118 else if (str == "||")
120 m.add_at_edge (X_AXIS, RIGHT, thin, 0);
121 m.add_at_edge (X_AXIS, RIGHT, thin, thinkern);
129 Bar::simple_barline (Real w, Real h) const
131 return lookup_l ()->filledbox (Box (Interval(0,w), Interval(-h/2, h/2)));
136 Bar::before_line_breaking ()
138 SCM g = get_elt_property ("glyph");
140 Direction bsd = break_status_dir ();
145 SCM breakdir = gh_int2scm (bsd);
146 g = scm_eval (gh_list (ly_symbol2scm ("break-barline"),
157 if (!gh_string_p (g))
159 set_elt_property ("molecule-callback", SCM_BOOL_T);
160 set_extent_callback (0, X_AXIS);
161 // leave y_extent for spanbar?
163 else if (! gh_equal_p (g, orig))
164 set_elt_property ("glyph", g);