]> git.donarmstrong.com Git - lilypond.git/commitdiff
* input/regression/alignment-order.ly: new file.
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 8 May 2005 23:17:49 +0000 (23:17 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Sun, 8 May 2005 23:17:49 +0000 (23:17 +0000)
* lily/vertical-align-engraver.cc (acknowledge_grob): read
alignAboveContext and alignBelowContext

17 files changed:
ChangeLog
Documentation/topdocs/NEWS.tely
THANKS
input/regression/alignment-order.ly [new file with mode: 0644]
lily/accidental-engraver.cc
lily/align-interface.cc
lily/context.cc
lily/engraver-group-engraver.cc
lily/font-size-engraver.cc
lily/function-documentation.cc
lily/grob-info.cc
lily/include/grob-info.hh
lily/output-property-engraver.cc
lily/score-engraver.cc
lily/vertical-align-engraver.cc
scm/define-context-properties.scm
scm/lily.scm

index 62d5a164afe1ec260e691f4eb3c16ef505aebb1f..141a16a40f8a55eead54ba9508b03bd8bd5c0dc9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-05-09  Han-Wen Nienhuys  <hanwen@xs4all.nl>
+
+       * input/regression/alignment-order.ly: new file. 
+
+       * lily/vertical-align-engraver.cc (acknowledge_grob): read
+       alignAboveContext and alignBelowContext
+
 2005-05-08  Han-Wen Nienhuys  <hanwen@xs4all.nl>
 
        * lily/pfb.cc (LY_DEFINE): add cast.
index 27e3a70d9d93bc47c360bd12a2e63a3f46ff4639..50d507eb7a8f31fc619d5882f3a5ed9d61b44115 100644 (file)
@@ -33,6 +33,15 @@ See user manual, \NAME\
 
 @itemize @bullet
 
+@item
+Newly created staves and lyric lines, can be put in any vertical order,
+by setting @code{alignBelowContext} or @code{alignAboveContext}
+properties in the newly created context. An example of the use of this
+is in @inputfileref{input/regression,alignment-order.ly}.
+
+This feature has been sponsored by Bertalan Fodor. 
+
+
 @item
 Staves may be stopped and started halfway a line, e.g.
 
diff --git a/THANKS b/THANKS
index 597afcc9d4d1ee78f6e371cd66e6e7465b68aca9..2cf6a346cc454af3d9cbd8d4bd32e4ef731960c5 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -36,6 +36,7 @@ Yuval Harel
 
 SPONSORS
 
+Bertalan Fodor
 Jonathan Walther
 Steve Doonan
 Marcus Macauley
diff --git a/input/regression/alignment-order.ly b/input/regression/alignment-order.ly
new file mode 100644 (file)
index 0000000..3291b01
--- /dev/null
@@ -0,0 +1,27 @@
+\header {
+  texidoc = "Newly created contexts can be inserted
+anywhere in the vertical alignment. "
+}
+
+\version "2.5.23"
+
+\paper {
+  raggedright = ##t
+}
+
+\relative <<
+  \context Staff = "1" { c4 c s2 }
+  \context Staff = "2" { c  c s2 }
+  \context Staff = "3" { c  c s2 }
+  { \skip 2
+    <<
+      \lyrics {
+       \set alignBelowContext = #"1"
+       below8 first staff
+      }
+      \lyrics {
+       \set alignAboveContext = #"3"
+       above8 last staff
+      }
+    >> }
+>>
index 1dc9395057210b9f637126568053fe6c45492a41..8a47a9cae1b992605aa53375ecd95a9a0721f05d 100644 (file)
@@ -492,8 +492,8 @@ Accidental_engraver::acknowledge_grob (Grob_info info)
 
          Accidental_entry entry;
          entry.head_ = info.grob_;
-         entry.origin_trans_ = dynamic_cast<Engraver *> (info.origin_trans_);
-         entry.origin_ = info.origin_trans_->context ();
+         entry.origin_trans_ = dynamic_cast<Engraver *> (info.origin_translator ());
+         entry.origin_ = entry.origin_trans_->context ();
          entry.melodic_ = note;
 
          accidentals_.push (entry);
index 3e4b9c5ca85de378a70e65096ef7c9358c12d2d9..5ae726676f107494fa5ff3b2a94d7ea64ede8ee8 100644 (file)
@@ -225,10 +225,10 @@ Align_interface::axis (Grob *me)
 }
 
 void
-Align_interface::add_element (Grob *me, Grob *s, SCM cb)
+Align_interface::add_element (Grob *me, Grob *element, SCM call_back)
 {
-  s->add_offset_callback (cb, Align_interface::axis (me));
-  Axis_group_interface::add_element (me, s);
+  element->add_offset_callback (call_back, Align_interface::axis (me));
+  Axis_group_interface::add_element (me, element);
 }
 
 void
index dc387961586d312170936075752348cfd7460426..b6ded9ec05e48736b8aacee2115e9a0e4b02c483 100644 (file)
@@ -221,14 +221,14 @@ Context::create_context (Context_def *cdef,
 {
   String type = ly_symbol2string (cdef->get_context_name ());
   Object_key const *key = get_context_key (type, id);
-  Context *new_group
+  Context *new_context
     = cdef->instantiate (ops, key);
 
-  new_group->id_string_ = id;
-  add_context (new_group);
-  apply_property_operations (new_group, ops);
+  new_context->id_string_ = id;
+  add_context (new_context);
+  apply_property_operations (new_context, ops);
 
-  return new_group;
+  return new_context;
 }
 
 Object_key const *
index 37811f925b4017d5798698cb1f64c2b70f6930b7..5270d7121ce13126e168c6fd85f7d9d652064949 100644 (file)
@@ -67,7 +67,7 @@ Engraver_group_engraver::acknowledge_grobs ()
        {
          Translator *t = unsmob_translator (scm_car (p));
          Engraver *eng = dynamic_cast<Engraver *> (t);
-         if (eng && eng != info.origin_trans_)
+         if (eng && eng != info.origin_translator ())
            eng->acknowledge_grob (info);
        }
     }
index a5f7848c7f455063899787b15ba332d2fe94b7a4..bc372a6a43e03481c6e387cdc286733c3d752792 100644 (file)
@@ -30,7 +30,7 @@ Font_size_engraver::acknowledge_grob (Grob_info gi)
   /*
     We only want to process a grob once.
   */
-  if (gi.origin_trans_->context () != context ())
+  if (gi.context () != context ())
     return;
 
   if (scm_is_number (sz) && scm_to_double (sz))
index 8daf4baf0cf73f87cbbfa508a91817f27400ccd8..bfa68ec5465c33fbd0e54ffcc75480c9c557a36e 100644 (file)
@@ -22,7 +22,7 @@ void ly_add_function_documentation (SCM func,
     return;
 
   if (!scm_is_vector (doc_hash_table))
-    doc_hash_table = scm_make_vector (scm_int2num (59), SCM_EOL);
+    doc_hash_table = scm_c_make_hash_table (59);
 
   String s = String (" - ") + "LilyPond procedure: " + fname + " " + varlist
     + "\n" + doc;
index 38d074dde677a189672b8ab3b74f0766c6272e52..6b69bfeab63949037d0428a36601748927d02a28 100644 (file)
@@ -7,12 +7,18 @@
 */
 
 #include "grob-info.hh"
-
 #include "grob.hh"
 #include "music.hh"
 #include "translator-group.hh"
 #include "context.hh"
 
+
+Grob_info::Grob_info (Translator *t, Grob *g)
+{
+  origin_trans_ = t;
+  grob_ = g;
+}
+
 Grob_info::Grob_info ()
 {
   grob_ = 0;
@@ -41,3 +47,10 @@ Grob_info::origin_contexts (Translator *end) const
   return r;
 }
 
+
+Context*
+Grob_info::context () const
+{
+  return origin_trans_->context ();
+}
+
index 4ebc0b2999ac38bb6e83752db4c2810f7605bb35..06b48ab89b72b8aac42f70feb5eccfd0e27c13ca 100644 (file)
 /*
   Data container for broadcasts.
 */
-struct Grob_info
+class Grob_info
 {
   Translator *origin_trans_;
   friend class Engraver;
 
-  Grob *grob_;
-
 public:
+  Grob *grob_;
+  Context *context () const; 
+  Translator *origin_translator () const { return origin_trans_; } 
   Music *music_cause ();
   Link_array<Context> origin_contexts (Translator *) const;
+  Grob_info (Translator *, Grob *);
   Grob_info ();
 };
 
index b8cc5d28796ada6e8ac90800702f7bed43abc8f3..dc7207a3ed155b0b3d0f195b3d9b576335d37be4 100644 (file)
@@ -59,12 +59,7 @@ Output_property_engraver::acknowledge_grob (Grob_info inf)
        }
       else
        {
-         Context * d =
-           dynamic_cast<Context *> (inf.origin_trans_);
-
-         if (!d)
-           d = dynamic_cast<Context *> (inf.origin_trans_->context ());
-         
+         Context * d = inf.context ();
          SCM proc = o->get_property ("procedure");
          scm_call_3 (proc,
                      inf.grob_->self_scm (),
index 442574125418c212a9039b419b668ce959bb7d57..0f01110780f582f50138ee58ddd92a71c207e452 100644 (file)
@@ -53,16 +53,10 @@ Score_engraver::make_columns ()
       Object_key const *key2 = context ()->get_grob_key ("PaperColumn");
       set_columns (new Paper_column (nmp, key1), new Paper_column (pc, key2));
 
-      Grob_info i1;
-      i1.grob_ = command_column_;
-      i1.origin_trans_ = this;
-
+      Grob_info i1 (this, command_column_);
       announce_grob (i1);
 
-      Grob_info i2;
-      i2.grob_ = musical_column_;
-      i2.origin_trans_ = this;
-
+      Grob_info i2 (this, musical_column_);
       announce_grob (i2);
     }
 }
index 20c3ac53e495d0ab8104b05761d614a118523424..3e1838ae1f7cd669d0b71d5ffa3b5b4d02d982ab 100644 (file)
@@ -18,21 +18,49 @@ class Vertical_align_engraver : public Engraver
 {
   Spanner *valign_;
   bool qualifies (Grob_info) const;
-
+  SCM id_to_group_hashtab_;  
+  
 public:
   TRANSLATOR_DECLARATIONS (Vertical_align_engraver);
 
 protected:
+  virtual void derived_mark () const;
   virtual void acknowledge_grob (Grob_info);
   virtual void process_music ();
   virtual void finalize ();
+  virtual void initialize ();
 };
 
+
+ADD_TRANSLATOR (Vertical_align_engraver,
+               "Catch groups (staffs, lyrics lines, etc.) and stack "
+               "them vertically.",
+               /* creats*/ "VerticalAlignment",
+               /* accepts */ "",
+               /* acks  */ "axis-group-interface",
+               /* reads */ "",
+               /* write */ "");
+
+
 Vertical_align_engraver::Vertical_align_engraver ()
 {
   valign_ = 0;
+  id_to_group_hashtab_ = SCM_EOL;
+}
+
+void
+Vertical_align_engraver::derived_mark () const
+{
+  scm_gc_mark (id_to_group_hashtab_); 
 }
 
+void
+Vertical_align_engraver::initialize ()
+{
+  id_to_group_hashtab_ = scm_c_make_hash_table (11);
+}
+
+
 void
 Vertical_align_engraver::process_music ()
 {
@@ -67,14 +95,46 @@ Vertical_align_engraver::acknowledge_grob (Grob_info i)
 {
   if (qualifies (i))
     {
-      Align_interface::add_element (valign_, i.grob_, get_property ("verticalAlignmentChildCallback"));
+      String id = i.context ()->id_string ();
+
+      scm_hash_set_x (id_to_group_hashtab_, scm_makfrom0str (id.to_str0 ()),
+                     i.grob_->self_scm ());
+
+
+      SCM before_id = i.context ()->get_property ("alignAboveContext");
+      SCM after_id = i.context ()->get_property ("alignBelowContext");
+      
+      SCM before = scm_hash_ref (id_to_group_hashtab_,  before_id, SCM_BOOL_F);
+      SCM after = scm_hash_ref (id_to_group_hashtab_,  after_id, SCM_BOOL_F);
+
+
+      Align_interface::add_element (valign_, i.grob_,
+                                   get_property ("verticalAlignmentChildCallback"));
+
+      if (unsmob_grob (before) || unsmob_grob (after))
+       {
+         SCM elts = valign_->get_property ("elements");
+         SCM new_order = scm_cdr (elts);
+         SCM *current = &new_order;
+
+         for (SCM s = new_order;  scm_is_pair (s); s = scm_cdr (s))
+           {
+             if (scm_car (s) == after)
+               {
+                 *current = scm_cons (i.grob_->self_scm(), s);
+                 break;
+               }
+             else if (scm_car (s) == before)
+               {
+                 scm_set_cdr_x (s, scm_cons (i.grob_->self_scm (),
+                                             scm_cdr (s)));
+                 break;
+               }
+
+             current = SCM_CDRLOC (s);
+           }
+
+         valign_->set_property ("elements", new_order);
+       }
     }
 }
-
-ADD_TRANSLATOR (Vertical_align_engraver,
-               /* descr */ "Catch Vertical axis groups and stack them.",
-               /* creats*/ "VerticalAlignment",
-               /* accepts */ "",
-               /* acks  */ "axis-group-interface",
-               /* reads */ "",
-               /* write */ "");
index 5583927759a0d0d81b7e6954e8456f033b5c1198..d15ed9b30340df60fea37cb075d7852b8af7a455 100644 (file)
@@ -23,6 +23,8 @@
      (apply translator-property-description x))
    `(
      (aDueText ,string? "Text to print at a unisono passage.")
+     (alignBelowContext ,string? "Where to insert newly created context in vertiical alignment.")
+     (alignAboveContext ,string? "Where to insert newly created context in vertiical alignment.")
      (alignBassFigureAccidentals ,boolean?
                                 "If true, then the accidentals are aligned in bass figure context.")
 
index 79f88d2af6c7b4043301d764fdf57e2139a729e0..4c0f0abc943ac43fafcc7326aba8a57c6fbf0b00 100644 (file)
@@ -36,8 +36,6 @@
       (debug-enable 'backtrace)
       (read-enable 'positions)))
 
-
-
 ;; initialize defaults. 
 (ly:set-option 'command-line-settings
               '((resolution . 90)