From 9e1f4fef0fcb3739fa03751cdde5606bb17fec74 Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 26 Mar 2002 23:09:51 +0000 Subject: [PATCH] lilypond-1.3.37 --- lily/beam.cc | 44 +++++++------- lily/dynamic-engraver.cc | 127 ++++++++++++++++++++++----------------- 2 files changed, 93 insertions(+), 78 deletions(-) diff --git a/lily/beam.cc b/lily/beam.cc index d641c8912c..23a62f4a5c 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -350,19 +350,19 @@ Beam::calc_position_and_height (Real* y, Real* dy) const } Array 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; } @@ -378,7 +378,7 @@ Beam::suspect_slope_b (Real y, Real dy) const 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)) @@ -404,8 +404,8 @@ Beam::calc_slope_damping_f (Real dy) const 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; @@ -421,9 +421,9 @@ Beam::calc_stem_y_f (Stem* s, Real y, Real dy) const 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 (); @@ -590,8 +590,8 @@ Beam::set_beaming (Beaming_info_list *beaming) 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"); @@ -605,9 +605,9 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const 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; @@ -636,7 +636,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const 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 beam_count (RIGHT) - next->beam_count (LEFT); int rwholebeams= here->beam_count (RIGHT) 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; @@ -717,19 +717,19 @@ Beam::do_brew_molecule () const 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 hpos_f ()-x0; + Real x = i->relative_coordinate (0, X_AXIS)-x0; sb.translate (Offset (x, x * dydx + y)); mol.add_molecule (sb); } diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 038d02ba54..8309597e50 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -24,6 +24,7 @@ #include "directional-element-interface.hh" #include "staff-symbol-referencer.hh" #include "translator-group.hh" +#include "axis-group-interface.hh" /* @@ -38,20 +39,20 @@ class Dynamic_line_spanner : public Spanner 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); @@ -61,29 +62,12 @@ Dynamic_line_spanner::add_column (Item* 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); } /** @@ -100,6 +84,7 @@ class Dynamic_engraver : public Engraver Drul_array span_req_l_drul_; Dynamic_line_spanner* line_spanner_; + Dynamic_line_spanner* finished_line_spanner_; Moment last_request_mom_; Note_column* pending_column_; @@ -138,6 +123,7 @@ Dynamic_engraver::Dynamic_engraver () 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; @@ -187,7 +173,7 @@ Dynamic_engraver::do_try_music (Music * m) 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 ()) { @@ -203,7 +189,7 @@ Dynamic_engraver::do_process_music () 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 (); } @@ -211,34 +197,62 @@ Dynamic_engraver::do_process_music () 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_) @@ -392,11 +406,12 @@ Dynamic_engraver::typeset_all () * 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; } } -- 2.39.5