]> git.donarmstrong.com Git - lilypond.git/blob - lily/bar-check-iterator.cc
* lily/include/event.hh: remove file.
[lilypond.git] / lily / bar-check-iterator.cc
1 /*
2   bar-check-iterator.cc -- implement Bar_check_iterator
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2001--2005  Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
8
9 #include "simple-music-iterator.hh"
10 #include "music.hh"
11 #include "context.hh"
12 #include "input.hh"
13
14 /*
15   Check bar checks. We do this outside the engravers so that you can
16   race through the score using skipTypesetting to correct durations.
17 */
18 class Bar_check_iterator : Simple_music_iterator
19 {
20 public:
21   virtual void process (Moment);
22   Bar_check_iterator ();
23   DECLARE_SCHEME_CALLBACK (constructor, ());
24 };
25
26 IMPLEMENT_CTOR_CALLBACK (Bar_check_iterator);
27
28 Bar_check_iterator::Bar_check_iterator ()
29 {
30 }
31
32 void
33 Bar_check_iterator::process (Moment m)
34 {
35   Simple_music_iterator::process (m);
36   if (!m.to_bool ())
37     {
38       Context *tr = get_outlet ();
39
40       SCM check = tr->get_property ("ignoreBarChecks");
41       if (to_boolean (check))
42         return;
43       
44       SCM mp = tr->get_property ("measurePosition");
45       SCM sync = tr->get_property ("barCheckSynchronize");
46
47       Moment *where = unsmob_moment (mp);
48       if (!where)
49         return;
50
51       if (where->main_part_)
52         {
53           bool warn = true;
54           if (to_boolean (sync))
55             {
56               tr = tr->where_defined (ly_symbol2scm ("measurePosition"));
57               Moment zero;
58               tr->set_property ("measurePosition", zero.smobbed_copy ());
59             }
60           else
61             {
62               SCM lf = tr->get_property ("barCheckLastFail");
63               if (unsmob_moment (lf)
64                   && *unsmob_moment (lf) == *where)
65                 warn = false;
66               else
67                 tr->set_property ("barCheckLastFail", mp);
68             }
69
70           if (warn)
71             get_music ()->origin ()->warning (_f ("barcheck failed at: %s",
72                                                   where->to_string ()));
73         }
74     }
75 }