2 bar-engraver.cc -- implement Bar_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997, 1998, 1999 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 ADD_THIS_TRANSLATOR (Bar_engraver);
22 Bar_engraver::Bar_engraver()
25 do_post_move_processing();
32 Bar_engraver::create_bar ()
36 bar_p_ = new Staff_bar;
37 bar_p_->set_elt_property ("break-aligned", SCM_BOOL_T);
39 // urg: "" != empty...
40 SCM default_type = get_property ("defaultBarType", 0);
41 if (gh_string_p (default_type))
43 bar_p_->set_elt_property ("default-glyph", default_type); // gu.h
48 urg. Why did I implement this? And did I implement this so
50 SCM prop = get_property ("barAtLineStart", 0);
51 if (to_boolean (prop))
53 bar_p_->set_elt_property ("at-line-start", SCM_BOOL_T);
56 announce_element (Score_element_info (bar_p_, 0));
61 Make a barline. If there are both |: and :| requested, merge them
66 Bar_engraver::request_bar (String requested_type)
70 SCM prop = get_property ("barAtLineStart", 0);
71 if (!to_boolean (prop))
74 bool bar_existed = bar_p_;
76 if (bar_existed && requested_type == "")
81 String current = ly_scm2string (bar_p_->get_elt_property ("default-glyph"));
83 if ((requested_type == "|:" && current== ":|")
84 || (requested_type == ":|" && current == "|:"))
85 requested_type = ":|:";
88 bar_p_->set_elt_property ("default-glyph",
89 ly_str02scm (requested_type.ch_C ()));
93 Bar_engraver::do_creation_processing ()
98 Bar_engraver::do_removal_processing ()
102 typeset_element (bar_p_);
108 Bar_engraver::do_process_requests()
110 Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver");
112 Timing_engraver * te = dynamic_cast<Timing_engraver*>(t);
113 String which = (te) ? te->which_bar () : "";
115 if (which.length_i ())
118 bar_p_->set_elt_property ("default-glyph", ly_str02scm (which.ch_C ()));
123 Score_engraver * e = 0;
124 Translator * t = daddy_grav_l ();
125 for (; !e && t; t = t->daddy_trans_l_)
127 e = dynamic_cast<Score_engraver*> (t);
131 programming_error ("No score engraver!");
139 Bar_engraver::do_pre_move_processing()
143 typeset_element (bar_p_);