]> git.donarmstrong.com Git - lilypond.git/blob - lily/laissez-vibrer-tie.cc
* The grand 2005-2006 replace.
[lilypond.git] / lily / laissez-vibrer-tie.cc
1 /*
2   laissez-vibrer-tie.cc -- implement Laissez_vibrer_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 "laissez-vibrer-tie-column.hh"
11 #include "laissez-vibrer-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(Laissez_vibrer_tie,
19               "laissez-vibrer-tie-interface",
20               "The interface for l.v. tie items.",
21
22               /* properties */
23               "control-points "
24               "direction "
25               "details "
26               "note-head "
27               "thickness "
28               "x-gap "
29               );
30
31 MAKE_SCHEME_CALLBACK(Laissez_vibrer_tie, calc_control_points, 1)
32 SCM
33 Laissez_vibrer_tie::calc_control_points (SCM smob)
34 {
35   Grob *me = unsmob_grob (smob);
36   if (Laissez_vibrer_tie_column::has_interface (me->get_parent (Y_AXIS)))
37     {
38       me->get_parent (Y_AXIS)->get_property ("positioning-done");
39     }
40   else
41     {
42       programming_error ("lv tie without Laissez_vibrer_tie_column. Killing lv tie."); 
43       me->suicide (); 
44     }
45   
46   return SCM_UNSPECIFIED;
47 }
48
49 MAKE_SCHEME_CALLBACK(Laissez_vibrer_tie, calc_direction, 1)
50 SCM
51 Laissez_vibrer_tie::calc_direction (SCM smob)
52 {
53   Grob *me = unsmob_grob (smob);
54   if (Laissez_vibrer_tie_column::has_interface (me->get_parent (Y_AXIS)))
55     me->get_parent (Y_AXIS)->get_property("positioning-done");
56   else
57     {
58       programming_error ("lv tie without Laissez_vibrer_tie_column"); 
59       set_grob_direction (me, UP);
60     }
61
62   return SCM_UNSPECIFIED;
63 }
64
65 int
66 Laissez_vibrer_tie::get_position (Grob *me)
67 {
68   Grob *h = unsmob_grob (me->get_object ("note-head"));
69   return (int) rint (Staff_symbol_referencer::get_position (h));
70 }
71
72 int
73 Laissez_vibrer_tie::compare (Grob *const &s1,
74                              Grob *const &s2)
75 {
76   return sign (get_position (s1) - get_position (s2));
77 }
78