]> git.donarmstrong.com Git - lilypond.git/blob - lily/semi-tie.cc
fbc98f20aa1db6eb6ce1c1a094c8cb4a44bc06bc
[lilypond.git] / lily / semi-tie.cc
1 /*
2   semi-tie.cc -- implement Semi_tie
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "semi-tie-column.hh"
11 #include "semi-tie.hh"
12 #include "directional-element-interface.hh"
13 #include "grob.hh"
14 #include "tie.hh"
15 #include "warn.hh"
16 #include "staff-symbol-referencer.hh"
17
18 ADD_INTERFACE(Semi_tie,
19               
20               "semi-tie-interface",
21               
22               "A tie which is only on one side connected to note heads. ",
23
24               /* properties */
25               "control-points "
26               "direction "
27               "details "
28               "note-head "
29               "thickness "
30               );
31
32 MAKE_SCHEME_CALLBACK(Semi_tie, calc_control_points, 1)
33 SCM
34 Semi_tie::calc_control_points (SCM smob)
35 {
36   Grob *me = unsmob_grob (smob);
37   if (Semi_tie_column::has_interface (me->get_parent (Y_AXIS)))
38     {
39       me->get_parent (Y_AXIS)->get_property ("positioning-done");
40     }
41   else
42     {
43       programming_error ("lv tie without Semi_tie_column. Killing lv tie."); 
44       me->suicide (); 
45     }
46   
47   return SCM_UNSPECIFIED;
48 }
49
50 MAKE_SCHEME_CALLBACK(Semi_tie, calc_direction, 1)
51 SCM
52 Semi_tie::calc_direction (SCM smob)
53 {
54   Grob *me = unsmob_grob (smob);
55   if (Semi_tie_column::has_interface (me->get_parent (Y_AXIS)))
56     me->get_parent (Y_AXIS)->get_property("positioning-done");
57   else
58     {
59       programming_error ("lv tie without Semi_tie_column"); 
60       set_grob_direction (me, UP);
61     }
62
63   return SCM_UNSPECIFIED;
64 }
65
66 int
67 Semi_tie::get_position (Grob *me)
68 {
69   Grob *h = unsmob_grob (me->get_object ("note-head"));
70   return (int) rint (Staff_symbol_referencer::get_position (h));
71 }
72
73 bool
74 Semi_tie::less (Grob *const &s1,
75                 Grob *const &s2)
76 {
77   return get_position (s1) < get_position (s2);
78 }
79