From e1f88a2ebc1428b103b2ee8a12317450fd7fbc6e Mon Sep 17 00:00:00 2001 From: fred Date: Wed, 27 Mar 2002 00:33:57 +0000 Subject: [PATCH] lilypond-1.3.113 --- lily/align-interface.cc | 80 ++++++++++++++++++++++++------ lily/align-note-column-engraver.cc | 3 +- lily/break-align-item.cc | 2 +- lily/cross-staff.cc | 16 +++--- lily/include/align-interface.hh | 7 +-- lily/vertical-align-engraver.cc | 2 +- ly/engraver.ly | 5 +- scm/translator-properties.scm | 4 ++ 8 files changed, 86 insertions(+), 33 deletions(-) diff --git a/lily/align-interface.cc b/lily/align-interface.cc index db7963ad21..58077373c8 100644 --- a/lily/align-interface.cc +++ b/lily/align-interface.cc @@ -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 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 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); } diff --git a/lily/align-note-column-engraver.cc b/lily/align-note-column-engraver.cc index 5904c223e7..0f7f67afab 100644 --- a/lily/align-note-column-engraver.cc +++ b/lily/align-note-column-engraver.cc @@ -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; } } diff --git a/lily/break-align-item.cc b/lily/break-align-item.cc index 38705e1d74..4b5c956cc7 100644 --- a/lily/break-align-item.cc +++ b/lily/break-align-item.cc @@ -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); diff --git a/lily/cross-staff.cc b/lily/cross-staff.cc index c45395ae5a..4bb5e0de00 100644 --- a/lily/cross-staff.cc +++ b/lily/cross-staff.cc @@ -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) diff --git a/lily/include/align-interface.hh b/lily/include/align-interface.hh index 058d4c7a14..9b7c646ef7 100644 --- a/lily/include/align-interface.hh +++ b/lily/include/align-interface.hh @@ -16,14 +16,15 @@ 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 */ diff --git a/lily/vertical-align-engraver.cc b/lily/vertical-align-engraver.cc index 442731b5f3..59449e1f0e 100644 --- a/lily/vertical-align-engraver.cc +++ b/lily/vertical-align-engraver.cc @@ -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")); } } diff --git a/ly/engraver.ly b/ly/engraver.ly index d44bd8fbf6..eb328cb685 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -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." diff --git a/scm/translator-properties.scm b/scm/translator-properties.scm index 42a14ef3c4..dec53c5905 100644 --- a/scm/translator-properties.scm +++ b/scm/translator-properties.scm @@ -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 -- 2.39.5