+2003-06-20 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ * 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 <gperlist@shaw.ca>
* input/test/ beam-damp.ly grace-end.ly lyric-extender.ly
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);
void add_bound_item (Spanner*, Grob*);
///DECLARE_UNSMOB (Spanner, spanner);
+int broken_spanner_index (Spanner * sp);
#endif
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<Spanner*> (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<Spanner*> (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;
}
Grob *me= unsmob_grob (smob);
Spanner *spanner = dynamic_cast<Spanner*> (me);
- Item* bound_drul[] = {
- spanner->get_bound (LEFT),
- 0,
- spanner->get_bound (RIGHT)
- };
+ Drul_array<Item*> 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++)
{
}
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 */
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");
Offset o;
if (Spanner *mother = dynamic_cast<Spanner*> (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<Spanner*> (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;
}
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,
}
+/*
+ Return I such that SP == SP->ORIGINAL_->BROKEN_INTOS_[I].
+ */
+int
+broken_spanner_index (Spanner * sp)
+{
+ Spanner * parent = dynamic_cast<Spanner*> (sp->original_);
+ return parent->broken_intos_.find_index (sp);
+}
+
+
Spanner*
unsmob_spanner (SCM s )
{