]> git.donarmstrong.com Git - lilypond.git/blob - lily/laissez-vibrer-tie.cc
* lily/paper-score.cc (find_break_indices): move from Break_algorithm.
[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               );
29
30 MAKE_SCHEME_CALLBACK(Laissez_vibrer_tie, calc_control_points, 1)
31 SCM
32 Laissez_vibrer_tie::calc_control_points (SCM smob)
33 {
34   Grob *me = unsmob_grob (smob);
35   if (Laissez_vibrer_tie_column::has_interface (me->get_parent (Y_AXIS)))
36     {
37       me->get_parent (Y_AXIS)->get_property ("positioning-done");
38     }
39   else
40     {
41       programming_error ("lv tie without Laissez_vibrer_tie_column. Killing lv tie."); 
42       me->suicide (); 
43     }
44   
45   return SCM_UNSPECIFIED;
46 }
47
48 MAKE_SCHEME_CALLBACK(Laissez_vibrer_tie, calc_direction, 1)
49 SCM
50 Laissez_vibrer_tie::calc_direction (SCM smob)
51 {
52   Grob *me = unsmob_grob (smob);
53   if (Laissez_vibrer_tie_column::has_interface (me->get_parent (Y_AXIS)))
54     me->get_parent (Y_AXIS)->get_property("positioning-done");
55   else
56     {
57       programming_error ("lv tie without Laissez_vibrer_tie_column"); 
58       set_grob_direction (me, UP);
59     }
60
61   return SCM_UNSPECIFIED;
62 }
63
64 int
65 Laissez_vibrer_tie::get_position (Grob *me)
66 {
67   Grob *h = unsmob_grob (me->get_object ("note-head"));
68   return (int) rint (Staff_symbol_referencer::get_position (h));
69 }
70
71 int
72 Laissez_vibrer_tie::compare (Grob *const &s1,
73                              Grob *const &s2)
74 {
75   return sign (get_position (s1) - get_position (s2));
76 }
77