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 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", 0);
39 if (gh_string_p (default_type))
41 bar_p_->set_elt_property ("glyph", default_type); // gu.h
46 urg. Why did I implement this? And did I implement this so
48 SCM prop = get_property ("barAtLineStart", 0);
49 if (to_boolean (prop))
51 bar_p_->set_elt_property ("at-line-start", SCM_BOOL_T);
54 announce_element (Score_element_info (bar_p_, 0));
59 Make a barline. If there are both |: and :| requested, merge them
64 Bar_engraver::request_bar (String requested_type)
68 SCM prop = get_property ("barAtLineStart", 0);
69 if (!to_boolean (prop))
72 bool bar_existed = bar_p_;
74 if (bar_existed && requested_type == "")
79 String current = ly_scm2string (bar_p_->get_elt_property ("glyph"));
81 if ((requested_type == "|:" && current== ":|")
82 || (requested_type == ":|" && current == "|:"))
83 requested_type = ":|:";
86 bar_p_->set_elt_property ("glyph",
87 ly_str02scm (requested_type.ch_C ()));
91 Bar_engraver::do_creation_processing ()
96 Bar_engraver::do_removal_processing ()
100 typeset_element (bar_p_);
106 Bar_engraver::do_process_requests()
108 Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver");
110 Timing_engraver * te = dynamic_cast<Timing_engraver*>(t);
111 String which = (te) ? te->which_bar () : "";
113 if (which.length_i ())
116 bar_p_->set_elt_property ("glyph", ly_str02scm (which.ch_C ()));
121 Score_engraver * e = 0;
122 Translator * t = daddy_grav_l ();
123 for (; !e && t; t = t->daddy_trans_l_)
125 e = dynamic_cast<Score_engraver*> (t);
129 programming_error ("No score engraver!");
137 Bar_engraver::do_pre_move_processing()
141 typeset_element (bar_p_);
146 ADD_THIS_TRANSLATOR(Bar_engraver);