]> git.donarmstrong.com Git - lilypond.git/blob - lily/repeat-tie-engraver.cc
Web-ja: update introduction
[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 class Repeat_tie_engraver : public Engraver
29 {
30   Stream_event *event_;
31   Grob *semi_tie_column_;
32   vector<Grob *> semi_ties_;
33
34   void stop_translation_timestep ();
35   void acknowledge_note_head (Grob_info);
36   void listen_repeat_tie (Stream_event *);
37
38 public:
39   TRANSLATOR_DECLARATIONS (Repeat_tie_engraver);
40 };
41
42 Repeat_tie_engraver::Repeat_tie_engraver (Context *c)
43   : Engraver (c)
44 {
45   event_ = 0;
46   semi_tie_column_ = 0;
47 }
48
49 void
50 Repeat_tie_engraver::stop_translation_timestep ()
51 {
52   event_ = 0;
53   semi_tie_column_ = 0;
54   semi_ties_.clear ();
55 }
56
57 void
58 Repeat_tie_engraver::listen_repeat_tie (Stream_event *ev)
59 {
60   ASSIGN_EVENT_ONCE (event_, ev);
61 }
62
63 void
64 Repeat_tie_engraver::acknowledge_note_head (Grob_info inf)
65 {
66   if (!event_)
67     return;
68
69   if (!semi_tie_column_)
70     {
71       semi_tie_column_ = make_item ("RepeatTieColumn", SCM_EOL);
72     }
73
74   SCM cause = event_->self_scm ();
75   Grob *semi_tie = make_item ("RepeatTie", cause);
76   semi_tie->set_object ("note-head", inf.grob ()->self_scm ());
77
78   Pointer_group_interface::add_grob (semi_tie_column_, ly_symbol2scm ("ties"),
79                                      semi_tie);
80   semi_tie->set_parent (semi_tie_column_, Y_AXIS);
81   semi_ties_.push_back (semi_tie);
82
83   if (is_direction (unsmob<Stream_event> (cause)->get_property ("direction")))
84     {
85       Direction d = to_dir (unsmob<Stream_event> (cause)->get_property ("direction"));
86       semi_tie->set_property ("direction", scm_from_int (d));
87     }
88
89 }
90
91 void
92 Repeat_tie_engraver::boot ()
93 {
94   ADD_LISTENER (Repeat_tie_engraver, repeat_tie);
95   ADD_ACKNOWLEDGER (Repeat_tie_engraver, note_head);
96 }
97
98 ADD_TRANSLATOR (Repeat_tie_engraver,
99                 /* doc */
100                 "Create repeat ties.",
101
102                 /* create */
103                 "RepeatTie "
104                 "RepeatTieColumn ",
105
106                 /* read */
107                 "",
108
109                 /* write */
110                 ""
111                );