Include fixed spacings in the calculation of minimum spacings.
reverse (*ret);
}
+// If include_fixed_spacing is true, the manually fixed spacings
+// induced by stretchable=0 or alignment-distances are included
+// in the minimum translations here. If you want to find the minimum
+// height of a system, include_fixed_spacing should be true. If you
+// want to actually lay out the page, then it should be false (or
+// else centered dynamics will break when there is a fixed alignment).
vector<Real>
Align_interface::get_minimum_translations (Grob *me,
vector<Grob*> const &all_grobs,
Axis a,
+ bool include_fixed_spacing,
bool pure, int start, int end)
{
if (!pure && a == Y_AXIS && dynamic_cast<Spanner*> (me) && !me->get_system ())
Skyline down_skyline (stacking_dir);
Real last_spaceable_element_pos = 0;
Grob *last_spaceable_element = 0;
+ int spaceable_count = 0;
for (vsize j = 0; j < elems.size (); j++)
{
Real dy = 0;
if (Page_layout_problem::read_spacing_spec (spec, &min_distance, ly_symbol2scm ("minimum-distance")))
dy = max (dy, min_distance);
+ if (include_fixed_spacing)
+ dy = max (dy, Page_layout_problem::get_fixed_spacing (elems[j-1], elems[j], spaceable_count, pure, start, end));
+
if (Page_layout_problem::is_spaceable (elems[j]) && last_spaceable_element)
{
- // Spaceable staves may have min-distance and padding
+ // Spaceable staves may have
// constraints coming from the previous spaceable staff
// as well as from the previous staff.
spec = Page_layout_problem::get_spacing_spec (last_spaceable_element, elems[j], pure, start, end);
&min_distance,
ly_symbol2scm ("minimum-distance")))
dy = max (dy, min_distance + stacking_dir*(last_spaceable_element_pos - where));
+
+ if (include_fixed_spacing)
+ dy = max (dy, Page_layout_problem::get_fixed_spacing (last_spaceable_element, elems[j], spaceable_count,
+ pure, start, end));
}
}
if (Page_layout_problem::is_spaceable (elems[j]))
{
+ spaceable_count++;
last_spaceable_element = elems[j];
last_spaceable_element_pos = where;
}
{
extract_grob_set (me, "elements", all_grobs);
- vector<Real> translates = get_minimum_translations (me, all_grobs, a, false, 0, 0);
+ vector<Real> translates = get_minimum_translations (me, all_grobs, a, true, false, 0, 0);
if (translates.size ())
for (vsize j = 0; j < all_grobs.size (); j++)
all_grobs[j]->translate_axis (translates[j], a);
Align_interface::get_pure_child_y_translation (Grob *me, Grob *ch, int start, int end)
{
extract_grob_set (me, "elements", all_grobs);
- vector<Real> translates = get_minimum_translations (me, all_grobs, Y_AXIS, true, start, end);
+ vector<Real> translates = get_minimum_translations (me, all_grobs, Y_AXIS, true, true, start, end);
if (translates.size ())
{
return 0;
}
+/* This version of get_system is more reliable than this->get_system ()
+ before line-breaking has been done, at which point there is only
+ one system in the whole score and we can find it just by following
+ parent pointers. */
+System *
+Grob::get_system(Grob *me)
+{
+ Grob *p = me->get_parent (X_AXIS);
+ return p ? get_system (p) : dynamic_cast<System *>(me);
+}
void
Grob::handle_broken_dependencies ()
static void align_elements_to_ideal_distances(Grob *);
static vector<Real> get_minimum_translations (Grob *, vector<Grob*> const&,
Axis a,
- bool safe, int start, int end);
+ bool include_fixed_spacing,
+ bool pure, int start, int end);
static void set_ordered (Grob *);
static Axis axis (Grob *);
static void add_element (Grob *, Grob *);
/* class hierarchy */
virtual System *get_system () const;
+ static System *get_system (Grob *);
virtual void do_break_processing ();
virtual Grob *find_broken_piece (System *) const;
virtual void discretionary_processing ();
static bool is_spaceable (Grob *g);
static SCM get_details (Grob *g);
static SCM get_spacing_spec (Grob *before, Grob *after, bool pure, int start, int end);
+ static Real get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end);
protected:
void append_system (System*, Spring const&, Real padding);
Paper_score *paper_score () const;
Grob *get_vertical_alignment ();
Grob *get_extremal_staff (Direction dir, Interval const&);
+ Grob *get_pure_bound (Direction dir, int start, int end);
+ Grob *get_maybe_pure_bound (Direction dir, bool pure, int start, int end);
int get_rank () const;
void do_break_substitution_and_fixup_refpoints ();
void post_processing ();
extract_grob_set (align, "elements", all_elts);
vector<Grob*> elts = filter_dead_elements (all_elts);
- vector<Real> minimum_offsets = Align_interface::get_minimum_translations (align, elts, Y_AXIS,
+ vector<Real> minimum_offsets = Align_interface::get_minimum_translations (align, elts, Y_AXIS, false,
false, 0, 0);
Skyline up_skyline (UP);
return false;
}
+// If there is a forced, fixed spacing between BEFORE and AFTER, return it.
+// Otherwise, return -infinity_f.
+// If after is spaceable, it is the (spaceable_index + 1)th spaceable grob in
+// its alignment.
+Real
+Page_layout_problem::get_fixed_spacing (Grob *before, Grob *after, int spaceable_index, bool pure, int start, int end)
+{
+ SCM spec = Page_layout_problem::get_spacing_spec (before, after, pure, start, end);
+ Real ret = -infinity_f;
+ Real stretchability = 0;
+ if (Page_layout_problem::read_spacing_spec (spec, &stretchability, ly_symbol2scm ("stretchability"))
+ && stretchability == 0)
+ Page_layout_problem::read_spacing_spec (spec, &ret, ly_symbol2scm ("space"));
+
+ // If we're pure, then paper-columns have not had their systems set,
+ // and so elts[i]->get_system () is unreliable.
+ System *sys = pure ? Grob::get_system (before) : before->get_system ();
+ Grob *left_bound = sys ? sys->get_maybe_pure_bound (LEFT, pure, start, end) : 0;
+
+ if (is_spaceable (before) && is_spaceable (after) && left_bound)
+ {
+ SCM details = left_bound->get_property ("line-break-system-details");
+ SCM manual_dists = ly_assoc_get (ly_symbol2scm ("alignment-distances"), details, SCM_EOL);
+ if (scm_is_pair (manual_dists))
+ {
+ SCM forced = robust_list_ref (spaceable_index - 1, manual_dists);
+ if (scm_is_number (forced))
+ ret = max (ret, scm_to_double (forced));
+ }
+ }
+ return ret;
+}
+
static SCM
add_stretchability (SCM alist, Real stretch)
{
return Interval ();
extract_grob_set (alignment, "elements", staves);
- vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, start, end);
+ vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, true, start, end);
for (vsize i = 0; i < offsets.size (); ++i)
if (Page_layout_problem::is_spaceable (staves[i]))
return Interval ();
extract_grob_set (alignment, "elements", staves);
- vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, start, end);
+ vector<Real> offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, true, start, end);
Interval ret;
for (vsize i = 0; i < staves.size (); ++i)
return ly_interval2scm (begin);
}
+Grob*
+System::get_pure_bound (Direction d, int start, int end)
+{
+ vector<vsize> ranks = pscore_->get_break_ranks ();
+ vector<vsize> indices = pscore_->get_break_indices ();
+ vector<Grob*> cols = pscore_->get_columns ();
+
+ vsize target_rank = (d == LEFT ? start : end);
+ vector<vsize>::const_iterator i =
+ lower_bound (ranks.begin (), ranks.end (), target_rank, std::less<vsize> ());
+
+ if (i != ranks.end () && (*i) == target_rank)
+ return cols[indices[i - ranks.begin ()]];
+ else
+ return 0;
+}
+
+Grob*
+System::get_maybe_pure_bound (Direction d, bool pure, int start, int end)
+{
+ return pure ? get_pure_bound (d, start, end) : get_bound (d);
+}
+
ADD_INTERFACE (System,
"This is the top-level object: Each object in a score"
" ultimately has a @code{System} object as its X and"