]> git.donarmstrong.com Git - lilypond.git/blob - lily/slur-performer.cc
Issue 4965: Create and use Grob::parent_relative
[lilypond.git] / lily / slur-performer.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2015 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   void listen_slur (Stream_event *);
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 void
87 Slur_performer::listen_slur (Stream_event *ev)
88 {
89   Direction d = to_dir (ev->get_property ("span-direction"));
90
91   if (d == START)
92     start_ev_ = ev;
93   else if (d == STOP)
94     now_stop_ev_ = ev;
95 }
96
97 void
98 Slur_performer::boot ()
99 {
100   ADD_LISTENER (Slur_performer, slur);
101 }
102
103 ADD_TRANSLATOR (Slur_performer,
104                 /* doc */
105                 "",
106
107                 /* create */
108                 "",
109
110                 /* read */
111                 "",
112
113                 /* write */
114                 ""
115                );