]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.113
authorfred <fred>
Wed, 27 Mar 2002 00:33:57 +0000 (00:33 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:33:57 +0000 (00:33 +0000)
lily/align-interface.cc
lily/align-note-column-engraver.cc
lily/break-align-item.cc
lily/cross-staff.cc
lily/include/align-interface.hh
lily/vertical-align-engraver.cc
ly/engraver.ly
scm/translator-properties.scm

index db7963ad2150ebca75562e6d076449c294b51d3d..58077373c847f5525c577ae7ba0dbfb139fc577a 100644 (file)
@@ -26,26 +26,82 @@ Align_interface::alignment_callback (SCM element_smob, SCM axis)
   Grob * par = me->parent_l (ax);
   if (par && !to_boolean (par->get_grob_property ("alignment-done")))
     {
-      Align_interface::do_side_processing (par, ax);
+      Align_interface::align_to_extents (par, ax);
     }
   return gh_double2scm (0.0);
 }
 
+MAKE_SCHEME_CALLBACK(Align_interface,fixed_distance_alignment_callback,2);
+SCM
+Align_interface::fixed_distance_alignment_callback (SCM element_smob, SCM axis)
+{
+  Grob * me = unsmob_grob (element_smob);
+  Axis ax = (Axis )gh_scm2int (axis);
+  Grob * par = me->parent_l (ax);
+  if (par && !to_boolean (par->get_grob_property ("alignment-done")))
+    {
+      Align_interface::align_to_fixed_distance (par, ax);
+    }
+  return gh_double2scm (0.0);
+}
+
+void
+Align_interface::align_to_fixed_distance (Grob *me , Axis a)
+{
+  me->set_grob_property ("alignment-done", SCM_BOOL_T);
+  
+  SCM d =   me->get_grob_property ("stacking-dir");
+
+  
+  Direction stacking_dir = gh_number_p(d) ? to_dir (d) : CENTER;
+  if (!stacking_dir)
+    stacking_dir = DOWN;
+
+
+  SCM force = me->get_grob_property ("forced-distance");
+
+  Real dy = 0.0;
+  if (gh_number_p (force))
+    {
+      dy = gh_scm2double (force);
+    }
+  
+  Link_array<Grob> elems
+    = Pointer_group_interface__extract_elements (  me, (Grob*) 0, "elements");
+  Real where_f=0;
+  for (int j=0 ;  j < elems.size(); j++) 
+    {
+      where_f += stacking_dir * dy;
+      elems[j]->translate_axis (where_f, a);
+    }
+}
 
 /*
   Hairy function to put elements where they should be. Can be tweaked
   from the outside by setting minimum-space and extra-space in its
   children */
 void
-Align_interface::do_side_processing (Grob * me, Axis a)
+Align_interface::align_to_extents (Grob * me, Axis a)
 {
   me->set_grob_property ("alignment-done", SCM_BOOL_T);
   
   SCM d =   me->get_grob_property ("stacking-dir");
+
+  
   Direction stacking_dir = gh_number_p(d) ? to_dir (d) : CENTER;
   if (!stacking_dir)
     stacking_dir = DOWN;
 
+
+  
+  Interval threshold = Interval (0, Interval::infinity ());
+  SCM thr = me->get_grob_property ("threshold");
+  if (gh_pair_p (thr))
+    {
+      threshold[SMALLER] = gh_scm2double (gh_car (thr));
+      threshold[BIGGER] = gh_scm2double (gh_cdr (thr));      
+    }
+
   
   Array<Interval> dims;
 
@@ -82,24 +138,16 @@ Align_interface::do_side_processing (Grob * me, Axis a)
          dims.push (y);          
        }
     }
-
   
-  Interval threshold = Interval (0, Interval::infinity ());
-  SCM thr = me->get_grob_property ("threshold");
-  if (gh_pair_p (thr))
-    {
-      Real ss = 1.0;
-      threshold[SMALLER] = ss *gh_scm2double (gh_car (thr));
-      threshold[BIGGER] = ss * gh_scm2double (gh_cdr (thr));      
-    }
-
   Real where_f=0;
   for (int j=0 ;  j < elems.size(); j++) 
     {
-      Real dy = - stacking_dir * dims[j][-stacking_dir];
+      Real dy = 0.0;
+      dy = - stacking_dir * dims[j][-stacking_dir];
       if (j)
        dy += stacking_dir * dims[j-1][stacking_dir];
-
+      
       if (j)
        {
          dy = (dy >? threshold[SMALLER] )
@@ -138,9 +186,9 @@ Align_interface::get_count (Grob*me,Grob*s)
 }
 
 void
-Align_interface::add_element (Grob*me,Grob* s)
+Align_interface::add_element (Grob*me,Grob* s, SCM cb)
 {
-  s->add_offset_callback (Align_interface::alignment_callback_proc, Align_interface::axis (me));
+  s->add_offset_callback (cb, Align_interface::axis (me));
   Axis_group_interface::add_element (me, s);
 }
 
index 5904c223e7420cdee41cf506c167f7358dd9fc94..0f7f67afabd434477d4aed6600019cfe13e8f309 100644 (file)
@@ -116,8 +116,7 @@ Align_note_column_engraver::create_grobs ()
       
   if (now_column_l_)
     {
-       
-      Align_interface::add_element (align_item_p_,now_column_l_);
+      Align_interface::add_element (align_item_p_,now_column_l_, Align_interface::alignment_callback_proc);
       now_column_l_ =0;
     }
 }
index 38705e1d74ae19941a8c30f85b62de3e117dacee..4b5c956cc70186fd3784ace59a3ad835f6f938d5 100644 (file)
@@ -169,7 +169,7 @@ Break_align_interface::do_alignment (Grob *me)
   /*
     Force callbacks for alignment to be called   
   */
-  Align_interface::do_side_processing (me, X_AXIS);
+  Align_interface::align_to_extents (me, X_AXIS);
 
   Real pre_space = elems[0]->relative_coordinate (column, X_AXIS);
 
index c45395ae5a371cd40d76d49646af544c3ec1ac40..4bb5e0de00c461ee7f8e2506ff7d9a703dfd50a1 100644 (file)
@@ -4,6 +4,8 @@
 #include "spanner.hh"
 #include "warn.hh"
 #include "paper-def.hh"
+
+
 /*
   JUNKME
  */
@@ -16,16 +18,12 @@ calc_interstaff_dist (Item  *item, Spanner  *span)
 
   if (Align_interface::has_interface (common) && Align_interface::axis(common) == Y_AXIS)
     {
-      SCM threshold = common->get_grob_property ("threshold");
-      if (!gh_pair_p (threshold)
-         || !scm_equal_p (gh_car (threshold), gh_cdr (threshold)))
-       warning (_ ("minVerticalAlign != maxVerticalAlign: cross staff spanners may be broken"));
-
-
-      
+      SCM threshold = common->get_grob_property ("forced-distance");
       interstaff = 1.0;
-      if (gh_pair_p (threshold))
-       interstaff =  gh_scm2double (gh_car (threshold)) * interstaff;
+      if (!gh_number_p (threshold))
+       warning (_ ("not a forced distance; cross-staff spanners may be broken"));
+      else
+       interstaff *= gh_scm2double (threshold);
 
       Grob  * span_refpoint = span;
       while (span_refpoint->parent_l  (Y_AXIS) != common)
index 058d4c7a14c287afe66bea1177dc102a6bd24b73..9b7c646ef7c3de367a7f42233211a40a262e173d 100644 (file)
 
 struct Align_interface {
   DECLARE_SCHEME_CALLBACK(alignment_callback, (SCM element, SCM axis));
-  static void do_side_processing (Grob*,Axis a);
+  DECLARE_SCHEME_CALLBACK(fixed_distance_alignment_callback, (SCM element, SCM axis));
+  static void align_to_fixed_distance (Grob*,Axis a);
+  static void align_to_extents (Grob*,Axis a);
   static void set_axis (Grob*,Axis);
   static Axis axis (Grob*) ;
-  static void add_element (Grob*,Grob*);
+  static void add_element (Grob*,Grob*, SCM callback);
   static int get_count (Grob*,Grob*);
   static void set_interface (Grob*);
   static bool has_interface (Grob*);
-  DECLARE_SCHEME_CALLBACK(center_on_element, (SCM element, SCM axis));
 };
 
 #endif /* ALIGN_INTERFACE_HH */
index 442731b5f355cd1038abc1b8a0dd1c6f1a53b68b..59449e1f0e61b2a6b4cd3e24c67eccd473cf32cb 100644 (file)
@@ -62,7 +62,7 @@ Vertical_align_engraver::acknowledge_grob (Grob_info i)
 {
   if (qualifies_b (i))
     {
-      Align_interface::add_element (valign_p_,i.elem_l_);
+      Align_interface::add_element (valign_p_,i.elem_l_, get_property ("verticalAlignmentChildCallback"));
     }
 }
 
index d44bd8fbf62ddd8731db2dc048f0f5218c82f479..eb328cb68547f0b25a225a30e4bafe26bade47fe 100644 (file)
@@ -208,7 +208,8 @@ PianoStaffContext = \translator{
        \consists "Vertical_align_engraver";
 
        alignmentReference = \center;
-       VerticalAlignment \override #'threshold = #'(12 . 12) 
+       verticalAlignmentChildCallback = #Align_interface::fixed_distance_alignment_callback
+       VerticalAlignment \override #'forced-distance = #12
 
 %      \consistsend "Axis_group_engraver";
 }
@@ -399,6 +400,8 @@ ScoreContext = \translator {
        
        scriptDefinitions = #default-script-alist
 
+       verticalAlignmentChildCallback = #Align_interface::alignment_callback
+
        startSustain = #"Ped."
        stopSustain = #"*"
        stopStartSustain = #"*Ped."
index 42a14ef3c4b2c63edc872e3a69fee5f9f9652704..dec53c590565619a1257edb135514d8a63952203 100644 (file)
@@ -253,6 +253,10 @@ context Voice      imes 2/3 @{
 (translator-property-description 'unirhythm boolean? "set if unirhythm is detected")
 (translator-property-description 'unisilence boolean? "set if unisilence is detected")
 (translator-property-description 'unison boolean? "set if unisono is detected  ")
+(translator-property-description 'verticalAlignmentChildCallback
+procedure? "what callback to add to children of a vertical alignment.
+It determines what alignment procedure is used on the alignment
+itself.  ")
 (translator-property-description 'voltaSpannerDuration moment? "maximum duration of the volta bracket.
 
     Set to a duration to control the size of the brackets printed by