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_priority_scm_sym, gh_int2scm (0));
37 // urg: "" != empty...
38 SCM default_type = get_property ("defaultBarType", 0);
39 if (gh_string_p (default_type))
41 bar_p_->type_str_ = ly_scm2string (default_type);
45 urg. Why did I implement this?
47 SCM prop = get_property ("barAtLineStart", 0);
48 if (gh_boolean_p (prop) && gh_scm2bool (prop))
50 bar_p_->set_elt_property (at_line_start_scm_sym, SCM_BOOL_T);
52 prop = get_property ("barSize", 0);
53 if (SCM_NUMBERP(prop))
55 bar_p_->set_elt_property (bar_size_scm_sym, prop);
57 announce_element (Score_element_info (bar_p_, 0));
62 Make a barline. If there are both |: and :| requested, merge them
67 Bar_engraver::request_bar (String requested_type)
71 SCM prop = get_property ("barAtLineStart", 0);
72 if (!gh_boolean_p (prop) && gh_scm2bool (prop))
75 bool bar_existed = bar_p_;
77 if (bar_existed && requested_type == "")
81 else if (((requested_type == "|:") && (bar_p_->type_str_ == ":|"))
82 || ((requested_type == ":|") && (bar_p_->type_str_ == "|:")))
83 bar_p_->type_str_ = ":|:";
85 bar_p_->type_str_ = requested_type;
89 Bar_engraver::do_creation_processing ()
94 Bar_engraver::do_removal_processing ()
98 typeset_element (bar_p_);
104 Bar_engraver::do_process_requests()
106 Translator * t = daddy_grav_l ()->get_simple_translator ("Timing_engraver");
108 Timing_engraver * te = dynamic_cast<Timing_engraver*>(t);
109 String which = (te) ? te->which_bar () : "";
111 if (which.length_i ())
114 bar_p_->type_str_ = which;
119 Score_engraver * e = 0;
120 Translator * t = daddy_grav_l ();
121 for (; !e && t; t = t->daddy_trans_l_)
123 e = dynamic_cast<Score_engraver*> (t);
127 programming_error ("No score engraver!");
135 Bar_engraver::do_pre_move_processing()
139 typeset_element (bar_p_);
144 ADD_THIS_TRANSLATOR(Bar_engraver);