]> git.donarmstrong.com Git - lilypond.git/blob - lily/semi-tie.cc
Issue 4961/3: Add ly:length, ly:directed, ly:angle
[lilypond.git] / lily / semi-tie.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2005--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "semi-tie-column.hh"
22 #include "semi-tie.hh"
23 #include "directional-element-interface.hh"
24 #include "grob.hh"
25 #include "paper-column.hh"
26 #include "tie.hh"
27 #include "warn.hh"
28 #include "staff-symbol-referencer.hh"
29
30 ADD_INTERFACE (Semi_tie,
31                "A tie which is only connected to a note head on one side."
32                "\n"
33                "The following properties may be set in the @code{details}"
34                " list:\n"
35                "\n"
36                "@table @code\n"
37                "@item height-limit\n"
38                "Maximum tie height: The longer the tie, the closer it is"
39                " to this height.\n"
40                "@item ratio\n"
41                "Parameter for tie shape.  The higher this number, the"
42                " quicker the tie attains its @code{height-limit}.\n"
43                "@end table\n",
44
45                /* properties */
46                "control-points "
47                "direction "
48                "details "
49                "head-direction "
50                "note-head "
51                "thickness "
52               );
53
54 MAKE_SCHEME_CALLBACK (Semi_tie, calc_control_points, 1)
55 SCM
56 Semi_tie::calc_control_points (SCM smob)
57 {
58   Item *me = LY_ASSERT_SMOB(Item, smob, 1);
59
60   (void) me->get_property ("direction");
61
62   Grob *yparent = me->get_parent (Y_AXIS);
63   if (has_interface<Semi_tie_column> (yparent))
64     {
65       /* trigger positioning. */
66       yparent->get_property ("positioning-done");
67
68       return me->get_property_data ("control-points");
69     }
70
71   programming_error ("lv tie without Semi_tie_column.  Killing lv tie.");
72   me->suicide ();
73   return SCM_EOL;
74 }
75
76 int
77 Semi_tie::get_column_rank (Item *me)
78 {
79   return Paper_column::get_rank (me->get_column ());
80 }
81
82 int
83 Semi_tie::get_position (Item *me)
84 {
85   return (int) rint (Staff_symbol_referencer::get_position (head (me)));
86 }
87
88 bool
89 Semi_tie::less (Grob *g1, Grob *g2)
90 {
91   Item *i1 = dynamic_cast<Item *> (g1);
92   if (!i1)
93     {
94       g1->programming_error ("grob is not a semi-tie");
95       return false;
96     }
97
98   Item *i2 = dynamic_cast<Item *> (g2);
99   if (!i2)
100     {
101       g2->programming_error ("grob is not a semi-tie");
102       return true;
103     }
104
105   return get_position (i1) < get_position (i2);
106 }
107
108 Item *
109 Semi_tie::head (Item *me)
110 {
111   return unsmob<Item> (me->get_object ("note-head"));
112 }