1 /* 2 This file is part of LilyPond, the GNU music typesetter. 3 4 Copyright (C) 2013--2020 Mike Solomon <mike@mikesolomon.org> 5 Copyright (C) 2016 David Kastrup <dak@gnu.org> 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 #ifndef SLUR_ENGRAVER_HH 22 #define SLUR_ENGRAVER_HH 23 24 #include "engraver.hh" 25 #include <map> 26 27 class Slur_engraver : public Engraver 28 { 29 protected: 30 struct Event_info 31 { 32 Stream_event *slur_, *note_; Event_infoSlur_engraver::Event_info33 Event_info (Stream_event *slur, Stream_event *note) 34 : slur_ (slur), note_ (note) 35 { } 36 }; 37 // protected so that subclasses can see them 38 std::vector<Event_info> start_events_; 39 std::vector<Event_info> stop_events_; 40 41 typedef std::multimap<Stream_event *, Spanner *> Note_slurs; 42 Drul_array<Note_slurs> note_slurs_; 43 std::vector<Grob *> slurs_; 44 std::vector<Grob *> end_slurs_; 45 46 // objects that we need for formatting, eg. scripts and ties. 47 std::vector<Grob_info> objects_to_acknowledge_; 48 49 virtual SCM event_symbol () const; 50 virtual bool double_property () const; 51 virtual SCM grob_symbol () const; 52 virtual const char *object_name () const; 53 54 void acknowledge_note_column (Grob_info); 55 void acknowledge_script (Grob_info); 56 57 void listen_note (Stream_event *ev); 58 // A slur on an in-chord note is not actually announced as an event 59 // but rather produced by the note listener. 60 void listen_note_slur (Stream_event *ev, Stream_event *note); listen_slur(Stream_event * ev)61 void listen_slur (Stream_event *ev) { listen_note_slur (ev, 0); } 62 void acknowledge_extra_object (Grob_info); 63 void stop_translation_timestep (); 64 void process_music (); 65 66 bool can_create_slur (SCM, vsize, vsize *, Stream_event *); 67 void create_slur (SCM spanner_id, Event_info evi, Grob *g_cause, Direction dir, bool left_broken); 68 bool try_to_end (Event_info evi); 69 70 virtual void set_melisma (bool); 71 void finalize () override; 72 void derived_mark () const override; 73 74 public: 75 TRANSLATOR_DECLARATIONS (Slur_engraver); 76 }; 77 78 #endif // SLUR_ENGRAVER_HH 79