From 1152d91a1c8ac90528660df7dfa6be2181f89c05 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C5=81ukasz=20Czerwi=C5=84ski?= Date: Mon, 30 Apr 2012 13:11:48 +0200 Subject: [PATCH] Issue 2491: Macro for(UP_and_DOWN) and 3 similar. Replaces do{ ... } while(flip (&d) != DOWN/UP/... with a macro for(DOWN_and_UP/UP_and_DOWN/....) { } Signed-off-by: David Kastrup --- flower/include/direction.hh | 12 +++++- lily/ambitus-engraver.cc | 12 ++---- lily/axis-group-interface.cc | 4 +- lily/beam-quanting.cc | 44 ++++++---------------- lily/beam.cc | 35 +++++------------ lily/bezier.cc | 4 +- lily/break-substitution.cc | 4 +- lily/dynamic-align-engraver.cc | 5 +-- lily/figured-bass-continuation.cc | 5 +-- lily/hairpin.cc | 15 ++------ lily/horizontal-bracket.cc | 8 +--- lily/interval-minefield.cc | 6 +-- lily/item.cc | 17 +++------ lily/ledger-line-spanner.cc | 8 +--- lily/line-spanner.cc | 16 +++----- lily/lookup.cc | 4 +- lily/lyric-hyphen.cc | 8 +--- lily/multi-measure-rest-engraver.cc | 4 +- lily/multi-measure-rest.cc | 4 +- lily/new-fingering-engraver.cc | 4 +- lily/note-collision.cc | 29 ++++---------- lily/note-spacing.cc | 5 +-- lily/optimal-page-breaking.cc | 3 +- lily/ottava-bracket.cc | 10 ++--- lily/ottava-engraver.cc | 4 +- lily/paper-column.cc | 4 +- lily/piano-pedal-bracket.cc | 4 +- lily/rest-collision.cc | 12 ++---- lily/rod.cc | 4 +- lily/script-column.cc | 4 +- lily/slur-configuration.cc | 14 +++---- lily/slur-scoring.cc | 48 +++++++----------------- lily/slur.cc | 20 +++------- lily/spacing-determine-loose-columns.cc | 4 +- lily/spacing-interface.cc | 4 +- lily/spacing-spanner.cc | 7 ++-- lily/spanner.cc | 28 ++++---------- lily/staff-symbol.cc | 4 +- lily/stem.cc | 12 ++---- lily/system-start-delimiter.cc | 4 +- lily/system.cc | 4 +- lily/tie-column.cc | 4 +- lily/tie-engraver.cc | 4 +- lily/tie-formatting-problem.cc | 36 +++++------------- lily/tie.cc | 8 +--- lily/tuplet-bracket.cc | 50 +++++++------------------ 46 files changed, 161 insertions(+), 388 deletions(-) diff --git a/flower/include/direction.hh b/flower/include/direction.hh index 50c41a4ab4..97c0f6d79b 100644 --- a/flower/include/direction.hh +++ b/flower/include/direction.hh @@ -60,7 +60,7 @@ operator - (Direction const d) return other_dir (d); } -// huh? +// to be deleted soon (after coping with issues 2491 and 2493 inline Direction flip (Direction *i) { @@ -71,6 +71,16 @@ flip (Direction *i) return *i; } +#define UP_and_DOWN(d) \ + Direction d = UP; d != CENTER; d = (d == UP ? DOWN : CENTER) + +#define DOWN_and_UP(d) \ + Direction d = DOWN; d != CENTER; d = (d == DOWN ? UP : CENTER) + +#define LEFT_and_RIGHT(d) \ + Direction d = LEFT; d != CENTER; d = (d == LEFT ? RIGHT : CENTER) + + /** if d > 0: the max operator if d < 0: the min operator diff --git a/lily/ambitus-engraver.cc b/lily/ambitus-engraver.cc index 2d2f027c4e..92fee10a50 100644 --- a/lily/ambitus-engraver.cc +++ b/lily/ambitus-engraver.cc @@ -71,8 +71,7 @@ Ambitus_engraver::create_ambitus () { ambitus_ = make_item ("AmbitusLine", SCM_EOL); group_ = make_item ("Ambitus", SCM_EOL); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { heads_[d] = make_item ("AmbitusNoteHead", SCM_EOL); accidentals_[d] = make_item ("AmbitusAccidental", SCM_EOL); @@ -82,7 +81,6 @@ Ambitus_engraver::create_ambitus () Axis_group_interface::add_element (group_, heads_[d]); Axis_group_interface::add_element (group_, accidentals_[d]); } - while (flip (&d) != DOWN); ambitus_->set_parent (heads_[DOWN], X_AXIS); Axis_group_interface::add_element (group_, ambitus_); @@ -164,8 +162,7 @@ Ambitus_engraver::finalize () Grob *accidental_placement = make_item ("AccidentalPlacement", accidentals_[DOWN]->self_scm ()); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { Pitch p = pitch_interval_[d]; heads_[d]->set_property ("cause", causes_[d]->self_scm ()); @@ -205,19 +202,16 @@ Ambitus_engraver::finalize () ly_symbol2scm ("note-heads"), heads_[d]); } - while (flip (&d) != DOWN); Axis_group_interface::add_element (group_, accidental_placement); } else { - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { accidentals_[d]->suicide (); heads_[d]->suicide (); } - while (flip (&d) != DOWN); ambitus_->suicide (); } diff --git a/lily/axis-group-interface.cc b/lily/axis-group-interface.cc index 8857de109d..1b937985ee 100644 --- a/lily/axis-group-interface.cc +++ b/lily/axis-group-interface.cc @@ -476,14 +476,12 @@ Axis_group_interface::internal_calc_pure_relevant_grobs (Grob *me, string grob_s if (Item *it = dynamic_cast (elts[i])) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *piece = it->find_prebroken_piece (d); if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL))) relevant_grobs.push_back (piece); } - while (flip (&d) != LEFT); } } diff --git a/lily/beam-quanting.cc b/lily/beam-quanting.cc index f2c35973e4..ac845103ea 100644 --- a/lily/beam-quanting.cc +++ b/lily/beam-quanting.cc @@ -193,10 +193,8 @@ void Beam_scoring_problem::init_instance_variables (Grob *me, Drul_array y the stems. Otherwise, we want to do initial slope calculations. */ do_initial_slope_calculations_ = false; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) do_initial_slope_calculations_ |= isinf (unquanted_y_[d]) || isnan (unquanted_y_[d]); - while (flip (&d) != LEFT); /* Calculations are relative to a unit-scaled staff, i.e. the quants are @@ -245,10 +243,8 @@ void Beam_scoring_problem::init_instance_variables (Grob *me, Drul_array y for (int a = 2; a--;) common[a] = common_refpoint_of_array (stems, beams[i], Axis (a)); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) common[X_AXIS] = beams[i]->get_bound (d)->common_refpoint (common[X_AXIS], X_AXIS); - while (flip (&d) != LEFT); // positions of the endpoints of this beam segment, including any overhangs const Interval x_pos = robust_scm2interval (beams[i]->get_property ("X-positions"), @@ -309,8 +305,7 @@ void Beam_scoring_problem::init_instance_variables (Grob *me, Drul_array y // TODO - why are we dividing by staff_space_? beam_translation_ = Beam::get_beam_translation (beams[i]) / staff_space_; - d = LEFT; - do + for (LEFT_and_RIGHT (d)) { quant_range_[d].set_full (); if (!edge_stems[d]) @@ -325,7 +320,6 @@ void Beam_scoring_problem::init_instance_variables (Grob *me, Drul_array y + (edge_beam_counts_[d] - 1) * beam_translation_ + beam_thickness_ * .5); quant_range_[d][-ed] = heads[ed] + stem_offset; } - while (flip (&d) != LEFT); segments_ = Beam::get_beam_segments (beams[i]); vector_sort (segments_, beam_segment_less); @@ -355,10 +349,8 @@ void Beam_scoring_problem::init_instance_variables (Grob *me, Drul_array y Real width = b[X_AXIS].length (); Real width_factor = sqrt (width / staff_space_); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) add_collision (b[X_AXIS][d], b[Y_AXIS], width_factor); - while (flip (&d) != LEFT); Grob *stem = unsmob_grob (collisions[j]->get_object ("stem")); if (stem && Stem::has_interface (stem) && Stem::is_normal_stem (stem)) @@ -794,23 +786,19 @@ Beam_scoring_problem::shift_region_to_valid () if (collisions_[i].y_.length () < min_y_size) continue; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Real dy = slope * collisions_[i].x_; - Direction yd = DOWN; Interval disallowed; - do + for (DOWN_and_UP (yd)) { Real left_y = collisions_[i].y_[yd] - dy; disallowed[yd] = left_y; } - while (flip (&yd) != DOWN); forbidden_intervals.push_back (disallowed); } - while (flip (&d) != LEFT); } vector_sort (forbidden_intervals, Interval::left_less); @@ -825,13 +813,11 @@ Beam_scoring_problem::shift_region_to_valid () // if the beam placement falls out of the feasible region, we push it // to infinity so that it can never be a feasible candidate below - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { if (!feasible_left_point.contains (feasible_beam_placements[d])) feasible_beam_placements[d] = d * infinity_f; } - while (flip (&d) != DOWN); if ((feasible_beam_placements[UP] == infinity_f && feasible_beam_placements[DOWN] == -infinity_f) && !feasible_left_point.is_empty ()) { @@ -892,8 +878,7 @@ Beam_scoring_problem::generate_quants (vector *scores) con Interval (unshifted_quants[i], unshifted_quants[j])); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (!quant_range_[d].contains (c->y[d])) { @@ -902,7 +887,6 @@ Beam_scoring_problem::generate_quants (vector *scores) con break; } } - while (flip (&d) != LEFT); if (c) scores->push_back (c); } @@ -1098,10 +1082,8 @@ Beam_scoring_problem::score_stem_lengths (Beam_configuration *config) const } /* Divide by number of stems, to make the measure scale-free. */ - Direction d = DOWN; - do + for (DOWN_and_UP (d)) score[d] /= max (count[d], 1); - while (flip (&d) != DOWN); /* sometimes, two perfectly symmetric kneed beams will have the same score @@ -1211,11 +1193,10 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const Real extra_demerit = parameters_.SECONDARY_BEAM_DEMERIT / max (edge_beam_counts_[LEFT], edge_beam_counts_[RIGHT]); - Direction d = LEFT; Real dem = 0.0; Real eps = parameters_.BEAM_EPS; - do + for (LEFT_and_RIGHT (d)) { for (int j = 1; j <= edge_beam_counts_[d]; j++) { @@ -1258,7 +1239,6 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const } } } - while ((flip (&d)) != LEFT); if (max (edge_beam_counts_[LEFT], edge_beam_counts_[RIGHT]) >= 2) { @@ -1267,8 +1247,7 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const Real inter = 0.5; Real hang = 1.0 - (beam_thickness_ - line_thickness_) / 2; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (edge_beam_counts_[d] >= 2 && fabs (config->y[d] - edge_dirs_[d] * beam_translation_) < staff_radius_ + inter) @@ -1296,7 +1275,6 @@ Beam_scoring_problem::score_forbidden_quants (Beam_configuration *config) const dem += extra_demerit; } } - while (flip (&d) != LEFT); } config->add (dem, "F"); diff --git a/lily/beam.cc b/lily/beam.cc index 0cfc3e193c..e2d1293187 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -284,9 +284,8 @@ Beam::calc_beaming (SCM smob) last_dir ? last_dir : this_dir, this_dir); - Direction d = LEFT; Slice new_slice; - do + for (LEFT_and_RIGHT (d)) { new_slice.set_empty (); SCM s = index_get_cell (this_beaming, d); @@ -299,7 +298,6 @@ Beam::calc_beaming (SCM smob) scm_set_car_x (s, scm_from_int (new_beam_pos)); } } - while (flip (&d) != LEFT); if (!new_slice.is_empty ()) last_int = new_slice; @@ -351,10 +349,8 @@ Beam::calc_beam_segments (SCM smob) extract_grob_set (me, "stems", stems); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) commonx = me->get_bound (d)->common_refpoint (commonx, X_AXIS); - while (flip (&d) != LEFT); int gap_count = robust_scm2int (me->get_property ("gap-count"), 0); Real gap_length = robust_scm2double (me->get_property ("gap"), 0.0); @@ -376,7 +372,7 @@ Beam::calc_beam_segments (SCM smob) Real stem_x = stem->relative_coordinate (commonx, X_AXIS); SCM beaming = stem->get_property ("beaming"); - do + for (LEFT_and_RIGHT (d)) { // Find the maximum and minimum beam ranks. // Given that RANKS is never reset to empty, the interval will always be @@ -415,7 +411,6 @@ Beam::calc_beam_segments (SCM smob) stem_segments[beam_rank].push_back (seg); } } - while (flip (&d) != LEFT); } Drul_array break_overshoot @@ -444,9 +439,8 @@ Beam::calc_beam_segments (SCM smob) // we are currently looking at (ie. if segs[j].dir_ == event_dir then we // are looking at that edge of the beam segment that is furthest from its // stem). - Direction event_dir = LEFT; Beam_stem_segment const &seg = segs[j]; - do + for (LEFT_and_RIGHT (event_dir)) { Beam_stem_segment const &neighbor_seg = segs[j + event_dir]; // TODO: make names clearer? --jneem @@ -542,7 +536,6 @@ Beam::calc_beam_segments (SCM smob) current = Beam_segment (); } } - while (flip (&event_dir) != LEFT); } } @@ -583,10 +576,8 @@ Beam::calc_x_positions (SCM smob) { extract_grob_set (me, "stems", stems); Grob *common_x = common_refpoint_of_array (stems, me, X_AXIS); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) x_positions[d] = me->relative_coordinate (common_x, X_AXIS); - while (flip (&d) != LEFT); } return ly_interval2scm (x_positions); } @@ -621,10 +612,8 @@ Beam::print (SCM grob) */ extract_grob_set (me, "stems", stems); Grob *commonx = common_refpoint_of_array (stems, me, X_AXIS); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) commonx = me->get_bound (d)->common_refpoint (commonx, X_AXIS); - while (flip (&d) != LEFT); vector segments = get_beam_segments (me); @@ -764,13 +753,11 @@ Beam::get_default_dir (Grob *me) for (iterof (s, stems); s != stems.end (); s++) { Interval positions = Stem::head_positions (*s); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { if (sign (positions[d]) == d) extremes[d] = d * max (d * positions[d], d * extremes[d]); } - while (flip (&d) != DOWN); } Drul_array total (0, 0); @@ -1133,13 +1120,12 @@ Beam::set_beaming (Grob *me, Beaming_pattern const *beaming) { extract_grob_set (me, "stems", stems); - Direction d = LEFT; for (vsize i = 0; i < stems.size (); i++) { /* Don't overwrite user settings. */ - do + for (LEFT_and_RIGHT (d)) { Grob *stem = stems[i]; SCM beaming_prop = stem->get_property ("beaming"); @@ -1161,7 +1147,6 @@ Beam::set_beaming (Grob *me, Beaming_pattern const *beaming) Stem::set_beaming (stem, count, d); } } - while (flip (&d) != LEFT); } } @@ -1243,10 +1228,8 @@ Beam::rest_collision_callback (SCM smob, SCM prev_offset) Drul_array pos (robust_scm2drul (beam->get_property ("positions"), Drul_array (0, 0))); - Direction dir = LEFT; - do + for (LEFT_and_RIGHT (dir)) pos[dir] += beam->relative_coordinate (common_y, Y_AXIS); - while (flip (&dir) != LEFT); Real staff_space = Staff_symbol_referencer::staff_space (rest); diff --git a/lily/bezier.cc b/lily/bezier.cc index 56e14943f8..c4cdbb1c7b 100644 --- a/lily/bezier.cc +++ b/lily/bezier.cc @@ -245,14 +245,12 @@ Bezier::minmax (Axis ax, Real l, Real r, Direction d) const // or intersections of the curve with the bounding lines at L and R. Interval lr (l, r); - Direction dir = LEFT; - do + for (LEFT_and_RIGHT (dir)) { vector v = get_other_coordinates (ax, lr[dir]); for (vsize i = v.size (); i--;) iv.add_point (v[i]); } - while (flip (&dir) != LEFT); if (iv.is_empty ()) { diff --git a/lily/break-substitution.cc b/lily/break-substitution.cc index ddaf9b4328..a0f03f753c 100644 --- a/lily/break-substitution.cc +++ b/lily/break-substitution.cc @@ -248,14 +248,12 @@ item_system_range (Item *it) return Slice (st->get_rank (), st->get_rank ()); Slice sr; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *bi = it->find_prebroken_piece (d); if (bi && bi->get_system ()) sr.add_point (bi->get_system ()->get_rank ()); } - while (flip (&d) != LEFT); return sr; } diff --git a/lily/dynamic-align-engraver.cc b/lily/dynamic-align-engraver.cc index b584e603c9..265498658a 100644 --- a/lily/dynamic-align-engraver.cc +++ b/lily/dynamic-align-engraver.cc @@ -158,8 +158,8 @@ Dynamic_align_engraver::set_spanner_bounds (Spanner *line, bool end) { if (!line) return; - Direction d = LEFT; - do + + for (LEFT_and_RIGHT (d)) { if ((d == LEFT && !line->get_bound (LEFT)) || (end && d == RIGHT && !line->get_bound (RIGHT))) @@ -181,7 +181,6 @@ Dynamic_align_engraver::set_spanner_bounds (Spanner *line, bool end) line->set_bound (d, bound); } } - while (flip (&d) != LEFT); } void diff --git a/lily/figured-bass-continuation.cc b/lily/figured-bass-continuation.cc index 6034a34641..bc216a2c4a 100644 --- a/lily/figured-bass-continuation.cc +++ b/lily/figured-bass-continuation.cc @@ -64,10 +64,10 @@ Figured_bass_continuation::print (SCM grob) * robust_scm2double (me->get_property ("thickness"), 1); Interval spanned; - Direction d = LEFT; + Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); - do + for (LEFT_and_RIGHT (d)) { Item *bound = me->get_bound (d); Direction extdir @@ -78,7 +78,6 @@ Figured_bass_continuation::print (SCM grob) = robust_relative_extent (bound, common, X_AXIS)[extdir] - me->relative_coordinate (common, X_AXIS); } - while (flip (&d) != LEFT); spanned.widen (- robust_scm2double (me->get_property ("padding"), 0.2)); Stencil extender; diff --git a/lily/hairpin.cc b/lily/hairpin.cc index 7ef0f847a1..7639ddd78e 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -69,19 +69,16 @@ Hairpin::broken_bound_padding (SCM smob) Grob *my_vertical_axis_group = Grob::get_vertical_axis_group (me); Drul_array vertical_axis_groups; - Direction d = DOWN; - do + for (DOWN_and_UP (d)) vertical_axis_groups[d] = d == dir ? sys->get_neighboring_staff (d, my_vertical_axis_group, Interval_t (me->spanned_rank_interval ())) : my_vertical_axis_group; - while (flip (&d) != DOWN); if (!vertical_axis_groups[dir]) return scm_from_double (0.0); Drul_array span_bars (0, 0); - d = DOWN; - do + for (DOWN_and_UP (d)) { extract_grob_set (vertical_axis_groups[d], "elements", elts); for (vsize i = elts.size (); i--;) @@ -98,7 +95,6 @@ Hairpin::broken_bound_padding (SCM smob) if (!span_bars[d]) return scm_from_double (0.0); } - while (flip (&d) != DOWN); if (span_bars[DOWN] != span_bars[UP]) return scm_from_double (0.0); @@ -125,13 +121,11 @@ Hairpin::print (SCM smob) Drul_array broken; Drul_array bounds; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { bounds[d] = me->get_bound (d); broken[d] = bounds[d]->break_status_dir () != CENTER; } - while (flip (&d) != LEFT); broken[RIGHT] = broken[RIGHT] && me->broken_neighbor (RIGHT); broken[RIGHT] = broken[RIGHT] && me->broken_neighbor (RIGHT)->is_live (); @@ -162,7 +156,7 @@ Hairpin::print (SCM smob) thick = robust_scm2double (me->get_property ("thickness"), 1.0) * Staff_symbol_referencer::line_thickness (me); - do + for (LEFT_and_RIGHT (d)) { Item *b = bounds[d]; Interval e = (Paper_column::has_interface (b) && b->break_status_dir ()) @@ -254,7 +248,6 @@ Hairpin::print (SCM smob) } } } - while (flip (&d) != LEFT); Real width = x_points[RIGHT] - x_points[LEFT]; diff --git a/lily/horizontal-bracket.cc b/lily/horizontal-bracket.cc index 7f3c839e91..279ee0baf2 100644 --- a/lily/horizontal-bracket.cc +++ b/lily/horizontal-bracket.cc @@ -53,8 +53,7 @@ Horizontal_bracket::make_bracket (Grob *me, = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), Drul_array (false, false)); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (connect_to_other[d]) { @@ -63,7 +62,6 @@ Horizontal_bracket::make_bracket (Grob *me, shorten[d] = 0.0; } } - while (flip (&d) != LEFT); /* ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around. @@ -113,14 +111,12 @@ Horizontal_bracket::print (SCM smob) return SCM_EOL; } - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *b = me->get_bound (d); if (b->break_status_dir ()) enclosed.push_back (b); } - while (flip (&d) != LEFT); Stencil b = make_enclosing_bracket (me, me, enclosed, X_AXIS, get_grob_direction (me)); return b.smobbed_copy (); diff --git a/lily/interval-minefield.cc b/lily/interval-minefield.cc index 7571e219ec..ffe784fae8 100644 --- a/lily/interval-minefield.cc +++ b/lily/interval-minefield.cc @@ -58,8 +58,7 @@ Interval_minefield::solve () dirty = false; for (vsize i = 0; i < forbidden_intervals_.size (); i++) { - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { Interval feasible_widened = Interval (feasible_placements_[d], feasible_placements_[d]); feasible_widened.widen (bulk_ / 2.); @@ -75,8 +74,7 @@ Interval_minefield::solve () dirty = true; } } - while (flip (&d) != DOWN); } } while (dirty); -} \ No newline at end of file +} diff --git a/lily/item.cc b/lily/item.cc index 0c3169a776..9941bc13c2 100644 --- a/lily/item.cc +++ b/lily/item.cc @@ -77,15 +77,13 @@ void Item::copy_breakable_items () { Drul_array new_copies; - Direction i = LEFT; - do + for (LEFT_and_RIGHT (d)) { Grob *dolly = clone (); Item *item = dynamic_cast (dolly); get_root_system (this)->typeset_grob (item); - new_copies[i] = item; + new_copies[d] = item; } - while (flip (&i) != LEFT); broken_to_drul_ = new_copies; } @@ -115,14 +113,12 @@ Item::find_broken_piece (System *l) const if (get_system () == l) return (Item *) (this); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Grob *s = broken_to_drul_[d]; if (s && s->get_system () == l) return s; } - while (flip (&d) != LEFT); return 0; } @@ -202,21 +198,18 @@ spanned_time_interval (Item *l, Item *r) Drul_array bounds (l, r); Interval_t iv; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (bounds[d] && bounds[d]->get_column ()) iv[d] = robust_scm2moment (bounds[d]->get_column ()->get_property ("when"), iv[d]); } - while (flip (&d) != LEFT); - do + for (LEFT_and_RIGHT (d)) { if (!bounds[d] || !bounds[d]->get_column ()) iv[d] = iv[-d]; } - while (flip (&d) != LEFT); return iv; } diff --git a/lily/ledger-line-spanner.cc b/lily/ledger-line-spanner.cc index 83304acff7..20e4b59fc3 100644 --- a/lily/ledger-line-spanner.cc +++ b/lily/ledger-line-spanner.cc @@ -227,8 +227,7 @@ Ledger_line_spanner::print (SCM smob) if (last == reqs.end ()) continue; - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { if (!staff_extent.contains (last->second[d].position_) && !staff_extent.contains (i->second[d].position_)) @@ -237,8 +236,7 @@ Ledger_line_spanner::print (SCM smob) = (last->second[d].head_extent_[RIGHT] + i->second[d].head_extent_[LEFT]) / 2; - Direction which = LEFT; - do + for (LEFT_and_RIGHT (which)) { Ledger_request &lr = ((which == LEFT) ? * last : *i).second[d]; @@ -253,10 +251,8 @@ Ledger_line_spanner::print (SCM smob) lr.ledger_extent_.at (-which) = which * max (which * lr.ledger_extent_[-which], which * limit); } - while (flip (&which) != LEFT); } } - while (flip (&d) != DOWN); } // create ledgers for note heads diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index 418a064874..2d43a71fa4 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -270,8 +270,7 @@ Line_spanner::print (SCM smob) Drul_array span_points; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Offset z (robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), bounds[d], SCM_BOOL_F), 0.0), @@ -280,7 +279,6 @@ Line_spanner::print (SCM smob) span_points[d] = z; } - while (flip (&d) != LEFT); Drul_array gaps (0, 0); Drul_array arrows (0, 0); @@ -291,7 +289,7 @@ Line_spanner::print (SCM smob) Real magstep = pow (2, robust_scm2double (me->get_property ("font-size"), 0.0) / 6); - do + for (LEFT_and_RIGHT (d)) { gaps[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("padding"), bounds[d], SCM_BOOL_F), 0.0); @@ -304,15 +302,13 @@ Line_spanner::print (SCM smob) if (!common_y[d]) common_y[d] = me; } - while (flip (&d) != LEFT); Grob *my_common_y = common_y[LEFT]->common_refpoint (common_y[RIGHT], Y_AXIS); if (!simple_y) { - do + for (LEFT_and_RIGHT (d)) span_points[d][Y_AXIS] += common_y[d]->relative_coordinate (my_common_y, Y_AXIS); - while (flip (&d) != LEFT); } Interval normalized_endpoints = robust_scm2interval (me->get_property ("normalized-endpoints"), Interval (0, 1)); @@ -329,7 +325,7 @@ Line_spanner::print (SCM smob) } Stencil line; - do + for (LEFT_and_RIGHT (d)) { span_points[d] += -d * gaps[d] * magstep * dz.direction (); @@ -350,15 +346,13 @@ Line_spanner::print (SCM smob) line.add_stencil (s); } } - while (flip (&d) != LEFT); - do + for (LEFT_and_RIGHT (d)) { if (stencils[d]) span_points[d] += dz_dir * (stencils[d]->extent (X_AXIS)[-d] / dz_dir[X_AXIS]); } - while (flip (&d) != LEFT); Offset adjust = dz.direction () * Staff_symbol_referencer::staff_space (me); diff --git a/lily/lookup.cc b/lily/lookup.cc index 4d4c0bdf6a..1acb34f783 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -333,11 +333,10 @@ Stencil Lookup::frame (Box b, Real thick, Real blot) { Stencil m; - Direction d = LEFT; for (Axis a = X_AXIS; a < NO_AXES; a = Axis (a + 1)) { Axis o = Axis ((a + 1) % NO_AXES); - do + for (LEFT_and_RIGHT (d)) { Box edges; edges[a] = b[a][d] + 0.5 * thick * Interval (-1, 1); @@ -346,7 +345,6 @@ Lookup::frame (Box b, Real thick, Real blot) m.add_stencil (round_filled_box (edges, blot)); } - while (flip (&d) != LEFT); } return m; } diff --git a/lily/lyric-hyphen.cc b/lily/lyric-hyphen.cc index 4ce2fddeb8..21ec770ea1 100644 --- a/lily/lyric-hyphen.cc +++ b/lily/lyric-hyphen.cc @@ -47,8 +47,7 @@ Lyric_hyphen::print (SCM smob) Grob *common = bounds[LEFT]->common_refpoint (bounds[RIGHT], X_AXIS); Interval span_points; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Interval iv = bounds[d]->break_status_dir () ? Axis_group_interface::generic_bound_extent (bounds[d], common, X_AXIS) @@ -58,7 +57,6 @@ Lyric_hyphen::print (SCM smob) ? bounds[d]->relative_coordinate (common, X_AXIS) : iv[-d]; } - while (flip (&d) != LEFT); Real lt = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); Real th = robust_scm2double (me->get_property ("thickness"), 1) * lt; @@ -125,14 +123,12 @@ Lyric_hyphen::set_spacing_rods (SCM smob) Spanner *sp = dynamic_cast (me); r.distance_ = robust_scm2double (me->get_property ("minimum-distance"), 0); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { r.item_drul_[d] = sp->get_bound (d); if (r.item_drul_[d]) r.distance_ += -d * r.item_drul_[d]->extent (r.item_drul_[d], X_AXIS)[-d]; } - while (flip (&d) != LEFT); if (r.item_drul_[LEFT] && r.item_drul_[RIGHT]) diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index 69865104f9..7fede1a3e7 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -127,8 +127,7 @@ Multi_measure_rest_engraver::process_music () /* Stack different scripts. */ - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { Grob *last = 0; for (vsize i = 0; i < numbers_.size (); i++) @@ -141,7 +140,6 @@ Multi_measure_rest_engraver::process_music () } } } - while (flip (&d) != DOWN); } for (vsize i = 0; i < numbers_.size (); i++) diff --git a/lily/multi-measure-rest.cc b/lily/multi-measure-rest.cc index 9ffaf4e18c..c0f26f5c85 100644 --- a/lily/multi-measure-rest.cc +++ b/lily/multi-measure-rest.cc @@ -42,8 +42,7 @@ Multi_measure_rest::bar_width (Spanner *me) { SCM spacing_pair = me->get_property ("spacing-pair"); Interval iv; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *col = me->get_bound (d)->get_column (); SCM align_sym @@ -54,7 +53,6 @@ Multi_measure_rest::bar_width (Spanner *me) iv[d] = coldim[-d]; } - while (flip (&d) != LEFT); return iv; } diff --git a/lily/new-fingering-engraver.cc b/lily/new-fingering-engraver.cc index b6275b0721..0ad31ec126 100644 --- a/lily/new-fingering-engraver.cc +++ b/lily/new-fingering-engraver.cc @@ -291,9 +291,8 @@ New_fingering_engraver::position_scripts (SCM orientations, f->set_property ("direction", scm_from_int (hordir)); } - Direction d = DOWN; Drul_array< vector > vertical (down, up); - do + for (DOWN_and_UP (d)) { for (vsize i = 0; i < vertical[d].size (); i++) { @@ -311,7 +310,6 @@ New_fingering_engraver::position_scripts (SCM orientations, f->set_property ("direction", scm_from_int (d)); } } - while (flip (&d) != DOWN); } void diff --git a/lily/note-collision.cc b/lily/note-collision.cc index 7c43dddd48..c0391f5015 100644 --- a/lily/note-collision.cc +++ b/lily/note-collision.cc @@ -360,13 +360,11 @@ check_meshing_chords (Grob *me, } } - Direction d = UP; - do + for (UP_and_DOWN (d)) { for (vsize i = 0; i < clash_groups[d].size (); i++) (*offsets)[d][i] += d * shift_amount; } - while ((flip (&d)) != UP); } MAKE_SCHEME_CALLBACK (Note_collision_interface, calc_positioning_done, 1) @@ -378,8 +376,7 @@ Note_collision_interface::calc_positioning_done (SCM smob) Drul_array > clash_groups = get_clash_groups (me); - Direction d = UP; - do + for (UP_and_DOWN (d)) { for (vsize i = clash_groups[d].size (); i--;) { @@ -389,13 +386,12 @@ Note_collision_interface::calc_positioning_done (SCM smob) clash_groups[d][i]->extent (me, X_AXIS); } } - while (flip (&d) != UP); SCM autos (automatic_shift (me, clash_groups)); SCM hand (forced_shift (me)); Real wid = 0.0; - do + for (UP_and_DOWN (d)) { if (clash_groups[d].size ()) { @@ -405,7 +401,6 @@ Note_collision_interface::calc_positioning_done (SCM smob) wid = fh->extent (h, X_AXIS).length (); } } - while (flip (&d) != UP); vector done; Real left_most = 1e6; @@ -460,13 +455,11 @@ Note_collision_interface::get_clash_groups (Grob *me) } } - Direction d = UP; - do + for (UP_and_DOWN (d)) { vector &clashes (clash_groups[d]); vector_sort (clashes, Note_column::shift_less); } - while ((flip (&d)) != UP); return clash_groups; } @@ -482,8 +475,7 @@ Note_collision_interface::automatic_shift (Grob *me, Drul_array < vector > shifts; SCM tups = SCM_EOL; - Direction d = UP; - do + for (UP_and_DOWN (d)) { vector &shift (shifts[d]); vector &clashes (clash_groups[d]); @@ -508,12 +500,10 @@ Note_collision_interface::automatic_shift (Grob *me, } } } - while ((flip (&d)) != UP); Drul_array > extents; Drul_array > offsets; - d = UP; - do + for (UP_and_DOWN (d)) { for (vsize i = 0; i < clash_groups[d].size (); i++) { @@ -524,7 +514,6 @@ Note_collision_interface::automatic_shift (Grob *me, offsets[d].push_back (d * 0.5 * i); } } - while ((flip (&d)) != UP); /* * do horizontal shifts of each direction @@ -535,7 +524,7 @@ Note_collision_interface::automatic_shift (Grob *me, * x| */ - do + for (UP_and_DOWN (d)) { for (vsize i = 1; i < clash_groups[d].size (); i++) { @@ -547,7 +536,6 @@ Note_collision_interface::automatic_shift (Grob *me, offsets[d][j] += d * 0.5; } } - while ((flip (&d)) != UP); /* see input/regression/dot-up-voice-collision.ly @@ -571,14 +559,13 @@ Note_collision_interface::automatic_shift (Grob *me, check_meshing_chords (me, &offsets, extents, clash_groups); - do + for (UP_and_DOWN (d)) { for (vsize i = 0; i < clash_groups[d].size (); i++) tups = scm_cons (scm_cons (clash_groups[d][i]->self_scm (), scm_from_double (offsets[d][i])), tups); } - while (flip (&d) != UP); return tups; } diff --git a/lily/note-spacing.cc b/lily/note-spacing.cc index 79a57bd47e..477236775d 100644 --- a/lily/note-spacing.cc +++ b/lily/note-spacing.cc @@ -222,8 +222,6 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, Interval bar_xextent; Interval bar_yextent; - Direction d = LEFT; - bool acc_right = false; Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT, @@ -232,7 +230,7 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, if (bar && dynamic_cast (bar)->get_column () == rcolumn) bar_yextent = Staff_spacing::bar_y_positions (bar); - do + for (LEFT_and_RIGHT (d)) { vector const &items (ly_scm2link_array (props [d])); for (vsize i = 0; i < items.size (); i++) @@ -280,7 +278,6 @@ Note_spacing::stem_dir_correction (Grob *me, Item *rcolumn, } } } - while (flip (&d) != LEFT); Real correction = 0.0; diff --git a/lily/optimal-page-breaking.cc b/lily/optimal-page-breaking.cc index b3d5fe1f7b..2b0910f887 100644 --- a/lily/optimal-page-breaking.cc +++ b/lily/optimal-page-breaking.cc @@ -161,8 +161,7 @@ Optimal_page_breaking::solve () } /* try a larger number of systems than the ideal line breaking number. This - is more or less C&P, but the loop bounds make it difficult to try something - like do {...} while (flip(&d) != UP). */ + is more or less C&P. */ bound = ideal_line_division; for (vsize sys_count = ideal_sys_count + 1; sys_count <= max_sys_count; sys_count++) { diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index cbe9928b6e..f70a30b404 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -56,8 +56,7 @@ Ottava_bracket::print (SCM smob) Output_def *layout = me->layout (); Drul_array broken; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *b = me->get_bound (d); broken[d] = (b->break_status_dir () != CENTER); @@ -75,7 +74,6 @@ Ottava_bracket::print (SCM smob) } } } - while (flip (&d) != LEFT); SCM properties = Font_interface::text_font_alist_chain (me); SCM markup = me->get_property ("text"); @@ -91,7 +89,7 @@ Ottava_bracket::print (SCM smob) TODO: we should check if there are ledgers, and modify length of the spanner to that. */ - do + for (LEFT_and_RIGHT (d)) { Item *b = me->get_bound (d); @@ -122,7 +120,6 @@ Ottava_bracket::print (SCM smob) else span_points[d] = ext[d]; } - while (flip (&d) != LEFT); /* 0.3 is ~ italic correction. @@ -144,13 +141,12 @@ Ottava_bracket::print (SCM smob) Drul_array flare = robust_scm2interval (me->get_property ("bracket-flare"), Interval (0, 0)); - do + for (LEFT_and_RIGHT (d)) { edge_height[d] *= -get_grob_direction (me); if (broken[d]) edge_height[d] = 0.0; } - while (flip (&d) != LEFT); Stencil b; Interval empty; diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index aafae77401..bd39702bdb 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -99,8 +99,7 @@ Ottava_spanner_engraver::typeset_all () { if (finished_) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (!finished_->get_bound (RIGHT)) { @@ -108,7 +107,6 @@ Ottava_spanner_engraver::typeset_all () finished_->set_bound (d, e); } } - while (flip (&d) != LEFT); finished_ = 0; } diff --git a/lily/paper-column.cc b/lily/paper-column.cc index a8c5e0eea8..cdf3d595ca 100644 --- a/lily/paper-column.cc +++ b/lily/paper-column.cc @@ -168,14 +168,12 @@ Paper_column::minimum_distance (Grob *left, Grob *right) Drul_array cols (left, right); Drul_array skys = Drul_array (Skyline (RIGHT), Skyline (LEFT)); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Skyline_pair *sp = Skyline_pair::unsmob (cols[d]->get_property ("horizontal-skylines")); if (sp) skys[d] = (*sp)[-d]; } - while (flip (&d) != LEFT); skys[RIGHT].merge (Separation_item::conditional_skyline (right, left)); diff --git a/lily/piano-pedal-bracket.cc b/lily/piano-pedal-bracket.cc index 4c8efd4d0f..534d5812ec 100644 --- a/lily/piano-pedal-bracket.cc +++ b/lily/piano-pedal-bracket.cc @@ -51,8 +51,7 @@ Piano_pedal_bracket::print (SCM smob) common = common->common_refpoint (textbit, X_AXIS); Interval span_points (0, 0); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *b = me->get_bound (d); broken[d] = b->break_status_dir () != CENTER; @@ -71,7 +70,6 @@ Piano_pedal_bracket::print (SCM smob) else span_points[d] = b->relative_coordinate (common, X_AXIS); } - while (flip (&d) != LEFT); /* For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____| need to shorten by the extent of the text grob diff --git a/lily/rest-collision.cc b/lily/rest-collision.cc index 4c08264687..8ba647e201 100644 --- a/lily/rest-collision.cc +++ b/lily/rest-collision.cc @@ -146,13 +146,11 @@ Rest_collision::calc_positioning_done (SCM smob) rests[d]->warning (_ ("cannot resolve rest collision: rest direction not set")); } - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) vector_sort (ordered_rests[d], rest_shift_less); - while (flip (&d) != LEFT) - ; - do + + for (LEFT_and_RIGHT (d)) { if (ordered_rests[d].size () < 1) { @@ -162,7 +160,6 @@ Rest_collision::calc_positioning_done (SCM smob) return SCM_BOOL_T; } } - while (flip (&d) != LEFT); Grob *common = common_refpoint_of_array (ordered_rests[DOWN], me, Y_AXIS); common = common_refpoint_of_array (ordered_rests[UP], common, Y_AXIS); @@ -182,7 +179,7 @@ Rest_collision::calc_positioning_done (SCM smob) 2 * int (ceil (diff))); } - do + for (LEFT_and_RIGHT (d)) { for (vsize i = ordered_rests[d].size () - 1; i-- > 0;) { @@ -194,7 +191,6 @@ Rest_collision::calc_positioning_done (SCM smob) Rest::translate (ordered_rests[d][i], d * (int) ceil (diff) * 2); } } - while (flip (&d) != LEFT); } else { diff --git a/lily/rod.cc b/lily/rod.cc index d5eaa4de3f..f7b38397c5 100644 --- a/lily/rod.cc +++ b/lily/rod.cc @@ -37,14 +37,12 @@ Rod::columnize () || !item_drul_[RIGHT]) return; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Paper_column *pc = item_drul_[d]->get_column (); distance_ += -d * item_drul_[d]->relative_coordinate (pc, X_AXIS); item_drul_[d] = pc; } - while ((flip (&d)) != LEFT); } void diff --git a/lily/script-column.cc b/lily/script-column.cc index d2655dc773..0a014a3800 100644 --- a/lily/script-column.cc +++ b/lily/script-column.cc @@ -132,8 +132,7 @@ Script_column::order_grobs (vector grobs) scripts_drul[d] = scm_cons (g->self_scm (), scripts_drul[d]); } - Direction d = DOWN; - do + for (DOWN_and_UP (d)) { SCM ss = scm_reverse_x (scripts_drul[d], SCM_EOL); ss = scm_stable_sort_x (ss, ly_grob_script_priority_less_proc); @@ -172,7 +171,6 @@ Script_column::order_grobs (vector grobs) } } } - while (flip (&d) != DOWN); } ADD_INTERFACE (Script_column, diff --git a/lily/slur-configuration.cc b/lily/slur-configuration.cc index 32597210e1..d6d231de30 100644 --- a/lily/slur-configuration.cc +++ b/lily/slur-configuration.cc @@ -93,10 +93,8 @@ fit_factor (Offset dz_unit, Offset dz_perp, Real close_to_edge_length, d * dot_product (z, dz_perp)); bool close_to_edge = false; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) close_to_edge = close_to_edge || -d * (p[X_AXIS] - curve_xext[d]) < close_to_edge_length; - while (flip (&d) != LEFT); if (close_to_edge) continue; @@ -333,11 +331,11 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) to prevent numerical inaccuracies in Bezier::get_other_coordinate (). */ - Direction d = LEFT; + bool found = false; Real y = 0.0; - do + for (LEFT_and_RIGHT (d)) { /* We need to check for the bound explicitly, since the @@ -358,7 +356,6 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) } } - while (flip (&d) != LEFT); if (!found) { @@ -396,11 +393,11 @@ Slur_configuration::score_extra_encompass (Slur_score_state const &state) void Slur_configuration::score_edges (Slur_score_state const &state) { - Direction d = LEFT; + Offset dz = attachment_[RIGHT] - attachment_[LEFT]; Real slope = dz[Y_AXIS] / dz[X_AXIS]; - do + for (LEFT_and_RIGHT (d)) { Real y = attachment_[d][Y_AXIS]; Real dy = fabs (y - state.base_attachments_[d][Y_AXIS]); @@ -419,7 +416,6 @@ Slur_configuration::score_edges (Slur_score_state const &state) string dir_str = d == LEFT ? "L" : "R"; add_score (demerit, dir_str + " edge"); } - while (flip (&d) != LEFT); } void diff --git a/lily/slur-scoring.cc b/lily/slur-scoring.cc index 543137dc48..eaadde5c58 100644 --- a/lily/slur-scoring.cc +++ b/lily/slur-scoring.cc @@ -156,10 +156,9 @@ Slur_score_state::get_bound_info () const { Drul_array extremes; - Direction d = LEFT; Direction dir = dir_; - do + for (LEFT_and_RIGHT (d)) { extremes[d].bound_ = slur_->get_bound (d); if (Note_column::has_interface (extremes[d].bound_)) @@ -203,7 +202,6 @@ Slur_score_state::get_bound_info () const } } - while (flip (&d) != LEFT); return extremes; } @@ -240,8 +238,7 @@ Slur_score_state::fill (Grob *me) common_[a] = common_refpoint_of_array (columns, me, a); common_[a] = common_refpoint_of_array (extra_objects, common_[a], a); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { /* If bound is not in note-columns, we don't want to know about @@ -250,7 +247,6 @@ Slur_score_state::fill (Grob *me) if (a != Y_AXIS) common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a); } - while (flip (&d) != LEFT); } extremes_ = get_bound_info (); @@ -287,8 +283,7 @@ Slur_score_state::fill (Grob *me) && !Clef::has_interface (extra_encompass_infos_[i].grob_) && !Time_signature::has_interface (extra_encompass_infos_[i].grob_))) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) additional_ys[d] = minmax (dir_, additional_ys[d], (dir_ @@ -298,14 +293,11 @@ Slur_score_state::fill (Grob *me) base_attachments_[RIGHT][X_AXIS], base_attachments_[LEFT][X_AXIS]) + (dir_ == LEFT ? 0 : -1))))); - while (flip (&d) != LEFT); } } - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) end_ys[d] += additional_ys[d]; - while (flip (&d) != LEFT); configurations_ = enumerate_attachments (end_ys); for (vsize i = 0; i < columns_.size (); i++) @@ -314,14 +306,13 @@ Slur_score_state::fill (Grob *me) valid_ = true; musical_dy_ = 0.0; - do + for (LEFT_and_RIGHT (d)) { if (!is_broken_ && extremes_[d].slur_head_) musical_dy_ += d * extremes_[d].slur_head_->relative_coordinate (common_[Y_AXIS], Y_AXIS); } - while (flip (&d) != LEFT); edge_has_beams_ = (extremes_[LEFT].stem_ && Stem::get_beam (extremes_[LEFT].stem_)) @@ -457,8 +448,7 @@ Drul_array Slur_score_state::get_y_attachment_range () const { Drul_array end_ys; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (extremes_[d].note_column_) { @@ -471,7 +461,6 @@ Slur_score_state::get_y_attachment_range () const else end_ys[d] = base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_; } - while (flip (&d) != LEFT); return end_ys; } @@ -480,13 +469,11 @@ bool spanner_less (Spanner *s1, Spanner *s2) { Slice b1, b2; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { b1[d] = s1->get_bound (d)->get_column ()->get_rank (); b2[d] = s2->get_bound (d)->get_column ()->get_rank (); } - while (flip (&d) != LEFT); return b2[LEFT] <= b1[LEFT] && b2[RIGHT] >= b1[RIGHT] && (b2[LEFT] != b1[LEFT] || b2[RIGHT] != b1[RIGHT]); @@ -496,8 +483,7 @@ Drul_array Slur_score_state::get_base_attachments () const { Drul_array base_attachment; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Grob *stem = extremes_[d].stem_; Grob *head = extremes_[d].slur_head_; @@ -532,9 +518,8 @@ Slur_score_state::get_base_attachments () const } base_attachment[d] = Offset (x, y); } - while (flip (&d) != LEFT); - do + for (LEFT_and_RIGHT (d)) { if (!extremes_[d].note_column_) { @@ -570,9 +555,8 @@ Slur_score_state::get_base_attachments () const base_attachment[d] = Offset (x, y); } } - while (flip (&d) != LEFT); - do + for (LEFT_and_RIGHT (d)) { for (int a = X_AXIS; a < NO_AXES; a++) { @@ -585,7 +569,6 @@ Slur_score_state::get_base_attachments () const } } } - while (flip (&d) != LEFT); return base_attachment; } @@ -687,9 +670,9 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const os[RIGHT] = base_attachments_[RIGHT]; for (int j = 0; dir_ * os[RIGHT][Y_AXIS] <= dir_ * end_ys[RIGHT]; j++) { - Direction d = LEFT; + Drul_array attach_to_stem (false, false); - do + for (LEFT_and_RIGHT (d)) { os[d][X_AXIS] = base_attachments_[d][X_AXIS]; if (extremes_[d].stem_ @@ -711,14 +694,13 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const os[d][X_AXIS] = extremes_[d].stem_extent_[X_AXIS].center (); } } - while (flip (&d) != LEFT); Offset dz; dz = os[RIGHT] - os[LEFT]; if (dz[X_AXIS] < minimum_length || fabs (dz[Y_AXIS] / dz[X_AXIS]) > parameters_.max_slope_) { - do + for (LEFT_and_RIGHT (d)) { if (extremes_[d].slur_head_ && !extremes_[d].slur_head_x_extent_.is_empty ()) @@ -727,11 +709,10 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const attach_to_stem[d] = false; } } - while (flip (&d) != LEFT); } dz = os[RIGHT] - os[LEFT]; - do + for (LEFT_and_RIGHT (d)) { if (extremes_[d].slur_head_ && !attach_to_stem[d]) @@ -745,7 +726,6 @@ Slur_score_state::enumerate_attachments (Drul_array end_ys) const * sin (dz.arg ()) / 3; } } - while (flip (&d) != LEFT); scores.push_back (Slur_configuration::new_config (os, scores.size ())); diff --git a/lily/slur.cc b/lily/slur.cc index d82633da18..a41aada7a7 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -101,10 +101,8 @@ Slur::pure_height (SCM smob, SCM start_scm, SCM end_scm) Interval d = encompasses[i]->pure_height (parent, start, end); if (!d.is_empty ()) { - Direction downup = DOWN; - do + for (DOWN_and_UP (downup)) ret.add_point (d[dir]); - while (flip (&downup) != DOWN); if (extremal_heights[LEFT] == infinity_f) extremal_heights[LEFT] = d[dir]; @@ -117,10 +115,8 @@ Slur::pure_height (SCM smob, SCM start_scm, SCM end_scm) Interval extremal_span; extremal_span.set_empty (); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) extremal_span.add_point (extremal_heights[d]); - while (flip (&d) != LEFT); ret[-dir] = minmax (dir, extremal_span[-dir], ret[-dir]); /* @@ -314,10 +310,8 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) return offset_scm; bool contains = false; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) contains |= slur_wid.contains (xext[d]); - while (flip (&d) != LEFT); if (!contains) return offset_scm; @@ -335,8 +329,7 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) Real EPS = 1.0e-5; if (avoid == ly_symbol2scm ("outside")) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Real x = minmax (-d, xext[d], curve.control_[d == LEFT ? 0 : 3][X_AXIS] + -d * EPS); Real y = curve.get_other_coordinate (X_AXIS, x); @@ -344,14 +337,12 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) if (do_shift) break; } - while (flip (&d) != LEFT); } else { for (int a = X_AXIS; a < NO_AXES; a++) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { vector coords = curve.get_other_coordinates (Axis (a), exts[a][d]); for (vsize i = 0; i < coords.size (); i++) @@ -363,7 +354,6 @@ Slur::outside_slur_callback (SCM grob, SCM offset_scm) if (do_shift) break; } - while (flip (&d) != LEFT); if (do_shift) break; } diff --git a/lily/spacing-determine-loose-columns.cc b/lily/spacing-determine-loose-columns.cc index 4fe7885259..785f01039c 100644 --- a/lily/spacing-determine-loose-columns.cc +++ b/lily/spacing-determine-loose-columns.cc @@ -134,10 +134,9 @@ Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c, Drul_array next_door, Spacing_options const *options) { - Direction d = LEFT; Drul_array dists (0, 0); - do + for (LEFT_and_RIGHT (d)) { Item *lc = dynamic_cast ((d == LEFT) ? next_door[LEFT] : c); Item *rc = dynamic_cast (d == LEFT ? c : next_door[RIGHT]); @@ -171,7 +170,6 @@ Spacing_spanner::set_distances_for_loose_col (Grob *me, Grob *c, programming_error ("Subversive spacing wish"); } } - while (flip (&d) != LEFT); Rod r; r.distance_ = dists[LEFT] + dists[RIGHT]; diff --git a/lily/spacing-interface.cc b/lily/spacing-interface.cc index 82eb11ef5f..27c99bb159 100644 --- a/lily/spacing-interface.cc +++ b/lily/spacing-interface.cc @@ -55,8 +55,7 @@ Spacing_interface::skylines (Grob *me, Grob *right_col) Drul_array columns (left_col, right_col); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { for (vsize i = 0; i < items[d].size (); i++) { @@ -88,7 +87,6 @@ Spacing_interface::skylines (Grob *me, Grob *right_col) } } } - while (flip (&d) != LEFT); return skylines; } diff --git a/lily/spacing-spanner.cc b/lily/spacing-spanner.cc index 1af0ba3720..657ff0cd6a 100644 --- a/lily/spacing-spanner.cc +++ b/lily/spacing-spanner.cc @@ -261,8 +261,7 @@ set_column_rods (vector const &cols, Real padding) Real left_stickout = skys ? (*skys)[RIGHT].max_height () : 0.0; bool done = true; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (j < i - 1) cur_dist[d] += distances[j]; @@ -287,8 +286,10 @@ set_column_rods (vector const &cols, Real padding) cur_dist[d] = max (cur_dist[d], dist); done = done && !touches; + + if (!rb) + break; } - while (flip (&d) != LEFT && rb); /* we need the empty check for gregorian notation, where there are a lot of extraneous paper-columns that we need to skip over */ diff --git a/lily/spanner.cc b/lily/spanner.cc index 92cb9cdf14..9a8ff83a3f 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -50,8 +50,7 @@ Spanner::do_break_processing () /* If we have a spanner spanning one column, we must break it anyway because it might provide a parent for another item. */ - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *bound = left->find_prebroken_piece (d); if (!bound) @@ -67,7 +66,6 @@ Spanner::do_break_processing () broken_intos_.push_back (span); } } - while ((flip (&d)) != LEFT); } else { @@ -95,13 +93,11 @@ Spanner::do_break_processing () Drul_array bounds; bounds[LEFT] = break_points[i - 1]; bounds[RIGHT] = break_points[i]; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (!bounds[d]->get_system ()) bounds[d] = bounds[d]->find_prebroken_piece (- d); } - while ((flip (&d)) != LEFT); if (!bounds[LEFT] || ! bounds[RIGHT]) { @@ -151,13 +147,11 @@ Spanner::get_break_index () const void Spanner::set_my_columns () { - Direction i = (Direction) LEFT; - do + for (LEFT_and_RIGHT (d)) { - if (!spanned_drul_[i]->get_system ()) - set_bound (i, spanned_drul_[i]->find_prebroken_piece ((Direction) - i)); + if (!spanned_drul_[d]->get_system ()) + set_bound (d, spanned_drul_[d]->find_prebroken_piece ((Direction) - d)); } - while (flip (&i) != LEFT); } Interval_t @@ -256,19 +250,15 @@ Spanner::spanner_length () const Drul_array bounds (get_property ("left-bound-info"), get_property ("right-bound-info")); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) lr[d] = robust_scm2double (ly_assoc_get (ly_symbol2scm ("X"), bounds[d], SCM_BOOL_F), -d); - while (flip (&d) != LEFT); } if (lr.is_empty ()) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) lr[d] = spanned_drul_[d]->relative_coordinate (0, X_AXIS); - while (flip (&d) != LEFT); } if (lr.is_empty ()) @@ -360,11 +350,9 @@ Spanner::derived_mark () const { scm_gc_mark (pure_property_cache_); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) if (spanned_drul_[d]) scm_gc_mark (spanned_drul_[d]->self_scm ()); - while (flip (&d) != LEFT) ; for (vsize i = broken_intos_.size (); i--;) diff --git a/lily/staff-symbol.cc b/lily/staff-symbol.cc index 98627e5783..3b0eef00b5 100644 --- a/lily/staff-symbol.cc +++ b/lily/staff-symbol.cc @@ -50,8 +50,7 @@ Staff_symbol::print (SCM smob) Real t = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness")); t *= robust_scm2double (me->get_property ("thickness"), 1.0); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { SCM width_scm = me->get_property ("width"); if (d == RIGHT && scm_is_number (width_scm)) @@ -75,7 +74,6 @@ Staff_symbol::print (SCM smob) span_points[d] -= d * t / 2; } - while (flip (&d) != LEFT); Stencil m; diff --git a/lily/stem.cc b/lily/stem.cc index 47e6797125..4b5a68510b 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -225,8 +225,7 @@ Stem::extremal_heads (Grob *me) Grob *n = heads[i]; int p = Staff_symbol_referencer::get_rounded_position (n); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (d * p > d * extpos[d]) { @@ -234,7 +233,6 @@ Stem::extremal_heads (Grob *me) extpos[d] = p; } } - while (flip (&d) != DOWN); } return exthead; } @@ -319,10 +317,8 @@ Stem::internal_pure_height (Grob *me, bool calc_beam) { Interval overshoot; Direction dir = get_grob_direction (me); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) overshoot[d] = d == dir ? dir * infinity_f : iv[d]; - while (flip (&d) != DOWN); vector heights; vector my_stems; @@ -370,10 +366,8 @@ Stem::cache_pure_height (Grob *me, Interval iv, Interval my_iv) { Interval overshoot; Direction dir = get_grob_direction (me); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) overshoot[d] = d == dir ? dir * infinity_f : my_iv[d]; - while (flip (&d) != DOWN); iv.intersect (overshoot); dynamic_cast (me)->cache_pure_height (iv); diff --git a/lily/system-start-delimiter.cc b/lily/system-start-delimiter.cc index 7208a2622b..d4b523c06c 100644 --- a/lily/system-start-delimiter.cc +++ b/lily/system-start-delimiter.cc @@ -47,10 +47,8 @@ System_start_delimiter::staff_bracket (Grob *me, Real height) * (height / 2 + overlap)); Stencil bracket = Lookup::filled_box (box); - Direction d = DOWN; - do + for (DOWN_and_UP (d)) bracket.add_at_edge (Y_AXIS, d, tips[d], -overlap); - while (flip (&d) != DOWN); bracket = Stencil (box, bracket.expr ()); bracket.translate_axis (-0.8, X_AXIS); diff --git a/lily/system.cc b/lily/system.cc index f58f1158d4..fdcc2b133d 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -874,14 +874,12 @@ System::calc_pure_relevant_grobs (SCM smob) if (Item *it = dynamic_cast (elts[i])) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Item *piece = it->find_prebroken_piece (d); if (piece && to_boolean (scm_apply_1 (pure_relevant_p, piece->self_scm (), SCM_EOL))) relevant_grobs.push_back (piece); } - while (flip (&d) != LEFT); } } } diff --git a/lily/tie-column.cc b/lily/tie-column.cc index 62edbf6890..bc14eb9bdf 100644 --- a/lily/tie-column.cc +++ b/lily/tie-column.cc @@ -67,14 +67,12 @@ Tie_column::before_line_breaking (SCM smob) for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s)) { Spanner *tie = dynamic_cast (unsmob_grob (scm_car (s))); - Direction dir = LEFT; - do + for (LEFT_and_RIGHT (dir)) { if (dir * tie->get_bound (dir)->get_column ()->get_rank () > dir * me->get_bound (dir)->get_column ()->get_rank ()) me->set_bound (dir, Tie::head (tie, dir)); } - while (flip (&dir) != LEFT); } return SCM_UNSPECIFIED; diff --git a/lily/tie-engraver.cc b/lily/tie-engraver.cc index 6734003dc1..40da0d3e84 100644 --- a/lily/tie-engraver.cc +++ b/lily/tie-engraver.cc @@ -347,16 +347,14 @@ Tie_engraver::typeset_tie (Grob *her) if (! (Tie::head (her, LEFT) && Tie::head (her, RIGHT))) warning (_ ("lonely tie")); - Direction d = LEFT; Drul_array new_head_drul; new_head_drul[LEFT] = Tie::head (her, LEFT); new_head_drul[RIGHT] = Tie::head (her, RIGHT); - do + for (LEFT_and_RIGHT (d)) { if (!Tie::head (her, d)) new_head_drul[d] = Tie::head (her, (Direction) - d); } - while (flip (&d) != LEFT); Spanner *sp = dynamic_cast (her); sp->set_bound (LEFT, new_head_drul[LEFT]); diff --git a/lily/tie-formatting-problem.cc b/lily/tie-formatting-problem.cc index c4e8a22eb9..d93df73abf 100644 --- a/lily/tie-formatting-problem.cc +++ b/lily/tie-formatting-problem.cc @@ -56,8 +56,8 @@ Interval Tie_formatting_problem::get_attachment (Real y, Drul_array columns) const { Interval attachments (0, 0); - Direction d = LEFT; - do + + for (LEFT_and_RIGHT (d)) { Tuple2 key (columns[d], int (d)); Chord_outline_map::const_iterator i (chord_outlines_.find (key)); @@ -66,7 +66,6 @@ Tie_formatting_problem::get_attachment (Real y, Drul_array columns) const else attachments[d] = i->second.height (y); } - while (flip (&d) != LEFT); return attachments; } @@ -227,8 +226,7 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, } - Direction updowndir = DOWN; - do + for (DOWN_and_UP (updowndir)) { Interval x; Interval y; @@ -244,7 +242,6 @@ Tie_formatting_problem::set_column_chord_outline (vector bounds, if (!x.is_empty ()) boxes.push_back (Box (x, y)); } - while (flip (&updowndir) != DOWN); /* todo: the horizon_padding is somewhat arbitrary */ chord_outlines_[key] = Skyline (boxes, details_.skyline_padding_, Y_AXIS, -dir); @@ -340,8 +337,7 @@ Tie_formatting_problem::from_ties (vector const &ties) details_.from_grob (ties[0]); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { vector bounds; @@ -356,19 +352,17 @@ Tie_formatting_problem::from_ties (vector const &ties) set_chord_outline (bounds, d); } - while (flip (&d) != LEFT); for (vsize i = 0; i < ties.size (); i++) { Tie_specification spec; spec.from_grob (ties[i]); - do + for (LEFT_and_RIGHT (d)) { spec.note_head_drul_[d] = Tie::head (ties[i], d); spec.column_ranks_[d] = Tie::get_column_rank (ties[i], d); } - while (flip (&d) != LEFT); specifications_.push_back (spec); } } @@ -565,8 +559,7 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir, It would be better to check D against HEAD-DIRECTION if applicable. */ - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Real y = conf->position_ * details_.staff_space_ * 0.5 + conf->delta_y_; if (get_stem_extent (conf->column_ranks_[d], d, X_AXIS).is_empty () @@ -577,7 +570,6 @@ Tie_formatting_problem::generate_configuration (int pos, Direction dir, = d * min (d * conf->attachment_x_[d], d * (get_stem_extent (conf->column_ranks_[d], d, X_AXIS)[-d] - d * details_.stem_gap_)); } - while (flip (&d) != LEFT); } return conf; } @@ -631,8 +623,7 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf, penalty += p; } - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (!spec.note_head_drul_[d]) continue; @@ -652,14 +643,12 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf, penalty += p; } - while (flip (&d) != LEFT); if (ties_conf && ties_conf->size () == 1) { - Direction d = LEFT; Drul_array stems (0, 0); - do + for (LEFT_and_RIGHT (d)) { if (!spec.note_head_drul_[d]) continue; @@ -669,7 +658,6 @@ Tie_formatting_problem::score_aptitude (Tie_configuration *conf, && Stem::is_normal_stem (stem)) stems[d] = stem; } - while (flip (&d) != LEFT); bool tie_stem_dir_ok = true; bool tie_position_dir_ok = true; @@ -1038,11 +1026,10 @@ vector Tie_formatting_problem::generate_extremal_tie_variations (Ties_configuration const &ties) const { vector vars; - Direction d = DOWN; for (int i = 1; i <= details_.multi_tie_region_size_; i++) { Drul_array configs (0, 0); - do + for (DOWN_and_UP (d)) { const Tie_configuration &config = boundary (ties, d, 0); if (config.dir_ == d @@ -1057,7 +1044,6 @@ Tie_formatting_problem::generate_extremal_tie_variations (Ties_configuration con vars.push_back (var); } } - while (flip (&d) != DOWN); if (configs[LEFT] && configs[RIGHT]) { Tie_configuration_variation var; @@ -1080,8 +1066,7 @@ Tie_formatting_problem::generate_single_tie_variations (Ties_configuration const sz = 1; for (int i = 0; i < sz; i++) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (i == 0 && ties[0].dir_ == d) @@ -1100,7 +1085,6 @@ Tie_formatting_problem::generate_single_tie_variations (Ties_configuration const vars.push_back (var); } } - while (flip (&d) != LEFT); } return vars; } diff --git a/lily/tie.cc b/lily/tie.cc index 84dfa29a82..aaac5fbbd4 100644 --- a/lily/tie.cc +++ b/lily/tie.cc @@ -92,14 +92,12 @@ Tie::get_column_rank (Grob *me, Direction d) int Tie::get_position (Grob *me) { - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Grob *h = head (me, d); if (h) return (int) rint (Staff_symbol_referencer::get_position (h)); } - while (flip (&d) != LEFT); /* TODO: this is theoretically possible for ties across more than 2 @@ -125,8 +123,7 @@ Direction Tie::get_default_dir (Grob *me) { Drul_array stems; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Grob *one_head = head (me, d); if (!one_head && dynamic_cast (me)) @@ -138,7 +135,6 @@ Tie::get_default_dir (Grob *me) stems[d] = stem; } - while (flip (&d) != LEFT); if (stems[LEFT] && stems[RIGHT]) { diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index ba0ef6e236..37099683bf 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -106,10 +106,8 @@ Tuplet_bracket::parallel_beam (Grob *me_grob, vector const &cols, return 0; Drul_array beams; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) beams[d] = stems[d] ? Stem::get_beam (stems[d]) : 0; - while (flip (&d) != LEFT); *equally_long = false; if (! (beams[LEFT] && (beams[LEFT] == beams[RIGHT]) && !me->is_broken ())) @@ -140,8 +138,7 @@ Tuplet_bracket::calc_connect_to_neighbors (SCM smob) get_x_bound_item (me, RIGHT, dir)); Drul_array connect_to_other (false, false); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { Direction break_dir = bounds[d]->break_status_dir (); Spanner *orig_spanner = dynamic_cast (me->original ()); @@ -161,7 +158,6 @@ Tuplet_bracket::calc_connect_to_neighbors (SCM smob) && neighbor_idx < orig_spanner->broken_intos_.size () && orig_spanner->broken_intos_[neighbor_idx]->is_live ()); } - while (flip (&d) != LEFT); if (connect_to_other[LEFT] || connect_to_other[RIGHT]) return scm_cons (scm_from_bool (connect_to_other[LEFT]), @@ -201,8 +197,7 @@ Tuplet_bracket::calc_x_positions (SCM smob) Drul_array (false, false)); Interval x_span; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { x_span[d] = bounds[d]->break_status_dir () ? Axis_group_interface::generic_bound_extent (bounds[d], commonx, X_AXIS)[d] @@ -245,7 +240,6 @@ Tuplet_bracket::calc_x_positions (SCM smob) x_span[d] = coord - padding; } } - while (flip (&d) != LEFT); return ly_interval2scm (x_span - me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS)); } @@ -303,10 +297,8 @@ Tuplet_bracket::print (SCM smob) Interval positions = robust_scm2interval (scm_positions, Interval (0.0, 0.0)); Drul_array points; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) points[d] = Offset (x_span[d], positions[d]); - while (flip (&d) != LEFT); Output_def *pap = me->layout (); @@ -351,8 +343,7 @@ Tuplet_bracket::print (SCM smob) = robust_scm2booldrul (me->get_property ("connect-to-neighbor"), Drul_array (false, false)); - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) { if (connect_to_other[d]) { @@ -380,7 +371,6 @@ Tuplet_bracket::print (SCM smob) } } } - while (flip (&d) != LEFT); Stencil brack = make_bracket (me, Y_AXIS, points[RIGHT] - points[LEFT], @@ -392,12 +382,11 @@ Tuplet_bracket::print (SCM smob) Interval (-0.5, 0.5) * gap + 0.1, flare, shorten); - do + for (LEFT_and_RIGHT (d)) { if (!edge_stencils[d].is_empty ()) brack.add_stencil (edge_stencils[d]); } - while (flip (&d) != LEFT); mol.add_stencil (brack); } @@ -430,29 +419,25 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. Drul_array straight_corners = corners; - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) straight_corners[d] += -d * shorten[d] / length * dz; - while (flip (&d) != LEFT); if (!gap.is_empty ()) { - do + for (LEFT_and_RIGHT (d)) gap_corners[d] = (dz * 0.5) + gap[d] / length * dz; - while (flip (&d) != LEFT); } Drul_array flare_corners = straight_corners; - do + for (LEFT_and_RIGHT (d)) { flare_corners[d][bracket_axis] = straight_corners[d][bracket_axis]; flare_corners[d][protrusion_axis] += height[d]; straight_corners[d][bracket_axis] += -d * flare[d]; } - while (flip (&d) != LEFT); Stencil m; - do + for (LEFT_and_RIGHT (d)) { if (!gap.is_empty ()) m.add_stencil (Line_interface::line (me, straight_corners[d], @@ -462,8 +447,6 @@ Tuplet_bracket::make_bracket (Grob *me, // for line properties. flare_corners[d])); } - while (flip (&d) != LEFT); - if (gap.is_empty ()) m.add_stencil (Line_interface::line (me, straight_corners[LEFT], straight_corners[RIGHT])); @@ -551,8 +534,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) Note_column::get_stem (columns.back ())); Interval poss; - Direction side = LEFT; - do + for (LEFT_and_RIGHT (side)) { // Trigger setting of stem lengths if necessary. if (Grob *beam = Stem::get_beam (stems[side])) @@ -560,7 +542,6 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) poss[side] = stems[side]->extent (stems[side], Y_AXIS)[get_grob_direction (stems[side])] + stems[side]->get_parent (Y_AXIS)->relative_coordinate (commony, Y_AXIS); } - while (flip (&side) != LEFT); *dy = poss[RIGHT] - poss[LEFT]; points.push_back (Offset (stems[LEFT]->relative_coordinate (commonx, X_AXIS) - x0, poss[LEFT])); @@ -630,14 +611,13 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) if (!tuplets[i]->is_live ()) continue; - Direction d = LEFT; Drul_array positions = robust_scm2interval (tuplets[i]->get_property ("positions"), Interval (0, 0)); Real other_dy = positions[RIGHT] - positions[LEFT]; - do + for (LEFT_and_RIGHT (d)) { Real y = tuplet_y.linear_combination (d * sign (other_dy)); @@ -650,7 +630,7 @@ Tuplet_bracket::calc_position_and_height (Grob *me_grob, Real *offset, Real *dy) points.push_back (Offset (tuplet_x[d] - x0, y)); } - while (flip (&d) != LEFT); + // Check for number-on-bracket collisions Grob *number = unsmob_grob (tuplets[i]->get_object ("tuplet-number")); if (number) @@ -779,10 +759,8 @@ Tuplet_bracket::get_default_dir (Grob *me) Direction d = Note_column::dir (columns[i]); extremal_positions[d] = minmax (d, 1.0 * Note_column::head_positions_interval (columns[i])[d], extremal_positions[d]); } - Direction d = LEFT; - do + for (LEFT_and_RIGHT (d)) extremal_positions[d] = -d * (staff_extent[d] - extremal_positions[d]); - while (flip (&d) != LEFT); return extremal_positions[UP] <= extremal_positions[DOWN] ? UP : DOWN; } -- 2.39.2