2 This file is part of LilyPond, the GNU music typesetter.
4 Copyright (C) 2000--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
6 LilyPond is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 LilyPond is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with LilyPond. If not, see <http://www.gnu.org/licenses/>.
20 #include "tie-column.hh"
24 #include "output-def.hh"
27 #include "paper-column.hh"
29 #include "pointer-group-interface.hh"
31 #include "directional-element-interface.hh"
32 #include "tie-formatting-problem.hh"
33 #include "tie-configuration.hh"
38 Tie_column::add_tie (Grob *tc, Spanner *tie)
40 Spanner *me = dynamic_cast<Spanner *> (tc);
42 if (tie->get_parent (Y_AXIS)
43 && has_interface<Tie_column> (tie->get_parent (Y_AXIS)))
46 if (!me->get_bound (LEFT)
47 || (Paper_column::get_rank (me->get_bound (LEFT)->get_column ())
48 > Paper_column::get_rank (dynamic_cast<Spanner *> (tie)->get_bound (LEFT)->get_column ())))
50 me->set_bound (LEFT, Tie::head (tie, LEFT));
51 me->set_bound (RIGHT, Tie::head (tie, RIGHT));
54 tie->set_parent (me, Y_AXIS);
55 Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
59 Extend the spanner over its Tie constituents.
61 MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1);
63 Tie_column::before_line_breaking (SCM smob)
65 Spanner *me = unsmob<Spanner> (smob);
66 for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
68 Spanner *tie = unsmob<Spanner> (scm_car (s));
69 for (LEFT_and_RIGHT (dir))
71 if (dir * tie->get_bound (dir)->get_column ()->get_rank ()
72 > dir * me->get_bound (dir)->get_column ()->get_rank ())
73 me->set_bound (dir, Tie::head (tie, dir));
77 return SCM_UNSPECIFIED;
80 MAKE_SCHEME_CALLBACK (Tie_column, calc_positioning_done, 1)
82 Tie_column::calc_positioning_done (SCM smob)
84 Grob *me = unsmob<Grob> (smob);
85 extract_grob_set (me, "ties", ro_ties);
86 vector<Grob *> ties (ro_ties);
90 me->set_property ("positioning-done", SCM_BOOL_T);
91 vector_sort (ties, Tie::less);
93 Tie_formatting_problem problem;
94 problem.from_ties (ties);
96 SCM manual_configs = me->get_property ("tie-configuration");
97 problem.set_manual_tie_configuration (manual_configs);
99 Ties_configuration base = problem.generate_optimal_configuration ();
100 for (vsize i = 0; i < base.size (); i++)
102 SCM cp = Tie::get_control_points (ties[i], problem.common_x_refpoint (),
106 ties[i]->set_property ("control-points", cp);
107 set_grob_direction (ties[i],
110 problem.set_debug_scoring (base);
115 ADD_INTERFACE (Tie_column,
116 "Object that sets directions of multiple ties in a tied"