From: Mike Solomon Date: Wed, 29 Aug 2012 08:06:36 +0000 (+0200) Subject: Extracts Accidentals for AccidentalPlacements in the side-position-interface. X-Git-Tag: release/2.17.2-1~40 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=b0f94fb2156046b5fc721f271d55e2feb788167d;p=lilypond.git Extracts Accidentals for AccidentalPlacements in the side-position-interface. Because AccidentalPlacements have no height, this makes sure that all accidentals are accounted for in case an engraver missed them. --- diff --git a/input/regression/accidental-fingering-collision.ly b/input/regression/accidental-fingering-collision.ly new file mode 100644 index 0000000000..ac7a07e9c0 --- /dev/null +++ b/input/regression/accidental-fingering-collision.ly @@ -0,0 +1,13 @@ +\version "2.17.0" + +\header { + texidoc = "Horizontal @code{Fingering} grobs should not collide with +accidentals. +" +} + +\relative c' { + \time 2/4 + \set fingeringOrientations = #'(left) + | +} \ No newline at end of file diff --git a/lily/grob.cc b/lily/grob.cc index 593b0814a6..9edf8a2f8a 100644 --- a/lily/grob.cc +++ b/lily/grob.cc @@ -20,6 +20,7 @@ #include "grob.hh" #include +#include #include "align-interface.hh" #include "axis-group-interface.hh" @@ -910,6 +911,20 @@ common_refpoint_of_array (vector const &arr, Grob *common, Axis a) return common; } +Grob * +common_refpoint_of_array (set const &arr, Grob *common, Axis a) +{ + set::iterator it; + + for (it = arr.begin (); it != arr.end (); it++) + if (common) + common = common->common_refpoint (*it, a); + else + common = *it; + + return common; +} + Interval robust_relative_extent (Grob *me, Grob *refpoint, Axis a) { diff --git a/lily/include/grob.hh b/lily/include/grob.hh index 14a7b47925..09cd566ad3 100644 --- a/lily/include/grob.hh +++ b/lily/include/grob.hh @@ -25,6 +25,8 @@ #include "dimension-cache.hh" #include "grob-interface.hh" +#include + class Grob { private: @@ -171,6 +173,7 @@ Item *unsmob_item (SCM); /* refpoints */ Grob *common_refpoint_of_list (SCM elt_list, Grob *, Axis a); Grob *common_refpoint_of_array (vector const &, Grob *, Axis a); +Grob *common_refpoint_of_array (set const &, Grob *, Axis a); System *get_root_system (Grob *me); /* extents */ diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index 75104e44b9..5a0d16606c 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -21,11 +21,13 @@ #include // ceil. #include +#include #include using namespace std; #include "accidental-interface.hh" +#include "accidental-placement.hh" #include "axis-group-interface.hh" #include "directional-element-interface.hh" #include "grob.hh" @@ -80,6 +82,34 @@ finish_offset (Grob *me, Direction dir, Real total_off, Real *current_offset) return scm_from_double (total_off); } +set +get_support_set (Grob *me) +{ + // Only slightly kludgy heuristic... + // We want to make sure that all AccidentalPlacements' + // accidentals make it into the side support + extract_grob_set (me, "side-support-elements", proto_support); + set support; + + for (vsize i = 0; i < proto_support.size (); i++) + { + if (Accidental_placement::has_interface (proto_support[i])) + { + Grob *accs = proto_support[i]; + for (SCM acs = accs->get_object ("accidental-grobs"); scm_is_pair (acs); + acs = scm_cdr (acs)) + for (SCM s = scm_cdar (acs); scm_is_pair (s); s = scm_cdr (s)) + { + Grob *a = unsmob_grob (scm_car (s)); + support.insert (a); + } + } + else + support.insert (proto_support[i]); + } + return support; +} + /* Put the element next to the support, optionally taking in account the extent of the support. @@ -91,7 +121,7 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten bool pure, int start, int end, Real *current_offset) { - extract_grob_set (me, "side-support-elements", support); + set support = get_support_set (me); Grob *common = common_refpoint_of_array (support, me->get_parent (a), a); Grob *staff_symbol = Staff_symbol_referencer::get_staff_symbol (me); @@ -114,9 +144,11 @@ Side_position_interface::general_side_position (Grob *me, Axis a, bool use_exten Direction dir = get_grob_direction (me); - for (vsize i = 0; i < support.size (); i++) + set::iterator it; + + for (it = support.begin (); it != support.end (); it++) { - Grob *e = support[i]; + Grob *e = *it; // In the case of a stem, we will find a note head as well // ignoring the stem solves cyclic dependencies if the stem is @@ -166,7 +198,7 @@ Side_position_interface::skyline_side_position (Grob *me, Axis a, bool pure, int start, int end, Real *current_offset) { - extract_grob_set (me, "side-support-elements", support); + set support = get_support_set (me); Grob *common[2]; for (Axis ax = X_AXIS; ax < NO_AXES; incr (ax)) @@ -210,10 +242,12 @@ Side_position_interface::skyline_side_position (Grob *me, Axis a, vector boxes; vector skyps; Real min_h = dir == LEFT ? infinity_f : -infinity_f; + set::iterator it; + map > note_column_map; // for parts of a note column - for (vsize i = 0; i < support.size (); i++) + for (it = support.begin (); it != support.end (); it++) { - Grob *e = support[i]; + Grob *e = *it; // In the case of a stem, we will find a note head as well // ignoring the stem solves cyclic dependencies if the stem is