out_of_staff into aligned_side.
* input/regression/measure-grouping.ly: fix warning.
* lily/side-position-interface.cc: add staff-padding support to
Side_position_interface::aligned_side.
* lily/system-start-delimiter-engraver.cc (process_music): whoops,
one get_property too many.
* flower/include/drul-array.hh (linear_combination): new function
(scale_drul): new function
* lily/beam.cc: use Drul_array<Real> iso. interval, because *=
operations on empty intervals are silly.
+2004-01-27 Han-Wen Nienhuys <hanwen@xs4all.nl>
+
+ * lily/side-position-interface.cc (out_of_staff): move contents of
+ out_of_staff into aligned_side.
+
+ * input/regression/measure-grouping.ly: fix warning.
+
+ * lily/side-position-interface.cc: add staff-padding support to
+ Side_position_interface::aligned_side.
+
+ * lily/system-start-delimiter-engraver.cc (process_music): whoops,
+ one get_property too many.
+
+ * flower/include/drul-array.hh (linear_combination): new function
+ (scale_drul): new function
+
+ * lily/beam.cc: use Drul_array<Real> iso. interval, because *=
+ operations on empty intervals are silly.
+
2004-01-26 Jan Nieuwenhuizen <janneke@gnu.org>
* lily/note-heads-engraver.cc (process_music): use robust_scm2int
MAJOR_VERSION=2
MINOR_VERSION=1
PATCH_LEVEL=15
-MY_PATCH_LEVEL=
+MY_PATCH_LEVEL=hwn1
#define DRUL_ARRAY_HH
#include "direction.hh"
+#include "real.hh"
#include <assert.h>
}
};
+template<class T>
+void
+scale_drul (Drul_array<T> * dr, T x)
+{
+ dr->elem (LEFT) *= x;
+ dr->elem (RIGHT) *= x;
+}
+
+inline Real
+linear_combination (Drul_array<Real> const &d, Real x)
+{
+ return ((1.0 - x) * Real (d.elem (LEFT)) + (x + 1.0) * Real (d.elem (RIGHT))) * 0.5;
+}
+
#endif // DRUL_ARRAY_HH
}
Real linear_combination (Real x) const {
- return ((1.0 - x) * Real (elem (LEFT)) + (x + 1.0) * Real (elem (RIGHT))) * 0.5;
+ Drul_array<Real> da (elem (LEFT),
+ elem (RIGHT));
+ return ::linear_combination (da, x);
}
String to_string () const;
template INTERVAL__INSTANTIATE (int);
template INTERVAL__INSTANTIATE (Real);
+
{
texidoc = "The @code{Measure_grouping_engraver} adds triangles and
-brackets above beats when you set beatGrouping. This shows a fragment
-of Steve Martland's Dance Works. "
+brackets above beats when you set beatGrouping. "
}
\time 2/4
c,8 g'4 g8~
#(set-time-signature 5 8 '(3 2))
- g8 a4 g a->
+ g8 a4 g a4.->
}
\paper {
raggedright = ##t
if (debug_beam_quanting_flag
&& gh_pair_p (inspect_quants))
{
- Real il = gh_scm2double (gh_car (inspect_quants));
- Real ir = gh_scm2double (gh_cdr (inspect_quants));
+ Drul_array<Real> ins = ly_scm2interval (inspect_quants);
int i = 0;
Real mindist = 1e6;
for (; i < qscores.size(); i ++)
{
- Real d =fabs (qscores[i].yl-il) + fabs (qscores[i].yr - ir);
+ Real d =fabs (qscores[i].yl- ins[LEFT]) + fabs (qscores[i].yr - ins[RIGHT]);
if (d < mindist)
{
best_idx = i;
#endif
me->set_grob_property ("positions",
- gh_cons (gh_double2scm (qscores[best_idx].yl),
- gh_double2scm (qscores[best_idx].yr)));
+ ly_interval2scm (Drul_array<Real> (qscores[best_idx].yl,
+ qscores[best_idx].yr)));
#if DEBUG_QUANTING
if (debug_beam_quanting_flag)
{
/*
TODO:
- * Use Number_pair i.s.o Interval to represent (yl, yr).
-
- Determine auto knees based on positions if it's set by the user.
- the code is littered with * and / staff_space calls for
#include "spanner.hh"
#include "warn.hh"
-
-
bool debug_beam_quanting_flag;
}
SCM posns = me->get_grob_property ("positions");
- Interval pos;
+ Drul_array<Real> pos;
if (!is_number_pair (posns))
{
programming_error ("No beam posns");
pos = Interval (0,0);
}
else
- pos= ly_scm2interval (posns);
-
+ pos= ly_scm2realdrul (posns);
- pos *= Staff_symbol_referencer::staff_space (me);
- Real dy = pos.delta ();
+ scale_drul ( &pos, Staff_symbol_referencer::staff_space (me));
+
+ Real dy = pos[RIGHT] - pos[LEFT];
Real dydx = (dy && dx) ? dy/dx : 0;
Real thick = get_thickness (me);
Real bdy = get_beam_translation (me);
- SCM last_beaming = SCM_EOL;;
+ SCM last_beaming = SCM_EOL;
Real last_xposn = -1;
Real last_stem_width = -1 ;
/*
"position" is relative to the staff.
*/
- pos *= 1/ Staff_symbol_referencer::staff_space (me);
+ scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me));
me->set_grob_property ("positions", ly_interval2scm (pos));
Real dx = lvs->relative_coordinate (commonx, X_AXIS) - x0;
- Interval pos = ly_scm2interval ( me->get_grob_property ("positions"));
+ Drul_array<Real> pos = ly_scm2interval ( me->get_grob_property ("positions"));
- pos *= Staff_symbol_referencer::staff_space (me);
+ scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
- Real dy = pos.delta();
+ Real dy = pos[RIGHT] - pos[LEFT];
Real y = pos[LEFT];
Real dydx =dy/dx;
y = feasible_left_point.center ();
}
- pos = Interval (y, (y+dy));
- pos *= 1/ Staff_symbol_referencer::staff_space (me);
+ pos = Drul_array<Real> (y, (y+dy));
+ scale_drul (&pos, 1/ Staff_symbol_referencer::staff_space (me));
me->set_grob_property ("positions", ly_interval2scm (pos));
return SCM_UNSPECIFIED;
/* TODO: some sort of damping iso -> plain horizontal */
if (concaveness1 || concaveness2 > r2)
{
- Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
- Real r = pos.linear_combination (0);
+ Drul_array<Real> pos = ly_scm2interval (me->get_grob_property ("positions"));
+ Real r = linear_combination (pos, 0);
r /= Staff_symbol_referencer::staff_space (me);
- me->set_grob_property ("positions", ly_interval2scm (Interval (r, r)));
+ me->set_grob_property ("positions", ly_interval2scm (Drul_array<Real> (r, r)));
me->set_grob_property ("least-squares-dy", gh_double2scm (0));
}
if (damping)
{
- Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
- pos *= Staff_symbol_referencer::staff_space (me);
+ Drul_array<Real> pos = ly_scm2interval (me->get_grob_property ("positions"));
+ scale_drul (&pos, Staff_symbol_referencer::staff_space (me));
- Real dy = pos.delta ();
+ Real dy = pos[RIGHT] - pos[LEFT];
Grob *fvs = first_visible_stem (me);
Grob *lvs = last_visible_stem (me);
pos[LEFT] += (dy - damped_dy) / 2;
pos[RIGHT] -= (dy - damped_dy) / 2;
- pos *= 1/ Staff_symbol_referencer::staff_space (me);
+ scale_drul (&pos, 1/Staff_symbol_referencer::staff_space (me));
me->set_grob_property ("positions", ly_interval2scm (pos));
}
Real
Beam::calc_stem_y (Grob *me, Grob* s, Grob ** common,
Real xl, Real xr,
- Interval pos, bool french)
+ Drul_array<Real> pos, bool french)
{
Real beam_translation = get_beam_translation (me);
Real r = s->relative_coordinate (common[X_AXIS], X_AXIS) - xl;
- Real dy = pos.delta ();
+ Real dy = pos[RIGHT] - pos[LEFT];
Real dx = xr - xl;
Real stem_y_beam0 = (dy && dx
? r / dx
for (int a = 2; a--;)
common[a] = common_refpoint_of_array (stems, me, Axis(a));
- Interval pos = ly_scm2interval (me->get_grob_property ("positions"));
+ Drul_array<Real> pos = ly_scm2realdrul (me->get_grob_property ("positions"));
Real staff_space = Staff_symbol_referencer::staff_space (me);
- pos *= staff_space;
+ scale_drul (&pos, staff_space);
bool gap = false;
Real thick =0.0;
|| !Beam::visible_stem_count (beam))
return gh_double2scm (0.0);
- Interval pos (0, 0);
+ Drul_array<Real> pos (0, 0);
SCM s = beam->get_grob_property ("positions");
if (gh_pair_p (s) && gh_number_p (ly_car (s)))
pos = ly_scm2interval (s);
Real staff_space = Staff_symbol_referencer::staff_space (rest);
- pos *= staff_space;
+ scale_drul (&pos, staff_space);
- Real dy = pos.delta ();
+ Real dy = pos[RIGHT] - pos[LEFT];
// ugh -> use commonx
Real x0 = first_visible_stem (beam)->relative_coordinate (0, X_AXIS);
static void set_stem_shorten (Grob*);
static Real calc_stem_y (Grob*, Grob* s, Grob**c,
Real, Real,
- Interval pos, bool french);
+ Drul_array<Real> pos, bool french);
static void set_stem_lengths (Grob*);
static int forced_stem_count (Grob*);
};
SCM ly_assoc_chain (SCM key, SCM achain);
SCM ly_assoc_cdr (SCM key, SCM alist);
Interval ly_scm2interval (SCM);
+Drul_array<Real> ly_scm2realdrul (SCM);
Slice int_list_to_slice (SCM l);
SCM ly_interval2scm (Drul_array<Real>);
gh_scm2double (ly_cdr (p)));
}
+Drul_array<Real>
+ly_scm2realdrul (SCM p)
+{
+ return Drul_array<Real> (gh_scm2double (ly_car (p)),
+ gh_scm2double (ly_cdr (p)));
+}
+
SCM
ly_interval2scm (Drul_array<Real> i)
{
if (fabs (total_off) > 100 CM)
programming_error ("Huh ? Improbable staff side dim.");
+
+
+
return gh_double2scm (total_off);
}
}
o += - iv[-d];
}
+
+ Grob * st = Staff_symbol_referencer::get_staff_symbol (me);
+ if (st && a == Y_AXIS
+ && gh_number_p (me->get_grob_property ("staff-padding")))
+ {
+ Real padding=
+ Staff_symbol_referencer::staff_space (me)
+ * gh_scm2double (me->get_grob_property ("staff-padding"));
+
+ Grob *common = me->common_refpoint (st, Y_AXIS);
+
+ Interval staff_size = st->extent (common, Y_AXIS);
+ Interval me_ext = me->extent (common, a);
+ Real diff = d*staff_size[d] + padding - d*(o + iv[-d]);
+ o += (d* (diff >? 0));
+ }
+
return gh_double2scm (o);
}
SCM
Side_position_interface::out_of_staff (SCM element_smob, SCM axis)
{
- Grob *me = unsmob_grob (element_smob);
- Axis a = (Axis) gh_scm2int (axis);
-
- Grob * st = Staff_symbol_referencer::get_staff_symbol (me);
-
- if (!st)
- return gh_int2scm (0);
-
- SCM scm_padding = me->get_grob_property ("staff-padding");
- if (!gh_number_p (scm_padding))
- return gh_int2scm (0);
-
- Real padding=
- Staff_symbol_referencer::staff_space (me)
- * gh_scm2double (scm_padding);
-
- Grob *common = me->common_refpoint (st, Y_AXIS);
- Direction d = Side_position_interface::get_direction (me);
- Interval staff_size = st->extent (common, Y_AXIS);
- Interval me_ext = me->extent (common, a);
- Real diff = d*staff_size[d] + padding - d*me_ext[-d];
- return gh_double2scm (d* (diff >? 0));
+ return gh_double2scm (0);
}
void
Real
Staff_symbol::get_ledger_line_thickness (Grob * me)
{
- Real lt = me->get_paper ()->get_realvar (ly_symbol2scm ("linethickness"));
-
SCM lt_pair = me->get_grob_property ("ledger-line-thickness");
Offset z = robust_scm2offset (lt_pair, Offset (1.0, 0.1));
if (!delim_)
{
SCM delim_name =get_property ("systemStartDelimiter");
- delim_ = internal_make_spanner (internal_get_property (delim_name));
+ delim_ = internal_make_spanner (delim_name);
delim_->set_bound (LEFT, unsmob_grob (get_property ("currentCommandColumn")));
announce_grob (delim_, SCM_EOL);
))
(MeasureGrouping
. (
- (Y-offset-callbacks . (,Side_position_interface::out_of_staff
- ,Side_position_interface::aligned_side))
+ (Y-offset-callbacks . (,Side_position_interface::aligned_side))
(molecule-callback . ,Measure_grouping::brew_molecule)
(padding . 2)
(direction . 1)
(OttavaBracket
. (
- (Y-offset-callbacks . (,Side_position_interface::out_of_staff
- ,Side_position_interface::aligned_side))
+ (Y-offset-callbacks . (,Side_position_interface::aligned_side))
(molecule-callback . ,Ottava_bracket::brew_molecule)
(font-shape . italic)
(font-family . roman)