From 84cad110c3bbaeca8e5144dba7f8756b89100396 Mon Sep 17 00:00:00 2001 From: David Kastrup Date: Sat, 21 Apr 2012 22:30:55 +0200 Subject: [PATCH] Let rhythmic-engraver make its articulation-or-event decision based on current listeners This removes the dependency of the rhythmic engraver on a static list of unlistened event classes and thus is part of work on issue 2449. As one effect, string numbers on isolated notes in Voice contexts are now typeset by default since the string numbers have no listener in Voice contexts even though they would have one in TabVoice. --- lily/dispatcher.cc | 21 +++++++++++++++++++++ lily/include/dispatcher.hh | 1 + lily/rhythmic-music-iterator.cc | 15 +++++---------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/lily/dispatcher.cc b/lily/dispatcher.cc index 94519021ab..4db7c93a15 100644 --- a/lily/dispatcher.cc +++ b/lily/dispatcher.cc @@ -173,6 +173,27 @@ Dispatcher::dispatch (SCM sev) #endif } +bool +Dispatcher::is_listened (Stream_event *ev) +{ + SCM class_symbol = ev->get_property ("class"); + if (!scm_is_symbol (class_symbol)) + { + warning (_ ("Event class should be a symbol")); + return false; + } + + for (SCM cl = scm_call_1 (ly_lily_module_constant ("ly:make-event-class"), class_symbol); + scm_is_pair (cl); cl = scm_cdr (cl)) + { + SCM list = scm_hashq_ref (listeners_, scm_car (cl), SCM_EOL); + if (scm_is_pair (list)) + return true; + } + return false; +} + + void Dispatcher::broadcast (Stream_event *ev) { diff --git a/lily/include/dispatcher.hh b/lily/include/dispatcher.hh index d812b27c63..b11167121b 100644 --- a/lily/include/dispatcher.hh +++ b/lily/include/dispatcher.hh @@ -39,6 +39,7 @@ class Dispatcher public: Dispatcher (); void broadcast (Stream_event *ev); + bool is_listened (Stream_event *ev); void add_listener (Listener, SCM event_class); void remove_listener (Listener, SCM event_class); void register_as_listener (Dispatcher *dist); diff --git a/lily/rhythmic-music-iterator.cc b/lily/rhythmic-music-iterator.cc index 1246e38542..427436a12f 100644 --- a/lily/rhythmic-music-iterator.cc +++ b/lily/rhythmic-music-iterator.cc @@ -59,17 +59,12 @@ Rhythmic_music_iterator::process (Moment m) SCM unlistened = SCM_EOL; for (; scm_is_pair (arts); arts = scm_cdr (arts)) { - if (scm_is_true - (scm_call_2 - (ly_lily_module_constant ("any"), - ly_lily_module_constant ("ly:is-listened-event-class"), - scm_call_1 - (ly_lily_module_constant ("ly:make-event-class"), - unsmob_stream_event (scm_car (arts)) - ->get_property ("class"))))) - listened = scm_cons (scm_car (arts), listened); + SCM art = scm_car (arts); + + if (c->event_source ()->is_listened (unsmob_stream_event (art))) + listened = scm_cons (art, listened); else - unlistened = scm_cons (scm_car (arts), unlistened); + unlistened = scm_cons (art, unlistened); } ev->set_property ("articulations", scm_reverse_x (unlistened, SCM_EOL)); c->event_source ()->broadcast (ev); -- 2.39.2