]> git.donarmstrong.com Git - lilypond.git/blob - lily/column-description.cc
Fix compilation warning.
[lilypond.git] / lily / column-description.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2011 Mike Solomon <mike@apollinemike.com>
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 <cstdio>
21
22 #include "column-description.hh"
23 #include "paper-column.hh"
24 #include "simple-spacer.hh"
25 #include "spaceable-grob.hh"
26 #include "spring.hh"
27
28 static Grob *
29 next_spaceable_column (vector<Grob *> const &list, vsize starting)
30 {
31   for (vsize i = starting + 1; i < list.size (); i++)
32     if (!Paper_column::is_loose (list[i]))
33       return list[i];
34   return 0;
35 }
36
37 Column_description
38 Column_description::get_column_description (vector<Grob *> const &cols, vsize col_index, bool line_starter)
39 {
40   Grob *col = cols[col_index];
41   if (line_starter)
42     col = Item::maybe_find_prebroken_piece (dynamic_cast<Item *> (col), RIGHT);
43
44   Column_description description;
45   Grob *next_col = next_spaceable_column (cols, col_index);
46   if (next_col)
47     description.spring_ = Spaceable_grob::get_spring (col, next_col);
48
49   Grob *end_col = dynamic_cast<Item *> (cols[col_index + 1])->find_prebroken_piece (LEFT);
50   if (end_col)
51     description.end_spring_ = Spaceable_grob::get_spring (col, end_col);
52
53   for (SCM s = Spaceable_grob::get_minimum_distances (col);
54        scm_is_pair (s); s = scm_cdr (s))
55     {
56       Grob *other = unsmob_grob (scm_caar (s));
57       vsize j = binary_search (cols, other, Paper_column::less_than, col_index);
58       if (j != VPOS)
59         {
60           if (cols[j] == other)
61             description.rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s))));
62           else /* it must end at the LEFT prebroken_piece */
63             description.end_rods_.push_back (Rod_description (j, scm_to_double (scm_cdar (s))));
64         }
65     }
66
67   if (!line_starter && to_boolean (col->get_property ("keep-inside-line")))
68     description.keep_inside_line_ = col->extent (col, X_AXIS);
69
70   description.break_permission_ = col->get_property ("line-break-permission");
71   return description;
72 }