]> git.donarmstrong.com Git - lilypond.git/blob - lily/spanner-scheme.cc
Web-ja: update introduction
[lilypond.git] / lily / spanner-scheme.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2007--2015 Han-Wen Nienhuys <hanwen@lilypond.org>
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 "spanner.hh"
22 #include "item.hh"
23
24 LY_DEFINE (ly_spanner_bound, "ly:spanner-bound",
25            2, 0, 0, (SCM spanner, SCM dir),
26            "Get one of the bounds of @var{spanner}.  @var{dir} is @w{@code{-1}}"
27            " for left, and @code{1} for right.")
28 {
29   LY_ASSERT_SMOB (Spanner, spanner, 1);
30   LY_ASSERT_TYPE (is_direction, dir, 2);
31   Item *bound = unsmob<Spanner> (spanner)->get_bound (to_dir (dir));
32   return bound ? bound->self_scm () : SCM_EOL;
33 }
34
35 LY_DEFINE (ly_spanner_set_bound_x, "ly:spanner-set-bound!",
36            3, 0, 0, (SCM spanner, SCM dir, SCM item),
37            "Set grob @var{item} as bound in direction @var{dir} for"
38            " @var{spanner}.")
39 {
40   LY_ASSERT_SMOB (Spanner, spanner, 1);
41   LY_ASSERT_TYPE (is_direction, dir, 2);
42   LY_ASSERT_SMOB (Item, item, 3);
43
44   unsmob<Spanner> (spanner)->set_bound (to_dir (dir), unsmob<Item> (item));
45   return SCM_UNSPECIFIED;
46 }
47
48 /* TODO: maybe we should return a vector -- random access is more
49    logical for this list? */
50 LY_DEFINE (ly_spanner_broken_into, "ly:spanner-broken-into",
51            1, 0, 0, (SCM spanner),
52            "Return broken-into list for @var{spanner}.")
53 {
54   LY_ASSERT_TYPE (unsmob<Spanner>, spanner, 1);
55   Spanner *me = unsmob<Spanner> (spanner);
56
57   SCM s = SCM_EOL;
58   for (vsize i = me->broken_intos_.size (); i--;)
59     s = scm_cons (me->broken_intos_[i]->self_scm (), s);
60   return s;
61 }
62
63 LY_DEFINE (ly_spanner_p, "ly:spanner?",
64            1, 0, 0, (SCM g),
65            "Is @var{g} a spanner object?")
66 {
67   Grob *me = unsmob<Grob> (g);
68   bool b = dynamic_cast<Spanner *> (me);
69
70   return ly_bool2scm (b);
71 }