From: Han-Wen Nienhuys Date: Thu, 19 Jun 2003 23:09:43 +0000 (+0000) Subject: * lily/slur.cc (get_boundary_notecolumn_y): change name from X-Git-Tag: release/1.7.23~31 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=124ce2dc953fc53bfd9b0c0fe607546fed45d896;p=lilypond.git * lily/slur.cc (get_boundary_notecolumn_y): change name from get_first_notecolumn_y * lily/spanner.cc (broken_spanner_index): new function. --- diff --git a/ChangeLog b/ChangeLog index fb663df35d..f1be3b3218 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2003-06-20 Han-Wen Nienhuys + + * lily/slur.cc (get_boundary_notecolumn_y): change name from + get_first_notecolumn_y + + * lily/spanner.cc (broken_spanner_index): new function. + 2003-06-19 Graham Percival * input/test/ beam-damp.ly grace-end.ly lyric-extender.ly diff --git a/lily/include/slur.hh b/lily/include/slur.hh index 67d1334f74..4c3eb95354 100644 --- a/lily/include/slur.hh +++ b/lily/include/slur.hh @@ -25,7 +25,7 @@ public: DECLARE_SCHEME_CALLBACK (height, (SCM,SCM)); private: - static Real get_first_notecolumn_y (Grob *me, Direction dir); + static Real get_boundary_notecolumn_y (Grob *me, Direction dir); static Offset broken_trend_offset (Grob *me, Direction dir); static Offset get_attachment (Grob *me,Direction dir, Grob **common); static void de_uglyfy (Grob *me,Slur_bezier_bow* bb, Real default_height); diff --git a/lily/include/spanner.hh b/lily/include/spanner.hh index b4aa9f9998..4afd77cfad 100644 --- a/lily/include/spanner.hh +++ b/lily/include/spanner.hh @@ -68,4 +68,5 @@ protected: void add_bound_item (Spanner*, Grob*); ///DECLARE_UNSMOB (Spanner, spanner); +int broken_spanner_index (Spanner * sp); #endif diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index fabfbf1a76..7ed5314f28 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -160,32 +160,26 @@ Line_spanner::get_broken_offset (Grob *me, Direction dir) return Offset (); } +/* A broken line-spaner should maintain the same vertical trend + the unbroken line-spanner would have had. + From slur */ Offset Line_spanner::broken_trend_offset (Grob *me, Direction dir) { - /* A broken line-spaner should maintain the same vertical trend - the unbroken line-spanner would have had. - From slur */ Offset o; + if (Spanner *mother = dynamic_cast (me->original_)) { - for (int i = dir == LEFT ? 0 : mother->broken_intos_.size () - 1; - dir == LEFT ? i < mother->broken_intos_.size () : i > 0; - dir == LEFT ? i++ : i--) - { - if (mother->broken_intos_[i - dir] == me) - { - Grob *neighbour = mother->broken_intos_[i]; - Offset neighbour_o = get_broken_offset (neighbour, dir); - Offset me_o = get_broken_offset (me, -dir); - // Hmm, why not return me_o[X], but recalc in brew_mol? - o = Offset (0, - (neighbour_o[Y_AXIS]*me_o[X_AXIS] - - me_o[Y_AXIS]*neighbour_o[X_AXIS]) * dir / - (me_o[X_AXIS] + neighbour_o[X_AXIS])); - break; - } - } + int k = broken_spanner_index (dynamic_cast (me)); + Grob *neighbour = mother->broken_intos_[k + dir]; + Offset neighbour_o = get_broken_offset (neighbour, dir); + Offset me_o = get_broken_offset (me, -dir); + + // Hmm, why not return me_o[X], but recalc in brew_mol? + o = Offset (0, + (neighbour_o[Y_AXIS]*me_o[X_AXIS] + - me_o[Y_AXIS]*neighbour_o[X_AXIS]) * dir / + (me_o[X_AXIS] + neighbour_o[X_AXIS])); } return o; } @@ -207,14 +201,9 @@ Line_spanner::brew_molecule (SCM smob) Grob *me= unsmob_grob (smob); Spanner *spanner = dynamic_cast (me); - Item* bound_drul[] = { - spanner->get_bound (LEFT), - 0, - spanner->get_bound (RIGHT) - }; + Drul_array bound (spanner->get_bound (LEFT), + spanner->get_bound (RIGHT)); - Item** bound = bound_drul + 1; - Grob *common[] = { me, me }; for (int a = X_AXIS; a < NO_AXES; a++) { @@ -229,13 +218,13 @@ Line_spanner::brew_molecule (SCM smob) } Real gap = gh_scm2double (me->get_grob_property ("gap")); - Real dist; /*distance between points */ Offset ofxy (gap, 0); /*offset from start point to start of line*/ Offset dxy ; Offset my_off; Offset his_off; + if (bound[LEFT]->break_status_dir () || bound[RIGHT]->break_status_dir ()) /* across line break */ diff --git a/lily/slur.cc b/lily/slur.cc index eba766cc31..7473197e22 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -218,7 +218,7 @@ Slur::set_extremities (Grob *me) Real -Slur::get_first_notecolumn_y (Grob *me, Direction dir) +Slur::get_boundary_notecolumn_y (Grob *me, Direction dir) { SCM cols = me->get_grob_property ("note-columns"); @@ -261,25 +261,17 @@ Slur::broken_trend_offset (Grob *me, Direction dir) Offset o; if (Spanner *mother = dynamic_cast (me->original_)) { - for (int i = dir == LEFT ? 0 : mother->broken_intos_.size () - 1; - dir == LEFT ? i < mother->broken_intos_.size () : i > 0; - dir == LEFT ? i++ : i--) - { - if (mother->broken_intos_[i - dir] == me) - { - Grob *neighbour = mother->broken_intos_[i]; - if (dir == RIGHT) - neighbour->set_grob_property ("direction", - me->get_grob_property ("direction")); - Real neighbour_y = get_first_notecolumn_y (neighbour, dir); - Real y = get_first_notecolumn_y (me, -dir); - int neighbour_cols = scm_ilength (neighbour->get_grob_property ("note-columns")); - int cols = scm_ilength (me->get_grob_property ("note-columns")); - o = Offset (0, (y*neighbour_cols + neighbour_y*cols) / - (cols + neighbour_cols)); - break; - } - } + int k = broken_spanner_index (dynamic_cast (me)); + Grob *neighbour = mother->broken_intos_[k + dir]; + if (dir == RIGHT) + neighbour->set_grob_property ("direction", + me->get_grob_property ("direction")); + Real neighbour_y = get_boundary_notecolumn_y (neighbour, dir); + Real y = get_boundary_notecolumn_y (me, -dir); + int neighbour_cols = scm_ilength (neighbour->get_grob_property ("note-columns")); + int cols = scm_ilength (me->get_grob_property ("note-columns")); + o = Offset (0, (y*neighbour_cols + neighbour_y*cols) / + (cols + neighbour_cols)); } return o; } @@ -288,6 +280,8 @@ Slur::broken_trend_offset (Grob *me, Direction dir) COMMON is size-2 array with common refpoints. UGH: this routine delivers offsets which are *not* relative to COMMON. + +UGH, we should take COMMON-Y as argument. */ Offset Slur::get_attachment (Grob *me, Direction dir, diff --git a/lily/spanner.cc b/lily/spanner.cc index 5882795d0a..0b444d45fe 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -343,6 +343,17 @@ Spanner::set_spacing_rods (SCM smob) } +/* + Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I]. + */ +int +broken_spanner_index (Spanner * sp) +{ + Spanner * parent = dynamic_cast (sp->original_); + return parent->broken_intos_.find_index (sp); +} + + Spanner* unsmob_spanner (SCM s ) {