]> git.donarmstrong.com Git - lilypond.git/blob - lily/repeat-tie-engraver.cc
Issue 4550 (1/2) Avoid "using namespace std;" in included files
[lilypond.git] / lily / repeat-tie-engraver.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "engraver.hh"
22 #include "item.hh"
23 #include "pointer-group-interface.hh"
24 #include "stream-event.hh"
25
26 #include "translator.icc"
27
28 using std::vector;
29
30 class Repeat_tie_engraver : public Engraver
31 {
32   Stream_event *event_;
33   Grob *semi_tie_column_;
34   vector<Grob *> semi_ties_;
35
36   void stop_translation_timestep ();
37   DECLARE_ACKNOWLEDGER (note_head);
38   DECLARE_TRANSLATOR_LISTENER (repeat_tie);
39
40 public:
41   TRANSLATOR_DECLARATIONS (Repeat_tie_engraver);
42 };
43
44 Repeat_tie_engraver::Repeat_tie_engraver ()
45 {
46   event_ = 0;
47   semi_tie_column_ = 0;
48 }
49
50 void
51 Repeat_tie_engraver::stop_translation_timestep ()
52 {
53   event_ = 0;
54   semi_tie_column_ = 0;
55   semi_ties_.clear ();
56 }
57
58 IMPLEMENT_TRANSLATOR_LISTENER (Repeat_tie_engraver, repeat_tie);
59 void
60 Repeat_tie_engraver::listen_repeat_tie (Stream_event *ev)
61 {
62   ASSIGN_EVENT_ONCE (event_, ev);
63 }
64
65 void
66 Repeat_tie_engraver::acknowledge_note_head (Grob_info inf)
67 {
68   if (!event_)
69     return;
70
71   if (!semi_tie_column_)
72     {
73       semi_tie_column_ = make_item ("RepeatTieColumn", event_->self_scm ());
74     }
75
76   SCM cause = event_->self_scm ();
77   Grob *semi_tie = make_item ("RepeatTie", cause);
78   semi_tie->set_object ("note-head", inf.grob ()->self_scm ());
79
80   Pointer_group_interface::add_grob (semi_tie_column_, ly_symbol2scm ("ties"),
81                                      semi_tie);
82   semi_tie->set_parent (semi_tie_column_, Y_AXIS);
83   semi_ties_.push_back (semi_tie);
84
85   if (is_direction (unsmob<Stream_event> (cause)->get_property ("direction")))
86     {
87       Direction d = to_dir (unsmob<Stream_event> (cause)->get_property ("direction"));
88       semi_tie->set_property ("direction", scm_from_int (d));
89     }
90
91 }
92
93 ADD_ACKNOWLEDGER (Repeat_tie_engraver, note_head);
94 ADD_TRANSLATOR (Repeat_tie_engraver,
95                 /* doc */
96                 "Create repeat ties.",
97
98                 /* create */
99                 "RepeatTie "
100                 "RepeatTieColumn ",
101
102                 /* read */
103                 "",
104
105                 /* write */
106                 ""
107                );