2 tie-column.cc -- implement Tie_column
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2005 Han-Wen Nienhuys <hanwen@cs.uu.nl>
9 #include "tie-column.hh"
16 #include "paper-column.hh"
18 #include "pointer-group-interface.hh"
20 #include "directional-element-interface.hh"
21 #include "tie-column-format.hh"
24 Tie_column::add_tie (Grob *me, Grob *tie)
26 if (tie->get_parent (Y_AXIS)
27 && Tie_column::has_interface (tie->get_parent (Y_AXIS)))
30 if (!Pointer_group_interface::count (me, ly_symbol2scm ("ties")))
32 dynamic_cast<Spanner *> (me)->set_bound (LEFT, Tie::head (tie, LEFT));
33 dynamic_cast<Spanner *> (me)->set_bound (RIGHT, Tie::head (tie, RIGHT));
36 tie->set_parent (me, Y_AXIS);
37 Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
38 tie->add_dependency (me);
42 Tie_column::set_directions (Grob *me)
44 if (!to_boolean (me->get_property ("positioning-done")))
46 me->set_property ("positioning-done", SCM_BOOL_T);
53 MAKE_SCHEME_CALLBACK (Tie_column, after_line_breaking, 1);
55 Tie_column::after_line_breaking (SCM smob)
57 set_directions (unsmob_grob (smob));
58 return SCM_UNSPECIFIED;
62 Extend the spanner over its Tie constituents.
64 MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1);
66 Tie_column::before_line_breaking (SCM smob)
68 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
69 for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
71 Spanner *tie = dynamic_cast<Spanner *> (unsmob_grob (scm_car (s)));
75 if (dir * tie->get_bound (dir)->get_column ()->get_rank ()
76 > dir * me->get_bound (dir)->get_column ()->get_rank ())
77 me->set_bound (dir, Tie::head (tie, dir));
79 while (flip (&dir) != LEFT);
81 return SCM_UNSPECIFIED;
86 Tie_column::new_directions (Grob *me)
88 extract_grob_set (me, "ties", ro_ties);
89 Link_array<Grob> ties (ro_ties);
95 Tie::set_default_control_points (ties[0]);
99 ties.sort (&Tie::compare);
101 Array<Tie_configuration> tie_configs;
102 for (int i = 0; i < ties.size (); i++)
104 Tie_configuration conf;
105 conf.dir_ = get_grob_direction (ties[i]);
106 conf.position_ = Tie::get_position (ties[i]);
107 tie_configs.push (conf);
110 SCM manual_configs = me->get_property ("tie-configuration");
111 bool manual_override = false;
112 set_manual_tie_configuration (&tie_configs,
115 set_tie_config_directions (&tie_configs);
118 for (int i = 0; i < ties.size (); i++)
120 common = dynamic_cast<Spanner*> (ties[i])->get_bound (LEFT)->common_refpoint (common, X_AXIS);
121 common = dynamic_cast<Spanner*> (ties[i])->get_bound (RIGHT)->common_refpoint (common, X_AXIS);
124 Drul_array< Array<Skyline_entry> > skylines;
125 set_chord_outlines (&skylines, ties, common);
128 details.init (ties[0]);
131 Let the ties flow out, according to our single-tie formatting.
133 if (!manual_override)
135 Tie::get_configuration (ties[0], common, &tie_configs.elem_ref (0),
139 Tie::get_configuration (ties.top (), common,
140 &tie_configs.elem_ref (tie_configs.size()-1),
147 Calculate final width and shape of the ties.
149 for (int i = 0; i < ties.size(); i++)
152 && (i == 0 || i == ties.size () -1))
156 final_shape_adjustment (tie_configs[i],
164 Try to shift small ties into available spaces.
166 if (!manual_override)
168 shift_small_ties (&tie_configs, ties[0], details);
171 for (int i = 0; i < ties.size(); i++)
173 Tie::set_control_points (ties[i], common, tie_configs[i],
176 set_grob_direction (ties[i], tie_configs[i].dir_);
182 ADD_INTERFACE (Tie_column, "tie-column-interface",
183 "Object that sets directions of multiple ties in a tied chord",