summaryrefslogtreecommitdiff
path: root/lily/minimal-page-breaking.cc
blob: 968c4bf9b705858e6f1afafb583674c8c8fff054 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
  This file is part of LilyPond, the GNU music typesetter.

  Copyright (C) 2007--2015 Nicolas Sceaux <nicolas.sceaux@free.fr>

  LilyPond is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

  LilyPond is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
*/

#include "international.hh"
#include "minimal-page-breaking.hh"
#include "output-def.hh"
#include "page-spacing.hh"
#include "paper-book.hh"

Minimal_page_breaking::Minimal_page_breaking (Paper_book *pb)
  : Page_breaking (pb, 0, 0)
{
}

Minimal_page_breaking::~Minimal_page_breaking ()
{
}

SCM
Minimal_page_breaking::solve ()
{
  vsize end = last_break_position ();

  message (_ ("Calculating line breaks..."));
  set_to_ideal_line_configuration (0, end);
  break_into_pieces (0, end, current_configuration (0));

  message (_ ("Calculating page breaks..."));
  vsize first_page_num = robust_scm2int (book_->paper_->c_variable ("first-page-number"), 1);
  Page_spacing_result res = pack_systems_on_least_pages (0, first_page_num);
  SCM lines = systems ();
  return make_pages (res.systems_per_page_, lines);
}