]> git.donarmstrong.com Git - lilypond.git/blob - lily/paper-system.cc
5f5e1702c965bfb425953d49cd5334a3c1aa3cab
[lilypond.git] / lily / paper-system.cc
1 /*
2   paper-system.cc -- implement Paper_system
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2004--2005 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "paper-system.hh"
10 #include "item.hh"
11
12 #include "ly-smobs.icc"
13
14 IMPLEMENT_SMOBS (Paper_system);
15 IMPLEMENT_TYPE_P (Paper_system, "ly:paper-system?");
16 IMPLEMENT_DEFAULT_EQUAL_P (Paper_system);
17
18 Paper_system::Paper_system (Stencil s, bool is_title)
19 {
20   is_title_ = is_title;
21   number_ = 0;
22   break_before_penalty_ = 0;
23   smobify_self ();
24   stencil_ = s;
25   staff_refpoints_ = Interval (0, 0);
26 }
27
28 Paper_system::~Paper_system ()
29 {
30 }
31
32 SCM
33 Paper_system::mark_smob (SCM smob)
34 {
35   Paper_system *system = (Paper_system *) SCM_CELL_WORD_1 (smob);
36   return system->stencil_.expr ();
37 }
38
39 int
40 Paper_system::print_smob (SCM smob, SCM port, scm_print_state*)
41 {
42   Paper_system *p = (Paper_system *) SCM_CELL_WORD_1 (smob);
43   scm_puts ("#<", port);
44   scm_puts (classname (p), port);
45   scm_puts ("n ", port);
46   scm_puts (to_string (p->number_).to_str0 (), port);
47   scm_puts (", p ", port);
48   scm_puts (to_string (p->break_before_penalty_).to_str0 (), port);
49   if (p->is_title ())
50     scm_puts (" t", port);
51   scm_puts (" >", port);
52   return 1;
53 }
54
55 bool
56 Paper_system::is_title () const
57 {
58   return is_title_;
59 }
60
61 Real
62 Paper_system::break_before_penalty () const
63 {
64   return break_before_penalty_;
65 }
66
67 Stencil
68 Paper_system::to_stencil () const
69 {
70   return stencil_;
71 }
72
73 void
74 Paper_system::read_left_bound (Item *left)
75 {
76   break_before_penalty_
77     = robust_scm2double (left->get_property ("page-penalty"), 0.0);
78
79   SCM details
80     = left->get_property ("line-break-system-details");
81
82   SCM yext
83     = scm_assoc (ly_symbol2scm ("Y-extent"), details);
84   
85   SCM staff_ext
86     = scm_assoc (ly_symbol2scm ("refpoint-Y-extent"), details);
87
88   if (scm_is_pair (yext)
89       && is_number_pair (scm_cdr (yext)))
90     {
91       Box b = stencil_.extent_box();
92       b[Y_AXIS] = ly_scm2interval (scm_cdr (yext));
93       
94       stencil_ = Stencil (b, stencil_.expr ());
95     }
96
97   if (scm_is_pair (staff_ext)
98       && is_number_pair (scm_cdr (staff_ext)))
99     {
100       staff_refpoints_ = ly_scm2interval (scm_cdr (staff_ext));
101     }
102 }
103
104 Interval
105 Paper_system::staff_refpoints () const
106 {
107   return staff_refpoints_;
108 }