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>
11 #include "tie-column.hh"
12 #include "group-interface.hh"
14 #include "directional-element-interface.hh"
15 #include "rhythmic-head.hh"
20 Tie_column::set_interface (Score_element*me)
22 me->set_interface (ly_symbol2scm ("tie-column"));
23 me->set_extent_callback (0, X_AXIS);
24 me->set_extent_callback (0, Y_AXIS);
28 Tie_column::has_interface (Score_element*me)
30 return me->has_interface (ly_symbol2scm ("tie-column"));
34 Tie_column::add_tie (Score_element*me,Score_element *s)
36 Pointer_group_interface g (me, "ties");
39 dynamic_cast<Spanner*> (me)->set_bound (LEFT, Tie::head (s,LEFT));
40 dynamic_cast<Spanner*> (me)->set_bound (RIGHT, Tie::head (s,RIGHT));
43 Pointer_group_interface (me, "ties").add_element (s);
44 s->add_dependency (me);
49 tie_compare (Score_element* const & s1,
50 Score_element* const & s2)
52 return sign (Tie::position_f (s1) - Tie::position_f(s2));
59 In normal chord cases, the outer ties point outwards, and the
60 direction of the rest is determined by their staff position.
62 Ross forgets about the tie that is *on* the middle staff line. We
63 assume it goes UP. (TODO: make me settable) */
65 Tie_column::set_directions (Score_element*me)
67 Link_array<Score_element> ties =
68 Pointer_group_interface__extract_elements (me, (Score_element*)0, "ties");
71 Direction d = Directional_element_interface::get (me);
75 for (int i = ties.size (); i--;)
77 Score_element * t = ties[i];
78 Directional_element_interface::set (t, d);
83 if (ties.size () == 1)
85 Score_element * t = ties[0];
86 Directional_element_interface::set (t,Tie::get_default_dir (t));
90 ties.sort (tie_compare);
91 Directional_element_interface::set( ties[0], DOWN);
94 Directional_element_interface ::set(ties.pop (), UP);
95 for (int i=ties.size(); i--; )
97 Score_element * t = ties[i];
98 Real p = Tie::position_f (t);
99 Direction d = (Direction) sign (p);
102 Directional_element_interface::set (t, d);
107 MAKE_SCHEME_CALLBACK(Tie_column,after_line_breaking,1);
109 Tie_column::after_line_breaking (SCM smob)
111 set_directions (unsmob_element (smob));
112 return SCM_UNSPECIFIED;