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