]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
Run grand-replace (issue 3765)
[lilypond.git] / lily / slur-performer.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2014 Jan Nieuwenhuizen <janneke@gnu.org>
5
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.
10
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.
15
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/>.
18 */
19
20 #include "performer.hh"
21 #include "audio-item.hh"
22 #include "audio-column.hh"
23 #include "global-context.hh"
24 #include "stream-event.hh"
25 #include "warn.hh"
26
27 #include "translator.icc"
28
29 /*
30   this is C&P from beam_performer.
31 */
32
33 class Slur_performer : public Performer
34 {
35 public:
36   TRANSLATOR_DECLARATIONS (Slur_performer);
37
38 protected:
39   void start_translation_timestep ();
40   void process_music ();
41   void set_melisma (bool);
42
43   DECLARE_TRANSLATOR_LISTENER (slur);
44 private:
45   Stream_event *start_ev_;
46   Stream_event *now_stop_ev_;
47   bool slur_;
48 };
49
50 Slur_performer::Slur_performer ()
51 {
52   slur_ = false;
53   start_ev_ = 0;
54   now_stop_ev_ = 0;
55 }
56
57 void
58 Slur_performer::process_music ()
59 {
60   if (now_stop_ev_)
61     {
62       slur_ = false;
63       set_melisma (false);
64     }
65
66   if (start_ev_)
67     {
68       slur_ = true;
69       set_melisma (true);
70     }
71 }
72
73 void
74 Slur_performer::set_melisma (bool ml)
75 {
76   context ()->set_property ("slurMelismaBusy", ml ? SCM_BOOL_T : SCM_BOOL_F);
77 }
78
79 void
80 Slur_performer::start_translation_timestep ()
81 {
82   start_ev_ = 0;
83   now_stop_ev_ = 0;
84 }
85
86 IMPLEMENT_TRANSLATOR_LISTENER (Slur_performer, slur);
87 void
88 Slur_performer::listen_slur (Stream_event *ev)
89 {
90   Direction d = to_dir (ev->get_property ("span-direction"));
91
92   if (d == START)
93     start_ev_ = ev;
94   else if (d == STOP)
95     now_stop_ev_ = ev;
96 }
97
98 ADD_TRANSLATOR (Slur_performer,
99                 /* doc */
100                 "",
101
102                 /* create */
103                 "",
104
105                 /* read */
106                 "",
107
108                 /* write */
109                 ""
110                );