Replaces do{ ... } while(flip (&d) != DOWN/UP/... with a macro for(DOWN_and_UP/UP_and_DOWN/....) { }
Signed-off-by: David Kastrup <dak@gnu.org>
return other_dir (d);
}
-// huh?
+// to be deleted soon (after coping with issues 2491 and 2493
inline Direction
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
{
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);
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_);
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 ());
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 ();
}
if (Item *it = dynamic_cast<Item *> (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);
}
}
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
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"),
// 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])
+ (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);
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))
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);
// 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 ())
{
Interval (unshifted_quants[i],
unshifted_quants[j]));
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
if (!quant_range_[d].contains (c->y[d]))
{
break;
}
}
- while (flip (&d) != LEFT);
if (c)
scores->push_back (c);
}
}
/* 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
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++)
{
}
}
}
- while ((flip (&d)) != LEFT);
if (max (edge_beam_counts_[LEFT], edge_beam_counts_[RIGHT]) >= 2)
{
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)
dem += extra_demerit;
}
}
- while (flip (&d) != LEFT);
}
config->add (dem, "F");
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);
scm_set_car_x (s, scm_from_int (new_beam_pos));
}
}
- while (flip (&d) != LEFT);
if (!new_slice.is_empty ())
last_int = new_slice;
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);
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
stem_segments[beam_rank].push_back (seg);
}
}
- while (flip (&d) != LEFT);
}
Drul_array<Real> break_overshoot
// 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
current = Beam_segment ();
}
}
- while (flip (&event_dir) != LEFT);
}
}
{
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);
}
*/
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<Beam_segment> segments = get_beam_segments (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<int> total (0, 0);
{
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");
Stem::set_beaming (stem, count, d);
}
}
- while (flip (&d) != LEFT);
}
}
Drul_array<Real> pos (robust_scm2drul (beam->get_property ("positions"),
Drul_array<Real> (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);
// 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<Real> 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 ())
{
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;
}
{
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)))
line->set_bound (d, bound);
}
}
- while (flip (&d) != LEFT);
}
void
* 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
= 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;
Grob *my_vertical_axis_group = Grob::get_vertical_axis_group (me);
Drul_array<Grob *> 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<int> (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<Grob *> 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--;)
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);
Drul_array<bool> broken;
Drul_array<Item *> 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 ();
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 ())
}
}
}
- while (flip (&d) != LEFT);
Real width = x_points[RIGHT] - x_points[LEFT];
= robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
Drul_array<bool> (false, false));
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
if (connect_to_other[d])
{
shorten[d] = 0.0;
}
}
- while (flip (&d) != LEFT);
/*
ugh, Tuplet_bracket should use Horizontal_bracket, not the other way around.
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 ();
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.);
dirty = true;
}
}
- while (flip (&d) != DOWN);
}
}
while (dirty);
-}
\ No newline at end of file
+}
Item::copy_breakable_items ()
{
Drul_array<Item *> new_copies;
- Direction i = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
Grob *dolly = clone ();
Item *item = dynamic_cast<Item *> (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;
}
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;
}
Drul_array<Item *> bounds (l, r);
Interval_t<Moment> 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;
}
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_))
= (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];
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
Drul_array<Offset> 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),
span_points[d] = z;
}
- while (flip (&d) != LEFT);
Drul_array<Real> gaps (0, 0);
Drul_array<bool> arrows (0, 0);
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);
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));
}
Stencil line;
- do
+ for (LEFT_and_RIGHT (d))
{
span_points[d] += -d * gaps[d] * magstep * dz.direction ();
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);
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);
m.add_stencil (round_filled_box (edges, blot));
}
- while (flip (&d) != LEFT);
}
return m;
}
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)
? 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;
Spanner *sp = dynamic_cast<Spanner *> (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])
/*
Stack different scripts.
*/
- Direction d = DOWN;
- do
+ for (DOWN_and_UP (d))
{
Grob *last = 0;
for (vsize i = 0; i < numbers_.size (); i++)
}
}
}
- while (flip (&d) != DOWN);
}
for (vsize i = 0; i < numbers_.size (); i++)
{
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
iv[d] = coldim[-d];
}
- while (flip (&d) != LEFT);
return iv;
}
f->set_property ("direction", scm_from_int (hordir));
}
- Direction d = DOWN;
Drul_array< vector<Finger_tuple> > vertical (down, up);
- do
+ for (DOWN_and_UP (d))
{
for (vsize i = 0; i < vertical[d].size (); i++)
{
f->set_property ("direction", scm_from_int (d));
}
}
- while (flip (&d) != DOWN);
}
void
}
}
- 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)
Drul_array<vector<Grob *> > clash_groups = get_clash_groups (me);
- Direction d = UP;
- do
+ for (UP_and_DOWN (d))
{
for (vsize i = clash_groups[d].size (); i--;)
{
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 ())
{
wid = fh->extent (h, X_AXIS).length ();
}
}
- while (flip (&d) != UP);
vector<Grob *> done;
Real left_most = 1e6;
}
}
- Direction d = UP;
- do
+ for (UP_and_DOWN (d))
{
vector<Grob *> &clashes (clash_groups[d]);
vector_sort (clashes, Note_column::shift_less);
}
- while ((flip (&d)) != UP);
return clash_groups;
}
Drul_array < vector<int> > shifts;
SCM tups = SCM_EOL;
- Direction d = UP;
- do
+ for (UP_and_DOWN (d))
{
vector<int> &shift (shifts[d]);
vector<Grob *> &clashes (clash_groups[d]);
}
}
}
- while ((flip (&d)) != UP);
Drul_array<vector<Slice> > extents;
Drul_array<vector<Real> > offsets;
- d = UP;
- do
+ for (UP_and_DOWN (d))
{
for (vsize i = 0; i < clash_groups[d].size (); i++)
{
offsets[d].push_back (d * 0.5 * i);
}
}
- while ((flip (&d)) != UP);
/*
* do horizontal shifts of each direction
* x|
*/
- do
+ for (UP_and_DOWN (d))
{
for (vsize i = 1; i < clash_groups[d].size (); i++)
{
offsets[d][j] += d * 0.5;
}
}
- while ((flip (&d)) != UP);
/*
see input/regression/dot-up-voice-collision.ly
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;
}
Interval bar_xextent;
Interval bar_yextent;
- Direction d = LEFT;
-
bool acc_right = false;
Grob *bar = Spacing_interface::extremal_break_aligned_grob (me, RIGHT,
if (bar && dynamic_cast<Item *> (bar)->get_column () == rcolumn)
bar_yextent = Staff_spacing::bar_y_positions (bar);
- do
+ for (LEFT_and_RIGHT (d))
{
vector<Grob *> const &items (ly_scm2link_array (props [d]));
for (vsize i = 0; i < items.size (); i++)
}
}
}
- while (flip (&d) != LEFT);
Real correction = 0.0;
}
/* 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++)
{
Output_def *layout = me->layout ();
Drul_array<bool> broken;
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
Item *b = me->get_bound (d);
broken[d] = (b->break_status_dir () != CENTER);
}
}
}
- while (flip (&d) != LEFT);
SCM properties = Font_interface::text_font_alist_chain (me);
SCM markup = me->get_property ("text");
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);
else
span_points[d] = ext[d];
}
- while (flip (&d) != LEFT);
/*
0.3 is ~ italic correction.
Drul_array<Real> 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;
{
if (finished_)
{
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
if (!finished_->get_bound (RIGHT))
{
finished_->set_bound (d, e);
}
}
- while (flip (&d) != LEFT);
finished_ = 0;
}
Drul_array<Grob *> cols (left, right);
Drul_array<Skyline> skys = Drul_array<Skyline> (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));
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;
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
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)
{
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);
2 * int (ceil (diff)));
}
- do
+ for (LEFT_and_RIGHT (d))
{
for (vsize i = ordered_rests[d].size () - 1; i-- > 0;)
{
Rest::translate (ordered_rests[d][i], d * (int) ceil (diff) * 2);
}
}
- while (flip (&d) != LEFT);
}
else
{
|| !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
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);
}
}
}
- while (flip (&d) != DOWN);
}
ADD_INTERFACE (Script_column,
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;
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
}
}
- while (flip (&d) != LEFT);
if (!found)
{
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]);
string dir_str = d == LEFT ? "L" : "R";
add_score (demerit, dir_str + " edge");
}
- while (flip (&d) != LEFT);
}
void
{
Drul_array<Bound_info> 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_))
}
}
- while (flip (&d) != LEFT);
return extremes;
}
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
if (a != Y_AXIS)
common_[a] = common_[a]->common_refpoint (sp->get_bound (d), a);
}
- while (flip (&d) != LEFT);
}
extremes_ = get_bound_info ();
&& !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_
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++)
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_))
Slur_score_state::get_y_attachment_range () const
{
Drul_array<Real> end_ys;
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
if (extremes_[d].note_column_)
{
else
end_ys[d] = base_attachments_[d][Y_AXIS] + parameters_.region_size_ * dir_;
}
- while (flip (&d) != LEFT);
return end_ys;
}
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]);
Slur_score_state::get_base_attachments () const
{
Drul_array<Offset> base_attachment;
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
Grob *stem = extremes_[d].stem_;
Grob *head = extremes_[d].slur_head_;
}
base_attachment[d] = Offset (x, y);
}
- while (flip (&d) != LEFT);
- do
+ for (LEFT_and_RIGHT (d))
{
if (!extremes_[d].note_column_)
{
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++)
{
}
}
}
- while (flip (&d) != LEFT);
return base_attachment;
}
os[RIGHT] = base_attachments_[RIGHT];
for (int j = 0; dir_ * os[RIGHT][Y_AXIS] <= dir_ * end_ys[RIGHT]; j++)
{
- Direction d = LEFT;
+
Drul_array<bool> attach_to_stem (false, false);
- do
+ for (LEFT_and_RIGHT (d))
{
os[d][X_AXIS] = base_attachments_[d][X_AXIS];
if (extremes_[d].stem_
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 ())
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])
* sin (dz.arg ()) / 3;
}
}
- while (flip (&d) != LEFT);
scores.push_back (Slur_configuration::new_config (os, scores.size ()));
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];
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]);
/*
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;
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);
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<Real> coords = curve.get_other_coordinates (Axis (a), exts[a][d]);
for (vsize i = 0; i < coords.size (); i++)
if (do_shift)
break;
}
- while (flip (&d) != LEFT);
if (do_shift)
break;
}
Drul_array<Item *> next_door,
Spacing_options const *options)
{
- Direction d = LEFT;
Drul_array<Real> dists (0, 0);
- do
+ for (LEFT_and_RIGHT (d))
{
Item *lc = dynamic_cast<Item *> ((d == LEFT) ? next_door[LEFT] : c);
Item *rc = dynamic_cast<Item *> (d == LEFT ? c : next_door[RIGHT]);
programming_error ("Subversive spacing wish");
}
}
- while (flip (&d) != LEFT);
Rod r;
r.distance_ = dists[LEFT] + dists[RIGHT];
Drul_array<Grob *> columns (left_col, right_col);
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
for (vsize i = 0; i < items[d].size (); i++)
{
}
}
}
- while (flip (&d) != LEFT);
return skylines;
}
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];
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 */
/*
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)
broken_intos_.push_back (span);
}
}
- while ((flip (&d)) != LEFT);
}
else
{
Drul_array<Item *> 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])
{
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<int>
Drul_array<SCM> 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 ())
{
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--;)
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))
span_points[d] -= d * t / 2;
}
- while (flip (&d) != LEFT);
Stencil m;
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])
{
extpos[d] = p;
}
}
- while (flip (&d) != DOWN);
}
return exthead;
}
{
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<Interval> heights;
vector<Grob *> my_stems;
{
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<Item *> (me)->cache_pure_height (iv);
* (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);
if (Item *it = dynamic_cast<Item *> (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);
}
}
}
for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
{
Spanner *tie = dynamic_cast<Spanner *> (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;
if (! (Tie::head (her, LEFT) && Tie::head (her, RIGHT)))
warning (_ ("lonely tie"));
- Direction d = LEFT;
Drul_array<Grob *> 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<Spanner *> (her);
sp->set_bound (LEFT, new_head_drul[LEFT]);
Tie_formatting_problem::get_attachment (Real y, Drul_array<int> columns) const
{
Interval attachments (0, 0);
- Direction d = LEFT;
- do
+
+ for (LEFT_and_RIGHT (d))
{
Tuple2<int> key (columns[d], int (d));
Chord_outline_map::const_iterator i (chord_outlines_.find (key));
else
attachments[d] = i->second.height (y);
}
- while (flip (&d) != LEFT);
return attachments;
}
}
- Direction updowndir = DOWN;
- do
+ for (DOWN_and_UP (updowndir))
{
Interval x;
Interval y;
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);
details_.from_grob (ties[0]);
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
vector<Item *> bounds;
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);
}
}
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 ()
= 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;
}
penalty += p;
}
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
if (!spec.note_head_drul_[d])
continue;
penalty += p;
}
- while (flip (&d) != LEFT);
if (ties_conf
&& ties_conf->size () == 1)
{
- Direction d = LEFT;
Drul_array<Grob *> stems (0, 0);
- do
+ for (LEFT_and_RIGHT (d))
{
if (!spec.note_head_drul_[d])
continue;
&& Stem::is_normal_stem (stem))
stems[d] = stem;
}
- while (flip (&d) != LEFT);
bool tie_stem_dir_ok = true;
bool tie_position_dir_ok = true;
Tie_formatting_problem::generate_extremal_tie_variations (Ties_configuration const &ties) const
{
vector<Tie_configuration_variation> vars;
- Direction d = DOWN;
for (int i = 1; i <= details_.multi_tie_region_size_; i++)
{
Drul_array<Tie_configuration *> configs (0, 0);
- do
+ for (DOWN_and_UP (d))
{
const Tie_configuration &config = boundary (ties, d, 0);
if (config.dir_ == d
vars.push_back (var);
}
}
- while (flip (&d) != DOWN);
if (configs[LEFT] && configs[RIGHT])
{
Tie_configuration_variation var;
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)
vars.push_back (var);
}
}
- while (flip (&d) != LEFT);
}
return vars;
}
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
Tie::get_default_dir (Grob *me)
{
Drul_array<Grob *> stems;
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
Grob *one_head = head (me, d);
if (!one_head && dynamic_cast<Spanner *> (me))
stems[d] = stem;
}
- while (flip (&d) != LEFT);
if (stems[LEFT] && stems[RIGHT])
{
return 0;
Drul_array<Grob *> 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 ()))
get_x_bound_item (me, RIGHT, dir));
Drul_array<bool> 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<Spanner *> (me->original ());
&& 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]),
Drul_array<bool> (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]
x_span[d] = coord - padding;
}
}
- while (flip (&d) != LEFT);
return ly_interval2scm (x_span - me->get_bound (LEFT)->relative_coordinate (commonx, X_AXIS));
}
Interval positions = robust_scm2interval (scm_positions, Interval (0.0, 0.0));
Drul_array<Offset> 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 ();
= robust_scm2booldrul (me->get_property ("connect-to-neighbor"),
Drul_array<bool> (false, false));
- Direction d = LEFT;
- do
+ for (LEFT_and_RIGHT (d))
{
if (connect_to_other[d])
{
}
}
}
- while (flip (&d) != LEFT);
Stencil brack = make_bracket (me, Y_AXIS,
points[RIGHT] - points[LEFT],
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);
}
Drul_array<Offset> 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<Offset> 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],
flare_corners[d]));
}
- while (flip (&d) != LEFT);
-
if (gap.is_empty ())
m.add_stencil (Line_interface::line (me, straight_corners[LEFT],
straight_corners[RIGHT]));
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]))
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]));
if (!tuplets[i]->is_live ())
continue;
- Direction d = LEFT;
Drul_array<Real> 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));
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)
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;
}