X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fconstrained-breaking.cc;h=f6f84b80907714907d218525deb8c868a95f397e;hb=72daeab460833e7e46c346a3e377b195674ef9c9;hp=e82397f653364f2b08be397f613950f373632eca;hpb=9171fc87b5b9693865339578be6ae00d1c536b3b;p=lilypond.git diff --git a/lily/constrained-breaking.cc b/lily/constrained-breaking.cc index e82397f653..f6f84b8090 100644 --- a/lily/constrained-breaking.cc +++ b/lily/constrained-breaking.cc @@ -1,7 +1,7 @@ /* This file is part of LilyPond, the GNU music typesetter. - Copyright (C) 2006--2010 Joe Neeman + Copyright (C) 2006--2011 Joe Neeman LilyPond is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -380,17 +380,8 @@ Constrained_breaking::initialize () ragged_right_ = to_boolean (pscore_->layout ()->c_variable ("ragged-right")); ragged_last_ = to_boolean (pscore_->layout ()->c_variable ("ragged-last")); - /* NOTE: currently, we aren't using the space_ field of a - Line_details for anything. That's because the approximations - used for scoring a page configuration don't actually space things - properly (for speed reasons) using springs anchored at the staff - refpoints. Rather, the "space" is placed between the extent - boxes. To get a good result, therefore, the "space" value for - page breaking needs to be much smaller than the "space" value for - page layout. Currently, we just make it zero always, which means - that we will always prefer a tighter vertical layout. - */ system_system_space_ = 0; + system_markup_space_ = 0; system_system_padding_ = 0; system_system_min_distance_ = 0; score_system_padding_ = 0; @@ -404,6 +395,17 @@ Constrained_breaking::initialize () SCM between_scores_spec = l->c_variable ("score-system-spacing"); SCM title_spec = l->c_variable ("score-markup-spacing"); SCM page_breaking_spacing_spec = l->c_variable ("page-breaking-system-system-spacing"); + + Page_layout_problem::read_spacing_spec (spacing_spec, + &system_system_space_, + ly_symbol2scm ("basic-distance")); + Page_layout_problem::read_spacing_spec (page_breaking_spacing_spec, + &system_system_space_, + ly_symbol2scm ("basic-distance")); + Page_layout_problem::read_spacing_spec (title_spec, + &system_markup_space_, + ly_symbol2scm ("basic-distance")); + Page_layout_problem::read_spacing_spec (spacing_spec, &system_system_padding_, ly_symbol2scm ("padding")); @@ -416,6 +418,7 @@ Constrained_breaking::initialize () Page_layout_problem::read_spacing_spec (title_spec, &score_markup_padding_, ly_symbol2scm ("padding")); + Page_layout_problem::read_spacing_spec (between_scores_spec, &score_system_min_distance_, ly_symbol2scm ("minimum-distance")); @@ -508,13 +511,19 @@ Constrained_breaking::fill_line_details (Line_details *const out, vsize start, v || isnan (rest_of_line_extent[RIGHT])) ? Interval (0, 0) : rest_of_line_extent; out->shape_ = Line_shape (begin_of_line_extent, rest_of_line_extent); - out->refpoint_extent_ = sys->pure_refpoint_extent (start_rank, end_rank); out->padding_ = last ? score_system_padding_ : system_system_padding_; out->title_padding_ = score_markup_padding_; out->min_distance_ = last ? score_system_min_distance_ : system_system_min_distance_; out->title_min_distance_ = score_markup_min_distance_; out->space_ = system_system_space_; + out->title_space_ = system_markup_space_; out->inverse_hooke_ = out->full_height () + system_system_space_; + + out->footnotes_ = sys->get_footnotes_in_range (start_rank, end_rank); + + out->refpoint_extent_ = sys->pure_refpoint_extent (start_rank, end_rank); + if (out->refpoint_extent_.is_empty ()) + out->refpoint_extent_ = Interval (0, 0); } Real @@ -534,18 +543,26 @@ Line_details::Line_details (Prob *pb, Output_def *paper) title_padding_ = 0; min_distance_ = 0; title_min_distance_ = 0; + space_ = 0; + title_space_ = 0; + Page_layout_problem::read_spacing_spec (spec, &space_, ly_symbol2scm ("basic-distance")); + Page_layout_problem::read_spacing_spec (title_spec, &title_space_, ly_symbol2scm ("basic-distance")); Page_layout_problem::read_spacing_spec (spec, &padding_, ly_symbol2scm ("padding")); Page_layout_problem::read_spacing_spec (title_spec, &title_padding_, ly_symbol2scm ("padding")); Page_layout_problem::read_spacing_spec (spec, &min_distance_, ly_symbol2scm ("minimum-distance")); Page_layout_problem::read_spacing_spec (title_spec, &title_min_distance_, ly_symbol2scm ("minimum-distance")); + SCM footnotes = pb->get_property ("footnotes"); + if (scm_is_pair (footnotes)) + for (SCM s = footnotes; scm_is_pair (s); s = scm_cdr (s)) + footnotes_.push_back (unsmob_stencil (scm_car (s))); + last_column_ = 0; force_ = 0; Interval stencil_extent = unsmob_stencil (pb->get_property ("stencil"))->extent (Y_AXIS); shape_ = Line_shape (stencil_extent, stencil_extent); // pretend it goes all the way across tallness_ = 0; bottom_padding_ = 0; - space_ = 0.0; inverse_hooke_ = 1.0; break_permission_ = ly_symbol2scm ("allow"); page_permission_ = pb->get_property ("page-break-permission"); @@ -561,6 +578,7 @@ Line_details::Line_details (Prob *pb, Output_def *paper) SCM first_scm = pb->get_property ("first-markup-line"); first_markup_line_ = to_boolean (first_scm); tight_spacing_ = to_boolean (pb->get_property ("tight-spacing")); + refpoint_extent_ = Interval (0, 0); } Real @@ -578,6 +596,18 @@ Line_details::tallness () const return tallness_; } +Real +Line_details::spring_length (Line_details const &next_line) const +{ + // space_ measures the spring which goes from the bottom refpoint + // of this to the top refpoint of next_line. We want to return + // the stretchable space between the bottom of this's extent to + // the top of next_line's extent. + Real refpoint_dist = tallness_ + refpoint_extent_[DOWN] - next_line.refpoint_extent_[UP]; + Real space = next_line.title_ ? title_space_ : space_; + return max (0.0, space - refpoint_dist); +} + Line_shape::Line_shape (Interval begin, Interval rest) { begin_ = begin;