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"
15 #include "paper-column.hh"
17 #include "pointer-group-interface.hh"
19 #include "directional-element-interface.hh"
20 #include "tie-column-format.hh"
25 Tie_column::add_tie (Grob *me, Grob *tie)
27 if (tie->get_parent (Y_AXIS)
28 && Tie_column::has_interface (tie->get_parent (Y_AXIS)))
31 if (!Pointer_group_interface::count (me, ly_symbol2scm ("ties")))
33 dynamic_cast<Spanner *> (me)->set_bound (LEFT, Tie::head (tie, LEFT));
34 dynamic_cast<Spanner *> (me)->set_bound (RIGHT, Tie::head (tie, RIGHT));
37 tie->set_parent (me, Y_AXIS);
38 Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), tie);
42 Extend the spanner over its Tie constituents.
44 MAKE_SCHEME_CALLBACK (Tie_column, before_line_breaking, 1);
46 Tie_column::before_line_breaking (SCM smob)
48 Spanner *me = dynamic_cast<Spanner *> (unsmob_grob (smob));
49 for (SCM s = me->get_property ("ties"); scm_is_pair (s); s = scm_cdr (s))
51 Spanner *tie = dynamic_cast<Spanner *> (unsmob_grob (scm_car (s)));
55 if (dir * tie->get_bound (dir)->get_column ()->get_rank ()
56 > dir * me->get_bound (dir)->get_column ()->get_rank ())
57 me->set_bound (dir, Tie::head (tie, dir));
59 while (flip (&dir) != LEFT);
62 return SCM_UNSPECIFIED;
65 MAKE_SCHEME_CALLBACK(Tie_column, calc_positioning_done, 1)
67 Tie_column::calc_positioning_done (SCM smob)
69 Grob *me = unsmob_grob (smob);
70 extract_grob_set (me, "ties", ro_ties);
71 Link_array<Grob> ties (ro_ties);
78 Already handled by standard mechanisms.
83 ties.sort (&Tie::compare);
85 Array<Tie_configuration> tie_configs;
86 for (int i = 0; i < ties.size (); i++)
88 Tie_configuration conf;
89 conf.dir_ = get_grob_direction (ties[i]);
90 conf.position_ = Tie::get_position (ties[i]);
91 tie_configs.push (conf);
94 SCM manual_configs = me->get_property ("tie-configuration");
95 bool manual_override = false;
96 set_manual_tie_configuration (&tie_configs,
99 set_tie_config_directions (&tie_configs);
102 for (int i = 0; i < ties.size (); i++)
104 common = dynamic_cast<Spanner*> (ties[i])->get_bound (LEFT)->common_refpoint (common, X_AXIS);
105 common = dynamic_cast<Spanner*> (ties[i])->get_bound (RIGHT)->common_refpoint (common, X_AXIS);
108 Drul_array< Array<Skyline_entry> > skylines;
109 set_chord_outlines (&skylines, ties, common);
112 details.init (ties[0]);
115 Let the ties flow out, according to our single-tie formatting.
117 if (!manual_override)
119 Tie::get_configuration (ties[0], common, &tie_configs.elem_ref (0),
123 Tie::get_configuration (ties.top (), common,
124 &tie_configs.elem_ref (tie_configs.size()-1),
131 Calculate final width and shape of the ties.
133 for (int i = 0; i < ties.size(); i++)
136 && (i == 0 || i == ties.size () -1))
140 final_shape_adjustment (tie_configs[i],
148 Try to shift small ties into available spaces.
150 if (!manual_override)
152 shift_small_ties (&tie_configs, ties[0], details);
155 for (int i = 0; i < ties.size(); i++)
157 Tie::set_control_points (ties[i], common, tie_configs[i],
160 set_grob_direction (ties[i], tie_configs[i].dir_);
167 ADD_INTERFACE (Tie_column, "tie-column-interface",
168 "Object that sets directions of multiple ties in a tied chord",