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();
30 Bar_engraver::create_bar ()
34 bar_p_ = new Staff_bar;
35 bar_p_->set_elt_property ("break-aligned", SCM_BOOL_T);
37 // 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
46 urg. Why did I implement this? And did I implement this so
49 input/test/just-friends.ly
50 Maybe a staffgroup of just one staff would be a better solution.
52 SCM prop = get_property ("barAtLineStart");
53 if (to_boolean (prop))
55 bar_p_->set_elt_property ("at-line-start", SCM_BOOL_T);
58 announce_element (Score_element_info (bar_p_, 0));
63 Make a barline. If there are both |: and :| requested, merge them
68 Bar_engraver::request_bar (String requested_type)
72 SCM prop = get_property ("barAtLineStart");
73 if (!to_boolean (prop))
76 bool bar_existed = bar_p_;
78 if (bar_existed && requested_type == "")
83 String current = ly_scm2string (bar_p_->get_elt_property ("glyph"));
85 if ((requested_type == "|:" && current== ":|")
86 || (requested_type == ":|" && current == "|:"))
87 requested_type = ":|:";
90 bar_p_->set_elt_property ("glyph",
91 ly_str02scm (requested_type.ch_C ()));
95 Bar_engraver::do_creation_processing ()
100 Bar_engraver::do_removal_processing ()
104 typeset_element (bar_p_);
110 Bar_engraver::do_process_music()
112 Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver");
114 Timing_engraver * te = dynamic_cast<Timing_engraver*>(t);
115 String which = (te) ? te->which_bar () : "";
117 if (which.length_i ())
120 bar_p_->set_elt_property ("glyph", ly_str02scm (which.ch_C ()));
125 Score_engraver * e = 0;
126 Translator * t = daddy_grav_l ();
127 for (; !e && t; t = t->daddy_trans_l_)
129 e = dynamic_cast<Score_engraver*> (t);
133 programming_error ("No score engraver!");
141 Bar_engraver::do_pre_move_processing()
145 typeset_element (bar_p_);
150 ADD_THIS_TRANSLATOR(Bar_engraver);