Make whole notes in solfa style the same width as half notes
[lilypond/mpolesky.git] / lily / default-bar-line-engraver.cc
blobc5680c3089e8853d8b2764b0440f6c902f22a9e5
1 /*
2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 1997--2010 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "engraver.hh"
21 #include "context.hh"
22 #include "multi-measure-rest.hh"
23 #include "grob.hh"
24 #include "warn.hh"
26 class Default_bar_line_engraver : public Engraver
28 protected:
29 /* Need to know whether we're advancing in grace notes, or not. */
30 Moment last_moment_;
32 void start_translation_timestep ();
33 void stop_translation_timestep ();
35 public:
36 TRANSLATOR_DECLARATIONS (Default_bar_line_engraver);
39 #include "translator.icc"
41 ADD_TRANSLATOR (Default_bar_line_engraver,
42 /* doc */
43 "This engraver determines what kind of automatic bar lines"
44 " should be produced, and sets @code{whichBar} accordingly."
45 " It should be at the same level as @ref{Timing_translator}.",
47 /* create */
48 "",
50 /* read */
51 "automaticBars "
52 "barAlways "
53 "defaultBarType "
54 "measureLength "
55 "whichBar "
56 "measurePosition ",
58 /* write */
59 "automaticBars "
62 Default_bar_line_engraver::Default_bar_line_engraver ()
64 last_moment_.main_part_ = Rational (-1);
67 void
68 Default_bar_line_engraver::start_translation_timestep ()
70 SCM automatic_bars = get_property ("automaticBars");
71 Moment now = now_mom ();
72 SCM which = get_property ("whichBar");
74 /* Set the first bar of the score? */
75 if (!scm_is_string (which))
76 which = SCM_EOL;
78 Moment mp = measure_position (context ());
79 bool start_of_measure = (last_moment_.main_part_ != now.main_part_
80 && !mp.main_part_);
82 if (!scm_is_string (which) && to_boolean (automatic_bars))
84 SCM always = get_property ("barAlways");
86 if ((start_of_measure && last_moment_.main_part_ >= Moment (0))
87 || to_boolean (always))
89 /* should this work, or be junked? See input/bugs/no-bars.ly */
90 which = get_property ("defaultBarType");
94 context ()->set_property ("whichBar", which);
97 void
98 Default_bar_line_engraver::stop_translation_timestep ()
100 context ()->set_property ("whichBar", SCM_EOL);
101 last_moment_ = now_mom ();