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>
12 #include "note-head.hh"
13 #include "protected-scm.hh"
15 #include "note-column.hh"
16 #include "group-interface.hh"
18 class Cluster_engraver
: public Engraver
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 ();
29 Drul_array
<Music
*> reqs_drul_
;
34 Cluster_engraver::Cluster_engraver ()
37 reqs_drul_
[LEFT
] = reqs_drul_
[RIGHT
] = 0;
41 Cluster_engraver::try_music (Music
*m
)
43 if (m
->is_mus_type ("abort-event"))
45 reqs_drul_
[START
] = 0;
53 else if (m
->is_mus_type ("cluster-event"))
55 Direction d
= to_dir (m
->get_mus_property ("span-direction"));
64 Cluster_engraver::process_music ()
70 reqs_drul_
[STOP
]->origin ()->warning ("can't find start of cluster");
74 Grob
*bound
= unsmob_grob (get_property ("currentMusicalColumn"));
75 cluster_
->set_bound (RIGHT
, bound
);
78 if (reqs_drul_
[START
])
82 reqs_drul_
[START
]->origin ()->warning ("may not nest clusters");
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;
97 Cluster_engraver::stop_translation_timestep ()
101 reqs_drul_
[STOP
] = 0;
102 typeset_grob (cluster_
);
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",