* Documentation/user/tutorial.itely (A lead sheet): remove
[lilypond.git] / lily / tie-column.cc
blob6d4ad0e2932163bbd83fc533ec673fb3f71e0820
1 /*
2 tie-column.cc -- implement Tie_column
4 source file of the GNU LilyPond music typesetter
6 (c) 2000--2003 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "spanner.hh"
11 #include "tie-column.hh"
12 #include "group-interface.hh"
13 #include "tie.hh"
14 #include "directional-element-interface.hh"
15 #include "rhythmic-head.hh"
23 tie dir depends on what Tie_column does.
26 void
27 Tie_column::add_tie (Grob*me,Grob *s)
29 if (! Pointer_group_interface ::count (me, "ties"))
31 dynamic_cast<Spanner*> (me)->set_bound (LEFT, Tie::head (s,LEFT));
32 dynamic_cast<Spanner*> (me)->set_bound (RIGHT, Tie::head (s,RIGHT));
35 Pointer_group_interface::add_grob (me, ly_symbol2scm ("ties"), s);
36 s->add_dependency (me);
40 int
41 tie_compare (Grob* const & s1,
42 Grob* const & s2)
44 return sign (Tie::get_position (s1) - Tie::get_position (s2));
48 See [Ross p. 138].
51 In normal chord cases, the outer ties point outwards, and the
52 direction of the rest is determined by their staff position.
54 Ross forgets about the tie that is *on* the middle staff line. We
55 assume it goes UP. (TODO: make me settable) */
56 void
57 Tie_column::set_directions (Grob*me)
59 Link_array<Grob> ties =
60 Pointer_group_interface__extract_grobs (me, (Grob*)0, "ties");
62 for (int i = ties.size (); i--;)
63 if (Directional_element_interface::get (ties[i]))
64 ties.del (i);
67 if (!ties.size ())
68 return ;
71 Direction d = Directional_element_interface::get (me);
72 if (d)
74 for (int i = ties.size (); i--;)
76 Grob * t = ties[i];
77 Directional_element_interface::set (t, d);
79 return;
82 if (ties.size () == 1)
84 Grob * t = ties[0];
85 Directional_element_interface::set (t,Tie::get_default_dir (t));
86 return;
89 ties.sort (tie_compare);
90 Directional_element_interface::set (ties[0], DOWN);
91 ties.del (0);
93 Directional_element_interface ::set (ties.pop (), UP);
94 for (int i=ties.size (); i--;)
96 Grob * t = ties[i];
97 Real p = Tie::get_position (t);
98 Direction d = (Direction) sign (p);
99 if (!d)
100 d = UP;
101 Directional_element_interface::set (t, d);
106 MAKE_SCHEME_CALLBACK (Tie_column,after_line_breaking,1);
108 Tie_column::after_line_breaking (SCM smob)
110 set_directions (unsmob_grob (smob));
111 return SCM_UNSPECIFIED;
116 ADD_INTERFACE (Tie_column,"tie-column-interface",
117 "that sets tie directions in a tied chord",
118 "direction");