]> git.donarmstrong.com Git - lilypond.git/commitdiff
Let rhythmic-engraver make its articulation-or-event decision based on current listeners
authorDavid Kastrup <dak@gnu.org>
Sat, 21 Apr 2012 20:30:55 +0000 (22:30 +0200)
committerDavid Kastrup <dak@gnu.org>
Mon, 23 Apr 2012 14:04:57 +0000 (16:04 +0200)
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
lily/include/dispatcher.hh
lily/rhythmic-music-iterator.cc

index 94519021abe43ccb4def37ce25fa595e3dd676a9..4db7c93a1555a66a9cffc6772ea9ac349a263379 100644 (file)
@@ -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)
 {
index d812b27c63ccf73021db1e714db672999b5f1083..b11167121bb93ebf2b1a83f8c3ec7f0349bdbccf 100644 (file)
@@ -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);
index 1246e3854272ec622ef10e1766a9bb1024e2be96..427436a12f00ba96c0c96ac438056cf36dfa1b49 100644 (file)
@@ -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);