]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-system.cc
apply Julian's patch to fix install-info warnings
[lilypond.git] / lily / paper-system.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2004--2011 Jan Nieuwenhuizen <janneke@gnu.org>
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 "paper-system.hh"
21 #include "item.hh"
22
23 Prob *
24 make_paper_system (SCM immutable_init)
25 {
26   Prob *prob = new Prob (ly_symbol2scm ("paper-system"), immutable_init);
27   return prob;
28 }
29
30 /*
31   TODO
32   it might be interesting to split off the footnotes as well, ie.
33   
34   get_footnotes(SCM expr, SCM* footnotes, SCM* cleaned) 
35     
36   by doing it this way and overwriting the old expr in the caller,
37   you can make sure nobody tries to handle footnotes differently
38   downstream.
39 */
40 SCM
41 get_footnotes (SCM expr)
42 {
43   if (!scm_is_pair (expr))
44     return SCM_EOL;
45
46   SCM head = scm_car (expr);
47
48   if (head == ly_symbol2scm ("delay-stencil-evaluation"))
49     {
50       // we likely need to do something here...just don't know what...
51       return SCM_EOL;
52     }
53   
54   if (head == ly_symbol2scm ("combine-stencil"))
55     {
56       SCM out = SCM_EOL;
57       SCM *tail = &out;
58
59       for (SCM x = scm_cdr (expr); scm_is_pair (x); x = scm_cdr (x))
60         {
61           SCM footnote = get_footnotes (scm_car (x));
62           if (scm_is_pair (footnote))
63             {
64               for (SCM y = footnote; scm_is_pair (y); y = scm_cdr (y))
65                 {
66                   *tail = scm_cons (scm_car (y), SCM_EOL);
67                   tail = SCM_CDRLOC (*tail);
68                 }
69             }
70           else if (SCM_EOL != footnote)
71             {
72               *tail = scm_cons (footnote, SCM_EOL);
73               tail = SCM_CDRLOC (*tail);
74             }
75         }
76       return out;
77     }
78   if (head == ly_symbol2scm ("translate-stencil"))
79     return get_footnotes (scm_caddr (expr));
80
81   if (head == ly_symbol2scm ("footnote"))
82     return scm_cadr (expr);
83
84   return SCM_EOL;
85 }
86
87
88 void
89 paper_system_set_stencil (Prob *prob, Stencil s)
90 {
91   SCM yext = prob->get_property ("Y-extent");
92
93   if (is_number_pair (yext))
94     {
95       Box b = s.extent_box ();
96       b[Y_AXIS] = ly_scm2interval (yext);
97
98       s = Stencil (b, s.expr ());
99     }
100
101   prob->set_property ("stencil", s.smobbed_copy ());
102 }