lilypond-1.3.69
[lilypond.git] / lily / tie-column.cc
blob10008dc2fae6ab37688dedb72067cbdf3e1adbce
1 /*
2 tie-column.cc -- implement Tie_column
4 source file of the GNU LilyPond music typesetter
6 (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
8 */
10 #include "tie-column.hh"
11 #include "group-interface.hh"
12 #include "tie.hh"
13 #include "directional-element-interface.hh"
14 #include "rhythmic-head.hh"
16 Tie_column::Tie_column (SCM s)
17 : Spanner (s)
21 void
22 Tie_column::set_interface (Score_element*me)
24 me-> set_elt_property ("ties", SCM_EOL);
25 me->set_extent_callback (0, X_AXIS);
26 me->set_extent_callback (0, Y_AXIS);
29 void
30 Tie_column::add_tie (Score_element*me,Tie *s)
32 Pointer_group_interface g (me, "ties");
33 if (!g.count ())
35 dynamic_cast<Spanner*> (me)->set_bound (LEFT, Tie::head (s,LEFT));
36 dynamic_cast<Spanner*> (me)->set_bound (RIGHT, Tie::head (s,RIGHT));
39 Pointer_group_interface (me, "ties").add_element (s);
40 s->add_dependency (me);
44 int
45 tie_compare (Tie* const & s1,
46 Tie* const & s2)
48 return sign (Tie::position_f (s1) - Tie::position_f(s2));
52 See [Ross p. 138].
55 In normal chord cases, the outer ties point outwards, and the
56 direction of the rest is determined by their staff position.
58 Ross forgets about the tie that is *on* the middle staff line. We
59 assume it goes UP. (TODO: make me settable) */
60 void
61 Tie_column::set_directions (Score_element*me)
63 Link_array<Tie> ties =
64 Pointer_group_interface__extract_elements (me, (Tie*)0, "ties");
67 Direction d = Directional_element_interface (me).get ();
69 if (d)
71 for (int i = ties.size (); i--;)
73 Tie * t = ties[i];
74 Directional_element_interface (t).set (d);
76 return;
79 if (ties.size () == 1)
81 Tie * t = ties[0];
82 Directional_element_interface (t).set (Tie::get_default_dir (t));
83 return;
86 ties.sort (tie_compare);
87 Directional_element_interface tie0(ties[0]);
88 tie0.set (DOWN);
89 ties.del (0);
91 Directional_element_interface tietop(ties.pop ());
92 tietop.set (UP);
94 for (int i=ties.size(); i--; )
96 Tie * t = ties[i];
97 Real p = Tie::position_f (t);
98 Direction d = (Direction) sign (p);
99 if (!d)
100 d = UP;
101 Directional_element_interface (t).set (d);
106 MAKE_SCHEME_CALLBACK(Tie_column,after_line_breaking);
108 Tie_column::after_line_breaking (SCM smob)
110 set_directions (unsmob_element (smob));
111 return SCM_UNDEFINED;