* lily/paper-book.cc: remove copyright & tagline. Remove
[lilypond.git] / lily / break-algorithm.cc
blob72d7021e9555fdc25612a6f9b399e65bd5bf4af5
1 /*
2 break.cc -- implement Break_algorithm
4 source file of the GNU LilyPond music typesetter
6 (c) 1996--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "paper-column.hh"
10 #include "break-algorithm.hh"
11 #include "output-def.hh"
12 #include "system.hh"
13 #include "paper-score.hh"
14 #include "paper-column.hh"
15 #include "cpu-timer.hh"
17 #include "simple-spacer.hh"
18 #include "group-interface.hh"
21 Array<int>
22 Break_algorithm::find_break_indices () const
24 Link_array<Grob> all = pscore_->system_->columns ();
25 Array<int> retval;
27 for (int i=0; i < all.size (); i++)
28 if (Item::is_breakable (all[i]))
29 retval.push (i);
31 if (linewidth_ <=0)
32 while (retval.size () >2)
33 retval.del (1);
35 return retval;
39 Link_array<Grob>
40 Break_algorithm::find_breaks () const
42 Link_array<Grob> all = pscore_->system_->columns ();
43 Link_array<Grob> retval;
45 for (int i=0; i < all.size (); i++)
46 if (Item::is_breakable (all[i]))
47 retval.push (all[i]);
49 if (linewidth_ <=0)
50 while (retval.size () >2)
51 retval.del (1);
53 return retval;
57 Simple_spacer*
58 Break_algorithm::generate_spacing_problem (Link_array<Grob> const &curline,
59 Interval line) const
61 Simple_spacer * sp = new Simple_spacer;
64 this is hardcoded, but this shouldn't happen anyway.
65 used to be get_dimension (ly_symbol2scm ("loose_column_distance"));
67 sp->default_space_ = 1.0;
70 sp->indent_ = line[LEFT];
73 sort out how interfacing this should work;
75 if (line.is_empty ())
77 sp->line_len_ = -1;
79 else
80 sp->line_len_ = line.length ();
82 sp->add_columns (curline);
85 return sp;
88 Break_algorithm::Break_algorithm ()
90 pscore_ = 0;
91 linewidth_ = 0;
94 void
95 Break_algorithm::set_pscore (Paper_score*s)
97 pscore_ = s;
98 linewidth_ = s->paper_->get_dimension (ly_symbol2scm ("linewidth"));
101 Array<Column_x_positions>
102 Break_algorithm::solve () const
104 Array<Column_x_positions> h= do_solve ();
106 return h;