* python/lilylib.py (setup_temp): temporary directories are mode 700.
[lilypond.git] / lily / cluster-engraver.cc
blob37f7f446b78aad58c45fd19788528d8ecd061dd2
1 /*
2 cluster-engraver.cc -- implement Cluster_engraver
4 (c) 2002--2003 Juergen Reuter <reuter@ipd.uka.de>
6 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "engraver.hh"
10 #include "item.hh"
11 #include "spanner.hh"
12 #include "note-head.hh"
13 #include "protected-scm.hh"
14 #include "warn.hh"
15 #include "note-column.hh"
16 #include "group-interface.hh"
18 class Cluster_engraver : public Engraver
21 protected:
22 TRANSLATOR_DECLARATIONS(Cluster_engraver);
23 virtual bool try_music (Music *);
24 virtual void process_music ();
25 virtual void acknowledge_grob (Grob_info);
26 virtual void stop_translation_timestep ();
28 private:
29 Drul_array<Music*> reqs_drul_;
31 Spanner *cluster_;
34 Cluster_engraver::Cluster_engraver ()
36 cluster_ = 0;
37 reqs_drul_[LEFT] = reqs_drul_[RIGHT] = 0;
40 bool
41 Cluster_engraver::try_music (Music *m)
43 if (m->is_mus_type ("abort-event"))
45 reqs_drul_[START] = 0;
46 reqs_drul_[STOP] = 0;
47 if (cluster_)
49 cluster_->suicide ();
50 cluster_ = 0;
53 else if (m->is_mus_type ("cluster-event"))
55 Direction d = to_dir (m->get_mus_property ("span-direction"));
57 reqs_drul_[d] = m;
58 return true;
60 return false;
63 void
64 Cluster_engraver::process_music ()
66 if (reqs_drul_[STOP])
68 if (!cluster_)
70 reqs_drul_[STOP]->origin ()->warning ("can't find start of cluster");
72 else
74 Grob *bound = unsmob_grob (get_property ("currentMusicalColumn"));
75 cluster_->set_bound (RIGHT, bound);
78 if (reqs_drul_[START])
80 if (cluster_)
82 reqs_drul_[START]->origin ()->warning ("may not nest clusters");
84 else
86 cluster_ = new Spanner (get_property ("Cluster"));
87 Grob *bound = unsmob_grob (get_property ("currentMusicalColumn"));
88 cluster_->set_bound (LEFT, bound);
89 announce_grob (cluster_, reqs_drul_[START]->self_scm ());
91 reqs_drul_[START] = 0;
96 void
97 Cluster_engraver::stop_translation_timestep ()
99 if (reqs_drul_[STOP])
101 reqs_drul_[STOP] = 0;
102 typeset_grob (cluster_);
103 cluster_ = 0;
107 void
108 Cluster_engraver::acknowledge_grob (Grob_info info)
110 if (cluster_ && Note_column::has_interface (info.grob_))
112 Pointer_group_interface::add_grob (cluster_, ly_symbol2scm ("columns"), info.grob_);
116 ENTER_DESCRIPTION(Cluster_engraver,
117 /* descr */ "engraves a cluster",
118 /* creats*/ "Cluster",
119 /* accepts */ "cluster-event",
120 /* acks */ "note-column-interface",
121 /* reads */ "",
122 /* write */ "");