2 staff-symbol-engraver.cc -- implement Staff_symbol_engraver
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
10 #include "international.hh"
12 #include "stream-event.hh"
15 #include "translator.icc"
17 class Staff_symbol_engraver
: public Engraver
20 TRANSLATOR_DECLARATIONS (Staff_symbol_engraver
);
23 Drul_array
<Stream_event
*> span_events_
;
25 Spanner
*finished_span_
;
29 virtual void start_spanner ();
30 virtual void stop_spanner ();
32 void stop_translation_timestep ();
33 virtual ~Staff_symbol_engraver ();
34 DECLARE_ACKNOWLEDGER (grob
);
35 DECLARE_TRANSLATOR_LISTENER (staff_span
);
36 virtual void finalize ();
37 void process_music ();
40 Staff_symbol_engraver::~Staff_symbol_engraver ()
45 Staff_symbol_engraver::Staff_symbol_engraver ()
50 span_events_
[LEFT
] = 0;
51 span_events_
[RIGHT
] = 0;
54 IMPLEMENT_TRANSLATOR_LISTENER (Staff_symbol_engraver
, staff_span
);
56 Staff_symbol_engraver::listen_staff_span (Stream_event
*ev
)
58 Direction d
= to_dir (ev
->get_property ("span-direction"));
60 ASSIGN_EVENT_ONCE (span_events_
[d
], ev
);
62 programming_error (_ ("staff-span event has no direction"));
66 Staff_symbol_engraver::process_music ()
68 if (span_events_
[STOP
])
70 finished_span_
= span_
;
76 if (span_events_
[START
]
77 || (first_start_
&& !span_events_
[STOP
]))
82 Staff_symbol_engraver::start_spanner ()
86 span_
= make_spanner ("StaffSymbol", SCM_EOL
);
87 span_
->set_bound (LEFT
,
88 unsmob_grob (get_property ("currentCommandColumn")));
93 Staff_symbol_engraver::stop_spanner ()
98 if (!finished_span_
->get_bound (RIGHT
))
99 finished_span_
->set_bound (RIGHT
, unsmob_grob (get_property ("currentCommandColumn")));
101 announce_end_grob (finished_span_
,
103 ? span_events_
[STOP
]->self_scm ()
110 Staff_symbol_engraver::stop_translation_timestep ()
112 if ((span_events_
[START
] || first_start_
)
115 first_start_
= false;
118 span_events_
[START
] = 0;
119 span_events_
[STOP
] = 0;
124 Staff_symbol_engraver::finalize ()
126 finished_span_
= span_
;
132 Todo: staff-symbol-referencer iface.
135 Staff_symbol_engraver::acknowledge_grob (Grob_info s
)
138 Perhaps should try to take SeparationItem as bound of the staff
141 if (span_
|| finished_span_
)
143 Spanner
*my
= span_
? span_
: finished_span_
;
144 s
.grob ()->set_object ("staff-symbol", my
->self_scm ());
148 ADD_ACKNOWLEDGER (Staff_symbol_engraver
, grob
);
150 ADD_TRANSLATOR (Staff_symbol_engraver
,
152 "Create the constellation of five (default) staff lines.",