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>
11 #include "tie-column.hh"
12 #include "group-interface.hh"
14 #include "directional-element-interface.hh"
15 #include "rhythmic-head.hh"
23 tie dir depends on what Tie_column does.
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
);
41 tie_compare (Grob
* const & s1
,
44 return sign (Tie::get_position (s1
) - Tie::get_position (s2
));
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) */
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
]))
71 Direction d
= Directional_element_interface::get (me
);
74 for (int i
= ties
.size (); i
--;)
77 Directional_element_interface::set (t
, d
);
82 if (ties
.size () == 1)
85 Directional_element_interface::set (t
,Tie::get_default_dir (t
));
89 ties
.sort (tie_compare
);
90 Directional_element_interface::set (ties
[0], DOWN
);
93 Directional_element_interface ::set (ties
.pop (), UP
);
94 for (int i
=ties
.size (); i
--;)
97 Real p
= Tie::get_position (t
);
98 Direction d
= (Direction
) sign (p
);
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",