}
Array<Offset> ideals;
- Real x0 = first_visible_stem ()->hpos_f ();
+ Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
for (int i=0; i < stem_count (); i++)
{
Stem* s = stem (i);
if (s->invisible_b ())
continue;
- ideals.push (Offset (s->hpos_f () - x0,
+ ideals.push (Offset (s->relative_coordinate (0, X_AXIS) - x0,
s->calc_stem_info ().idealy_f_));
}
Real dydx;
minimise_least_squares (&dydx, y, ideals); // duh, takes references
- Real dx = last_visible_stem ()->hpos_f () - x0;
+ Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
*dy = dydx * dx;
}
Real lengthened = paper_l ()->get_var ("beam_lengthened");
Real steep = paper_l ()->get_var ("beam_steep_slope");
- Real dx = last_visible_stem ()->hpos_f () - first_visible_stem ()->hpos_f ();
+ Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS);
Real dydx = dy && dx ? dy/dx : 0;
if (((y - first_ideal > lengthened) && (dydx > steep))
if (damping)
{
- Real dx = last_visible_stem ()->hpos_f ()
- - first_visible_stem ()->hpos_f ();
+ Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS)
+ - first_visible_stem ()->relative_coordinate (0, X_AXIS);
Real dydx = dy && dx ? dy/dx : 0;
dydx = 0.6 * tanh (dydx) / damping;
return dydx * dx;
int stem_multiplicity = (s->flag_i () - 2) >? 0;
Real interbeam_f = paper_l ()->interbeam_f (beam_multiplicity);
- Real x0 = first_visible_stem ()->hpos_f ();
- Real dx = last_visible_stem ()->hpos_f () - x0;
- Real stem_y = (dy && dx ? (s->hpos_f () - x0) / dx * dy : 0) + y;
+ Real x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
+ Real dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
+ Real stem_y = (dy && dx ? (s->relative_coordinate (0, X_AXIS) - x0) / dx * dy : 0) + y;
/* knee */
Direction dir = directional_element(this).get ();
Molecule
Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const
{
- if ((next && !(next->hpos_f () > here->hpos_f ())) ||
- (prev && !(prev->hpos_f () < here->hpos_f ())))
+ if ((next && !(next->relative_coordinate (0, X_AXIS) > here->relative_coordinate (0, X_AXIS))) ||
+ (prev && !(prev->relative_coordinate (0, X_AXIS) < here->relative_coordinate (0, X_AXIS))))
programming_error ("Beams are not left-to-right");
Real staffline_f = paper_l ()->get_var ("stafflinethickness");
Real stemdx = staffline_f;
Real dx = visible_stem_count () ?
- last_visible_stem ()->hpos_f () - first_visible_stem ()->hpos_f ()
+ last_visible_stem ()->relative_coordinate (0, X_AXIS) - first_visible_stem ()->relative_coordinate (0, X_AXIS)
: 0.0;
- Real dy = get_real ("height");
+ Real dy = gh_scm2double (get_elt_property ("height"));
Real dydx = dy && dx ? dy/dx : 0;
Molecule leftbeams;
Half beam should be one note-width,
but let's make sure two half-beams never touch
*/
- Real w = here->hpos_f () - prev->hpos_f ();
+ Real w = here->relative_coordinate (0, X_AXIS) - prev->relative_coordinate (0, X_AXIS);
w = w/2 <? nw_f;
Molecule a;
if (lhalfs) // generates warnings if not
int rhalfs = here->beam_count (RIGHT) - next->beam_count (LEFT);
int rwholebeams= here->beam_count (RIGHT) <? next->beam_count (LEFT) ;
- Real w = next->hpos_f () - here->hpos_f ();
+ Real w = next->relative_coordinate (0, X_AXIS) - here->relative_coordinate (0, X_AXIS);
Molecule a = lookup_l ()->beam (dydx, w + stemdx, thick);
a.translate_axis( - stemdx/2, X_AXIS);
int j = 0;
Real x0,dx;
if (visible_stem_count ())
{
- x0 = first_visible_stem ()->hpos_f ();
- dx = last_visible_stem ()->hpos_f () - x0;
+ x0 = first_visible_stem ()->relative_coordinate (0, X_AXIS);
+ dx = last_visible_stem ()->relative_coordinate (0, X_AXIS) - x0;
}
else
{
- x0 = stem (0)->hpos_f ();
- dx = stem_top ()->hpos_f () - x0;
+ x0 = stem (0)->relative_coordinate (0, X_AXIS);
+ dx = stem_top ()->relative_coordinate (0, X_AXIS) - x0;
}
- Real dy = get_real ("height");
+ Real dy = gh_scm2double (get_elt_property ("height"));
Real dydx = dy && dx ? dy/dx : 0;
- Real y = get_real ("y-position");
+ Real y = gh_scm2double (get_elt_property ("y-position"));
for (int j=0; j <stem_count (); j++)
{
Stem *i = stem (j);
Stem * next = (j < stem_count ()-1) ? stem (j+1) :0;
Molecule sb = stem_beams (i, next, prev);
- Real x = i->hpos_f ()-x0;
+ Real x = i->relative_coordinate (0, X_AXIS)-x0;
sb.translate (Offset (x, x * dydx + y));
mol.add_molecule (sb);
}
#include "directional-element-interface.hh"
#include "staff-symbol-referencer.hh"
#include "translator-group.hh"
+#include "axis-group-interface.hh"
/*
public:
Dynamic_line_spanner ();
VIRTUAL_COPY_CONS(Score_element);
- void add_column (Item*);
-
-protected:
- virtual void after_line_breaking ();
+ void add_column (Note_column*);
+ void add_element (Score_element*);
};
Dynamic_line_spanner::Dynamic_line_spanner ()
{
set_elt_property ("transparent", SCM_BOOL_T);
side_position (this).set_axis (Y_AXIS);
+ Axis_group_interface (this).set_interface ();
+ Axis_group_interface (this).set_axes (X_AXIS, Y_AXIS);
}
void
-Dynamic_line_spanner::add_column (Item* n)
+Dynamic_line_spanner::add_column (Note_column* n)
{
if (!get_bound (LEFT))
set_bound (LEFT, n);
add_dependency (n);
}
+
void
-Dynamic_line_spanner::after_line_breaking ()
+Dynamic_line_spanner::add_element (Score_element* e)
{
-#if 0
-
- /*
- We hebben hier een probleempje: er is een verschil tussen
- dynamics zonder en met line-spanner.
- Allen zijn gecentreerd (aligned-on-self), wat okee is,
- maar de losse hebben zelf een padding tov de staff.
-
- Deze padding werkt niet op items die in line-spanner zitten:
- de padding werkt op line-spanner zelf.
- De line-spanner moet dus eigenlijk zoveel naar beneden of boven
- als er items uitsteken, maar Hmm.
- */
-#endif
- Direction dir = directional_element (this).get ();
- if (!dir)
- dir = DOWN;
- //Hmm. inf
- //translate_axis (extent (Y_AXIS)[dir], Y_AXIS);
- translate_axis (staff_symbol_referencer (this).staff_space () * dir, Y_AXIS);
+ e->set_parent (this, Y_AXIS);
+ Axis_group_interface (this).add_element (e);
}
/**
Drul_array<Span_req*> span_req_l_drul_;
Dynamic_line_spanner* line_spanner_;
+ Dynamic_line_spanner* finished_line_spanner_;
Moment last_request_mom_;
Note_column* pending_column_;
text_p_ = 0;
finished_cresc_p_ = 0;
line_spanner_ = 0;
+ finished_line_spanner_ = 0;
span_start_req_l_ = 0;
cresc_p_ =0;
pending_column_ = 0;
void
Dynamic_engraver::do_process_music ()
{
- if ((span_req_l_drul_[START] || text_req_l_)
+ if ((span_req_l_drul_[START] || span_req_l_drul_[STOP] || text_req_l_)
&& !line_spanner_
&& pending_element_arr_.size ())
{
if (line_spanner_ && pending_element_arr_.size ())
{
for (int i = 0; i < pending_element_arr_.size (); i++)
- pending_element_arr_[i]->set_parent (line_spanner_, Y_AXIS);
+ line_spanner_->add_element (pending_element_arr_[i]);
pending_element_arr_.clear ();
}
last_request_mom_ = now_mom ();
else
{
- for (int i = 0; i < pending_element_arr_.size (); i++)
+
+#if 0
+ /*
+ Maybe always creating a line-spanner for a (de)crescendo (see
+ below) is not a good idea:
+
+ a\< b\p \!c
+
+ the \p will be centred on the line-spanner, and thus clash
+ with the hairpin. When axis-group code is in place, the \p
+ should move below the hairpin, which is probably better?
+
+ Urg, but line-spanner must always have at least same duration
+ as (de)crecsendo, b.o. line-breaking.
+ */
+ if (now_mom () > last_request_mom_)
+#else
+ /*
+ During a (de)crescendo, pending request will not be cleared,
+ and a line-spanner will always be created, as \< \! are already
+ two requests.
+ */
+ if (now_mom () > last_request_mom_ && !span_start_req_l_)
+#endif
{
- Score_element* e = pending_element_arr_[i];
- side_position (e).set_axis (Y_AXIS);
- side_position (e).add_staff_support ();
-
- /*
- UGH UGH
- */
- Direction d = directional_element (e).get ();
- if (!d)
+ for (int i = 0; i < pending_element_arr_.size (); i++)
{
- SCM s = get_property ("dynamicDirection");
- if (!isdir_b (s))
- s = get_property ("verticalDirection");
- if (isdir_b (s))
- d = to_dir (s);
- directional_element (e).set (d);
- }
+ Score_element* e = pending_element_arr_[i];
+ side_position (e).set_axis (Y_AXIS);
+ side_position (e).add_staff_support ();
+
+ /*
+ UGH UGH
+ */
+ Direction d = directional_element (e).get ();
+ if (!d)
+ {
+ SCM s = get_property ("dynamicDirection");
+ if (!isdir_b (s))
+ s = get_property ("verticalDirection");
+ if (isdir_b (s))
+ d = to_dir (s);
+ directional_element (e).set (d);
+ }
- SCM s = get_property ("dynamicPadding");
- if (gh_number_p (s))
- e->set_elt_property ("padding", s);
- s = get_property ("dynamicMinimumSpace");
- if (gh_number_p (s))
- e->set_elt_property ("minimum-space", s);
+ SCM s = get_property ("dynamicPadding");
+ if (gh_number_p (s))
+ e->set_elt_property ("padding", s);
+ s = get_property ("dynamicMinimumSpace");
+ if (gh_number_p (s))
+ e->set_elt_property ("minimum-space", s);
+ }
+ pending_element_arr_.clear ();
+ finished_line_spanner_ = line_spanner_;
+ line_spanner_ = 0;
}
- pending_element_arr_.clear ();
}
if (text_req_l_)
* break when group of dynamic requests ends
* break now
* continue through piece */
- if (line_spanner_ && last_request_mom_ < now_mom ())
+ // if (line_spanner_ && last_request_mom_ < now_mom ())
+ if (finished_line_spanner_)
{
- side_position (line_spanner_).add_staff_support ();
- typeset_element (line_spanner_);
- line_spanner_ = 0;
+ side_position (finished_line_spanner_).add_staff_support ();
+ typeset_element (finished_line_spanner_);
+ finished_line_spanner_ = 0;
}
}