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 (Grob
*me
)
22 me
->set_interface (ly_symbol2scm ("tie-column-interface"));
23 me
->set_extent_callback (SCM_EOL
, X_AXIS
);
24 me
->set_extent_callback (SCM_EOL
, Y_AXIS
) ;
28 Tie_column::has_interface (Grob
*me
)
30 return me
->has_interface (ly_symbol2scm ("tie-column-interface"));
35 tie dir depends on what Tie_column does.
39 Tie_column::add_tie (Grob
*me
,Grob
*s
)
41 if (! Pointer_group_interface ::count (me
, "ties"))
43 dynamic_cast<Spanner
*> (me
)->set_bound (LEFT
, Tie::head (s
,LEFT
));
44 dynamic_cast<Spanner
*> (me
)->set_bound (RIGHT
, Tie::head (s
,RIGHT
));
47 Pointer_group_interface::add_element (me
, "ties",s
);
48 s
->add_dependency (me
);
53 tie_compare (Grob
* const & s1
,
56 return sign (Tie::position_f (s1
) - Tie::position_f(s2
));
63 In normal chord cases, the outer ties point outwards, and the
64 direction of the rest is determined by their staff position.
66 Ross forgets about the tie that is *on* the middle staff line. We
67 assume it goes UP. (TODO: make me settable) */
69 Tie_column::set_directions (Grob
*me
)
71 Link_array
<Grob
> ties
=
72 Pointer_group_interface__extract_elements (me
, (Grob
*)0, "ties");
74 for (int i
= ties
.size (); i
--; )
75 if (Directional_element_interface::get (ties
[i
]))
83 Direction d
= Directional_element_interface::get (me
);
86 for (int i
= ties
.size (); i
--;)
89 Directional_element_interface::set (t
, d
);
94 if (ties
.size () == 1)
97 Directional_element_interface::set (t
,Tie::get_default_dir (t
));
101 ties
.sort (tie_compare
);
102 Directional_element_interface::set( ties
[0], DOWN
);
105 Directional_element_interface ::set(ties
.pop (), UP
);
106 for (int i
=ties
.size(); i
--; )
109 Real p
= Tie::position_f (t
);
110 Direction d
= (Direction
) sign (p
);
113 Directional_element_interface::set (t
, d
);
118 MAKE_SCHEME_CALLBACK(Tie_column
,after_line_breaking
,1);
120 Tie_column::after_line_breaking (SCM smob
)
122 set_directions (unsmob_grob (smob
));
123 return SCM_UNSPECIFIED
;