#include "main.hh" // DEBUG_SLUR_SCORING
#include "note-column.hh"
#include "output-def.hh"
-#include "spanner.hh"
#include "skyline-pair.hh"
+#include "spanner.hh"
#include "staff-symbol-referencer.hh"
#include "stem.hh"
#include "text-interface.hh"
Slur::print (SCM smob)
{
Grob *me = unsmob_grob (smob);
+
extract_grob_set (me, "note-columns", encompasses);
if (encompasses.empty ())
{
Pointer_group_interface::add_grob (me, ly_symbol2scm ("encompass-objects"), n);
}
+void
+Slur::main_to_stub (Grob *main, Grob *stub)
+{
+ extract_grob_set (main, "note-columns", nc);
+ for (vsize i = 0; i < nc.size (); i++)
+ add_column (stub, nc[i]);
+
+ extract_grob_set (main, "encompass-objects", eo);
+ for (vsize i = 0; i < eo.size (); i++)
+ add_extra_encompass (stub, eo[i]);
+
+ stub->set_object ("surrogate", main->self_scm ());
+
+ dynamic_cast<Spanner *> (stub)->set_bound
+ (LEFT, dynamic_cast<Spanner *> (main)->get_bound (LEFT));
+ dynamic_cast<Spanner *> (stub)->set_bound
+ (RIGHT, dynamic_cast<Spanner *> (main)->get_bound (RIGHT));
+}
+
MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, pure_outside_slur_callback, 4, 1, "");
SCM
Slur::pure_outside_slur_callback (SCM grob, SCM start_scm, SCM end_scm, SCM offset_scm)
return scm_from_double (offset + avoidance_offset);
}
-MAKE_SCHEME_CALLBACK_WITH_OPTARGS (Slur, vertical_skylines, 1, 0, "");
+MAKE_SCHEME_CALLBACK (Slur, vertical_skylines, 1);
SCM
Slur::vertical_skylines (SCM smob)
{
vector<Box> boxes;
if (!me)
- return Skyline_pair (boxes, 0.0, X_AXIS).smobbed_copy ();
+ return Skyline_pair (boxes, X_AXIS).smobbed_copy ();
Bezier curve = Slur::get_curve (me);
vsize box_count = robust_scm2vsize (me->get_property ("skyline-quantizing"), 10);
boxes.push_back (b);
}
- return Skyline_pair (boxes, 0.0, X_AXIS).smobbed_copy ();
+ return Skyline_pair (boxes, X_AXIS).smobbed_copy ();
+}
+
+/*
+ * USE ME ONLY FOR CROSS STAFF SLURS!
+ * We only want to keep the topmost skyline of the topmost axis group(s)
+ * and the bottommost skyline of the bottommost axis group(s). Otherwise,
+ * the VerticalAxisGroups will be spaced very far apart to accommodate the
+ * slur, which we don't want, as it is cross staff.
+ *
+ * TODO: Currently, the code below keeps the topmost and bottommost axis
+ * groups and gets rid of the rest. This should be more nuanced for
+ * cases like ossias where the topmost staff changes over the course of
+ * the slur. Ditto for the bottommost staff.
+ */
+
+MAKE_SCHEME_CALLBACK (Slur, extremal_stub_vertical_skylines, 1);
+SCM
+Slur::extremal_stub_vertical_skylines (SCM smob)
+{
+ Grob *me = unsmob_grob (smob);
+ Grob *my_vag = Grob::get_vertical_axis_group (me);
+ extract_grob_set (me, "note-columns", ro_note_columns);
+ vector<Grob *> note_columns (ro_note_columns);
+ vector_sort (note_columns, Grob::vertical_less);
+ bool highest = my_vag == Grob::get_vertical_axis_group (note_columns[0]);
+ bool lowest = my_vag == Grob::get_vertical_axis_group (note_columns.back ());
+ if (!highest && !lowest)
+ return Skyline_pair ().smobbed_copy ();
+
+ Skyline_pair sky = *Skyline_pair::unsmob (vertical_skylines (smob));
+
+ if (highest)
+ sky[DOWN] = Skyline (DOWN);
+ else
+ sky[UP] = Skyline (UP);
+
+ return sky.smobbed_copy ();
}
/*
*/
void
Slur::auxiliary_acknowledge_extra_object (Grob_info const &info,
- vector<Grob *> &slurs,
- vector<Grob *> &end_slurs)
+ vector<Slur_info> &slur_infos,
+ vector<Slur_info> &end_slur_infos)
{
- if (slurs.empty () && end_slurs.empty ())
+ if (slur_infos.empty () && end_slur_infos.empty ())
return;
Grob *e = info.grob ();
SCM avoid = e->get_property ("avoid-slur");
+ Grob *slur;
+ if (end_slur_infos.size () && !slur_infos.size ())
+ slur = end_slur_infos[0].slur_;
+ else
+ slur = slur_infos[0].slur_;
+
if (Tie::has_interface (e)
|| avoid == ly_symbol2scm ("inside"))
{
- for (vsize i = slurs.size (); i--;)
- add_extra_encompass (slurs[i], e);
- for (vsize i = end_slurs.size (); i--;)
- add_extra_encompass (end_slurs[i], e);
+ for (vsize i = slur_infos.size (); i--;)
+ add_extra_encompass (slur_infos[i].slur_, e);
+ for (vsize i = end_slur_infos.size (); i--;)
+ add_extra_encompass (end_slur_infos[i].slur_, e);
+ if (slur)
+ e->set_object ("slur", slur->self_scm ());
}
else if (avoid == ly_symbol2scm ("outside")
|| avoid == ly_symbol2scm ("around"))
{
- Grob *slur;
- if (end_slurs.size () && !slurs.size ())
- slur = end_slurs[0];
- else
- slur = slurs[0];
-
if (slur)
{
chain_offset_callback (e, outside_slur_callback_proc, Y_AXIS);
}
}
else if (avoid != ly_symbol2scm ("ignore"))
- e->warning (_f ("Ignoring grob for slur: %s. avoid-slur not set?",
+ e->warning (_f ("Ignoring grob for slur: %s. avoid-slur not set?",
e->name ().c_str ()));
}
"inspect-index "
"line-thickness "
"note-columns "
- "skyline-quantizing "
"positions "
"ratio "
"thickness "
- "vertical-skylines "
);