2 bar-engraver.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 Jan Nieuwenhuizen <janneke@gnu.org>
10 #include "score-engraver.hh"
11 #include "bar-engraver.hh"
12 #include "staff-bar.hh"
13 #include "musical-request.hh"
14 #include "multi-measure-rest.hh"
15 #include "command-request.hh"
16 #include "timing-engraver.hh"
17 #include "engraver-group-engraver.hh"
20 Bar_engraver::Bar_engraver()
23 do_post_move_processing();
27 Bar_engraver::create_bar ()
31 bar_p_ = new Staff_bar;
32 bar_p_->set_elt_property ("break-align-symbol", ly_symbol2scm ("Staff_bar"));
34 // urg: "" != empty...
38 SCM default_type = get_property ("defaultBarType");
39 if (gh_string_p (default_type))
41 bar_p_->set_elt_property ("glyph", default_type); // ugh
44 announce_element (Score_element_info (bar_p_, 0));
49 Make a barline. If there are both |: and :| requested, merge them
54 Bar_engraver::request_bar (String requested_type)
58 SCM prop = get_property ("barAtLineStart");
59 if (!to_boolean (prop))
62 bool bar_existed = bar_p_;
64 if (bar_existed && requested_type == "")
69 String current = ly_scm2string (bar_p_->get_elt_property ("glyph"));
71 if ((requested_type == "|:" && current== ":|")
72 || (requested_type == ":|" && current == "|:"))
73 requested_type = ":|:";
76 bar_p_->set_elt_property ("glyph",
77 ly_str02scm (requested_type.ch_C ()));
81 Bar_engraver::do_creation_processing ()
86 Bar_engraver::do_removal_processing ()
90 typeset_element (bar_p_);
96 Bar_engraver::do_process_music()
98 Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver");
100 Timing_engraver * te = dynamic_cast<Timing_engraver*>(t);
101 String which = (te) ? te->which_bar () : "";
103 if (which.length_i ())
106 bar_p_->set_elt_property ("glyph", ly_str02scm (which.ch_C ()));
111 Score_engraver * e = 0;
112 Translator * t = daddy_grav_l ();
113 for (; !e && t; t = t->daddy_trans_l_)
115 e = dynamic_cast<Score_engraver*> (t);
119 programming_error ("No score engraver!");
127 Bar_engraver::do_pre_move_processing()
131 typeset_element (bar_p_);
136 ADD_THIS_TRANSLATOR(Bar_engraver);