Restore MIDI output for DrumStaff.
[lilypond/mpolesky.git] / lily / tie-column.cc
blobc236e55bc1252c169f479133319c8b7a2121c874
1 /*
2 tie-column.cc -- implement Tie_column
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2009 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
9 #include "tie-column.hh"
11 #include <cmath>
13 #include "output-def.hh"
14 #include "skyline.hh"
15 #include "warn.hh"
16 #include "paper-column.hh"
17 #include "spanner.hh"
18 #include "pointer-group-interface.hh"
19 #include "tie.hh"
20 #include "directional-element-interface.hh"
21 #include "tie-column-format.hh"
22 #include "tie-formatting-problem.hh"
23 #include "tie-configuration.hh"
25 using namespace std;
27 void
28 Tie_column::add_tie (Grob *tc, Grob *tie)
30 Spanner *me = dynamic_cast<Spanner *> (tc);
32 if (tie->get_parent (Y_AXIS)
33 && Tie_column::has_interface (tie->get_parent (Y_AXIS)))
34 return;
36 if (!me->get_bound (LEFT)
37 || (Paper_column::get_rank (me->get_bound (LEFT)->get_column ())
38 > Paper_column::get_rank (dynamic_cast<Spanner*> (tie)->get_bound (LEFT)->get_column ())))
40 me->set_bound (LEFT, Tie::head (tie, LEFT));
41 me->set_bound (RIGHT, Tie::head (tie, RIGHT));
44 tie->set_parent (me, Y_AXIS);
45 Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
49 Extend the spanner over its Tie constituents.
51 MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1);
52 SCM
53 Tie_column::before_line_breaking (SCM smob)
55 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
56 for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
58 Spanner *tie = dynamic_cast<Spanner *> (unsmob_grob (scm_car (s)));
59 Direction dir = LEFT;
62 if (dir * tie->get_bound (dir)->get_column ()->get_rank ()
63 > dir * me->get_bound (dir)->get_column ()->get_rank ())
64 me->set_bound (dir, Tie::head (tie, dir));
66 while (flip (&dir) != LEFT);
69 return SCM_UNSPECIFIED;
72 MAKE_SCHEME_CALLBACK (Tie_column, calc_positioning_done, 1)
73 SCM
74 Tie_column::calc_positioning_done (SCM smob)
76 Grob *me = unsmob_grob (smob);
77 extract_grob_set (me, "ties", ro_ties);
78 vector<Grob*> ties (ro_ties);
79 if (!ties.size ())
80 return SCM_BOOL_T;
83 me->set_property ("positioning-done", SCM_BOOL_T);
85 vector_sort (ties, Tie::less);
87 Tie_formatting_problem problem;
88 problem.from_ties (ties);
90 SCM manual_configs = me->get_property ("tie-configuration");
91 problem.set_manual_tie_configuration (manual_configs);
94 Ties_configuration base = problem.generate_optimal_configuration ();
96 for (vsize i = 0; i < base.size (); i++)
98 SCM cp = Tie::get_control_points (ties[i], problem.common_x_refpoint (),
99 base[i],
100 problem.details_);
102 ties[i]->set_property ("control-points", cp);
103 set_grob_direction (ties[i],
104 base[i].dir_);
106 problem.set_debug_scoring (base);
108 return SCM_BOOL_T;
113 ADD_INTERFACE (Tie_column,
114 "Object that sets directions of multiple ties in a tied chord.",
116 /* properties */
117 "positioning-done "
118 "tie-configuration "