]> git.donarmstrong.com Git - lilypond.git/blob - lily/skyline-pair.cc
Doc-fr: update for 2.16.1 (second part)
[lilypond.git] / lily / skyline-pair.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2008--2012 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 "skyline-pair.hh"
22
23 #include "international.hh"
24 #include "ly-smobs.icc"
25
26 Skyline_pair::Skyline_pair ()
27   : skylines_ (Skyline (DOWN), Skyline (UP))
28 {
29 }
30
31 Skyline_pair::Skyline_pair (vector<Box> const &boxes, Real padding, Axis a)
32   : skylines_ (Skyline (boxes, padding, a, DOWN), Skyline (boxes, padding, a, UP))
33 {
34 }
35
36 Skyline_pair::Skyline_pair (Box const &b, Real padding, Axis a)
37   : skylines_ (Skyline (b, padding, a, DOWN), Skyline (b, padding, a, UP))
38 {
39 }
40
41 void
42 Skyline_pair::raise (Real r)
43 {
44   skylines_[UP].raise (r);
45   skylines_[DOWN].raise (r);
46 }
47
48 void
49 Skyline_pair::shift (Real r)
50 {
51   skylines_[UP].shift (r);
52   skylines_[DOWN].shift (r);
53 }
54
55 void
56 Skyline_pair::insert (Box const &b, Real padding, Axis a)
57 {
58   skylines_[UP].insert (b, padding, a);
59   skylines_[DOWN].insert (b, padding, a);
60 }
61
62 void
63 Skyline_pair::merge (Skyline_pair const &other)
64 {
65   skylines_[UP].merge (other[UP]);
66   skylines_[DOWN].merge (other[DOWN]);
67 }
68
69 void
70 Skyline_pair::print () const
71 {
72   skylines_[UP].print ();
73   skylines_[DOWN].print ();
74 }
75
76 void
77 Skyline_pair::print_points () const
78 {
79   skylines_[UP].print ();
80   skylines_[DOWN].print ();
81 }
82
83 bool
84 Skyline_pair::is_empty () const
85 {
86   return skylines_[UP].is_empty ()
87          && skylines_[DOWN].is_empty ();
88 }
89
90 Skyline &
91 Skyline_pair::operator [] (Direction d)
92 {
93   return skylines_[d];
94 }
95
96 Skyline const &
97 Skyline_pair::operator [] (Direction d) const
98 {
99   return skylines_[d];
100 }
101
102 IMPLEMENT_SIMPLE_SMOBS (Skyline_pair);
103 IMPLEMENT_TYPE_P (Skyline_pair, "ly:skyline-pair?");
104 IMPLEMENT_DEFAULT_EQUAL_P (Skyline_pair);
105
106 SCM
107 Skyline_pair::mark_smob (SCM)
108 {
109   return SCM_EOL;
110 }
111
112 int
113 Skyline_pair::print_smob (SCM s, SCM port, scm_print_state *)
114 {
115   Skyline_pair *r = (Skyline_pair *) SCM_CELL_WORD_1 (s);
116   (void) r;
117
118   scm_puts ("#<Skyline-pair>", port);
119   return 1;
120 }
121
122 MAKE_SCHEME_CALLBACK (Skyline_pair, skyline, 2);
123 SCM
124 Skyline_pair::skyline (SCM smob, SCM dir_scm)
125 {
126   Skyline_pair *sp = Skyline_pair::unsmob (smob);
127   Direction dir = robust_scm2dir (dir_scm, UP);
128
129   if (dir == CENTER)
130     {
131       warning (_f ("direction must not be CENTER in ly:skyline-pair::skyline"));
132       dir = UP;
133     }
134
135   return (*sp)[dir].smobbed_copy ();
136 }