]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/break-align-engraver.cc
Run `make grand-replace'.
[lilypond.git] / lily / break-align-engraver.cc
index 2363fdded0c4210931ca2a5f003ef23501470434..155f34d9bc0acba3287d967b3a989b5776a88b9b 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1999--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  (c) 1999--2008 Han-Wen Nienhuys <hanwen@xs4all.nl>
 */
 #include "engraver.hh"
 #include "protected-scm.hh"
@@ -12,6 +12,7 @@
 #include "axis-group-interface.hh"
 #include "context.hh"
 #include "translator-group.hh"
+#include "item.hh"
 
 #include "translator.icc"
 
@@ -22,13 +23,14 @@ class Break_align_engraver : public Engraver
   Item *left_edge_;
 
   void add_to_group (SCM, Item *);
+  void create_alignment (Grob_info);
 protected:
-  PRECOMPUTED_VIRTUAL void stop_translation_timestep ();
+  void stop_translation_timestep ();
   virtual void derived_mark () const;
 public:
   TRANSLATOR_DECLARATIONS (Break_align_engraver);
-  DECLARE_ACKNOWLEDGER(break_aligned);
-
+  DECLARE_ACKNOWLEDGER (break_aligned);
+  DECLARE_ACKNOWLEDGER (break_alignable);
 };
 
 void
@@ -53,6 +55,18 @@ Break_align_engraver::derived_mark () const
   scm_gc_mark (column_alist_);
 }
 
+void
+Break_align_engraver::acknowledge_break_alignable (Grob_info inf)
+{
+  if (!align_)
+    create_alignment (inf);
+
+  Grob *g = inf.grob ();
+
+  if (!g->get_parent (X_AXIS))
+    g->set_parent (align_, X_AXIS);
+}
+
 void
 Break_align_engraver::acknowledge_break_aligned (Grob_info inf)
 {
@@ -64,37 +78,38 @@ Break_align_engraver::acknowledge_break_aligned (Grob_info inf)
       if (item->get_parent (X_AXIS))
        return;
 
-      SCM bp = item->get_property ("breakable");
-      bool breakable = (to_boolean (bp));
-      if (!breakable)
+      if (!Item::is_non_musical (item))
        return;
 
       SCM align_name = item->get_property ("break-align-symbol");
       if (!scm_is_symbol (align_name))
        return;
-
+         
       if (!align_)
-       {
-         align_ = make_item ("BreakAlignment", SCM_EOL);
+       create_alignment (inf);
 
-         Context *origin = inf.origin_contexts (this)[0];
+      add_to_group (align_name, item);
+    }
+}
+
+void
+Break_align_engraver::create_alignment (Grob_info inf)
+{
+  align_ = make_item ("BreakAlignment", SCM_EOL);
 
-         Translator_group *tg = origin ->implementation ();
-         Engraver *random_source =  dynamic_cast<Engraver*> (unsmob_translator (scm_car (tg->get_simple_trans_list ())));
+  Context *origin = inf.origin_contexts (this)[0];
 
-         /*
-           Make left edge appear to come from same context as clef/bar-line etc.
-          */
-         left_edge_ = make_item_from_properties (random_source,
-                                                 ly_symbol2scm ("LeftEdge"),
-                                                 SCM_EOL,
-                                                 "LeftEdge");
-         add_to_group (left_edge_->get_property ("break-align-symbol"),
-                       left_edge_);
-       }
+  Translator_group *tg = origin->implementation ();
+  Engraver *random_source = dynamic_cast<Engraver *> (unsmob_translator (scm_car (tg->get_simple_trans_list ())));
+  if (!random_source)
+    random_source = this;
 
-      add_to_group (align_name, item);
-    }
+  /*
+    Make left edge appear to come from same context as clef/bar-line etc.
+  */
+  left_edge_ = random_source->make_item ("LeftEdge", SCM_EOL);
+  add_to_group (left_edge_->get_property ("break-align-symbol"),
+               left_edge_);
 }
 
 void
@@ -117,17 +132,28 @@ Break_align_engraver::add_to_group (SCM align_name, Item *item)
 
       column_alist_ = scm_assoc_set_x (column_alist_, align_name, group->self_scm ());
 
-      Break_align_interface::add_element (align_, group);
+      Break_alignment_interface::add_element (align_, group);
     }
   Axis_group_interface::add_element (group, item);
 }
-ADD_ACKNOWLEDGER(Break_align_engraver, break_aligned);
+
+ADD_ACKNOWLEDGER (Break_align_engraver, break_aligned);
+ADD_ACKNOWLEDGER (Break_align_engraver, break_alignable);
 ADD_TRANSLATOR (Break_align_engraver,
-               "Align grobs with corresponding @code{break-align-symbols} into "
-               "groups, and order the groups according to @code{breakAlignOrder}. "
-               "The left edge of the alignment gets a separate group, with a symbol @code{left-edge}. ",
-               /* creats*/ "BreakAlignment BreakAlignGroup LeftEdge",
-               /* accepts */ "",
-               /* acks  */ "",
-               /* reads */ "",
-               /* write */ "");
+               /* doc */
+               "Align grobs with corresponding @code{break-align-symbols}"
+               " into groups, and order the groups according to"
+               " @code{breakAlignOrder}.  The left edge of the alignment gets"
+               " a separate group, with a symbol @code{left-edge}.",
+
+               /* create */
+               "BreakAlignment "
+               "BreakAlignGroup "
+               "LeftEdge ",
+
+               /* read */
+               "",
+
+               /* write */
+               ""
+               );