]> git.donarmstrong.com Git - lilypond.git/blob - lily/grid-line-interface.cc
Web-ja: update introduction
[lilypond.git] / lily / grid-line-interface.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   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "grid-line-interface.hh"
21
22 #include "grob.hh"
23 #include "pointer-group-interface.hh"
24 #include "lookup.hh"
25 #include "output-def.hh"
26
27 MAKE_SCHEME_CALLBACK (Grid_line_interface, print, 1);
28 SCM
29 Grid_line_interface::print (SCM smobbed_me)
30 {
31   Grob *me = unsmob<Grob> (smobbed_me);
32
33   extract_grob_set (me, "elements", elts);
34   /* compute common refpoint of elements */
35   Grob *refp = common_refpoint_of_array (elts, me, Y_AXIS);
36   Interval iv;
37
38   for (vsize i = 0; i < elts.size (); i++)
39     {
40       Grob *point = elts[i];
41
42       iv.unite (point->extent (refp, Y_AXIS));
43     }
44
45   if (iv.is_empty ())
46     {
47       me->suicide ();
48       return SCM_EOL;
49     }
50
51   Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
52   Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
53                * staffline;
54
55   iv += -me->relative_coordinate (refp, Y_AXIS);
56   Stencil st = Lookup::filled_box (Box (Interval (0, thick),
57                                         iv));
58
59   return st.smobbed_copy ();
60 }
61
62 MAKE_SCHEME_CALLBACK (Grid_line_interface, width, 1);
63 SCM
64 Grid_line_interface::width (SCM smob)
65 {
66   Grob *me = unsmob<Grob> (smob);
67
68   Real staffline = me->layout ()->get_dimension (ly_symbol2scm ("line-thickness"));
69   Real thick = robust_scm2double (me->get_property ("thickness"), 1.0)
70                * staffline;
71
72   return ly_interval2scm (Interval (0, thick));
73 }
74
75 void
76 Grid_line_interface::add_grid_point (Grob *me, Grob *b)
77 {
78   Pointer_group_interface::add_grob (me, ly_symbol2scm ("elements"), b);
79 }
80
81 ADD_INTERFACE (Grid_line_interface,
82                "A line that is spanned between grid-points.",
83
84                /* properties */
85                "elements "
86                "thickness "
87               );
88
89 ADD_INTERFACE (Grid_point_interface,
90                "A spanning point for grid lines.",
91
92                /* properties */
93                ""
94               );