From e65a2fb4c6e0e2e75f457531cab49aaf74364015 Mon Sep 17 00:00:00 2001 From: Neil Puttock Date: Mon, 26 Jul 2010 01:02:52 +0100 Subject: [PATCH] Fix #1192. System separator positioning depends on correct calculation of the paper-system property 'staff-refpoint-extent, but this is incorrect for systems which include Staff-like contexts since the Vertically_spaced_contexts_engraver fails to acknowledge axis-groups whose origin context is aliased to Staff. Though it's simple to enhance the axis-group acknowledger to detect aliased contexts, a better solution is to remove the Vertically_spaced_context_engraver: spaceability is now determined by 'staff-affinity, so the engraver's more limited functionality can be folded into System::get_paper_system (). * lily/system.cc (get_paper_system): calculate 'staff-refpoint-extent via VerticalAlignment and Page_layout_problem::is_spaceable () remove 'spaceable-staves * lily/vertically-spaced-context-engraver.cc: delete * ly/engraver-init.ly: remove Vertically_spaced_context_engraver and verticallySpacedContexts * scm/define-context-properties.scm (all-user-translation-properties): remove verticallySpacedContexts definition * scm/define-grob-interfaces.scm: remove vertically-spaceable-interface * scm/define-grob-properties.scm (all-internal-grob-properties): remove 'spaceable-staves definition * scm/define-grobs.scm (all-grob-descriptions): remove vertically-spaceable-interface from VerticalAxisGroup --- .../system-separator-spaceable-staves.ly | 31 ++++++++ lily/system.cc | 87 +++++++++++----------- lily/vertically-spaced-context-engraver.cc | 81 -------------------- ly/engraver-init.ly | 2 - scm/define-context-properties.scm | 3 - scm/define-grob-interfaces.scm | 6 -- scm/define-grob-properties.scm | 2 - scm/define-grobs.scm | 3 +- 8 files changed, 75 insertions(+), 140 deletions(-) create mode 100644 input/regression/system-separator-spaceable-staves.ly delete mode 100644 lily/vertically-spaced-context-engraver.cc diff --git a/input/regression/system-separator-spaceable-staves.ly b/input/regression/system-separator-spaceable-staves.ly new file mode 100644 index 0000000000..7337e5a706 --- /dev/null +++ b/input/regression/system-separator-spaceable-staves.ly @@ -0,0 +1,31 @@ +\version "2.13.29" + +\header { + texidoc = "System separator positioning works with all spaceable +staff contexts." +} + + +\paper { + system-separator-markup = \slashSeparator + indent = 0 +} + +\book { + \new TabStaff { + c'1 + } + + \new Staff { + c'1 + } + + \new DrumStaff { + c'1 + } + + \new RhythmicStaff { + c'1 + } +} + diff --git a/lily/system.cc b/lily/system.cc index 628603fa84..8571cf35f9 100644 --- a/lily/system.cc +++ b/lily/system.cc @@ -119,7 +119,7 @@ System::derived_mark () const } static void -fixup_refpoints (vector const &grobs) +fixup_refpoints (vector const &grobs) { for (vsize i = grobs.size (); i--;) grobs[i]->fixup_refpoint (); @@ -183,7 +183,7 @@ System::do_break_substitution_and_fixup_refpoints () that no duplicates are in the list. */ for (vsize i = 0; i < broken_intos_.size (); i++) { - System *child = dynamic_cast (broken_intos_[i]); + System *child = dynamic_cast (broken_intos_[i]); child->all_elements_->remove_duplicates (); for (vsize j = 0; j < child->all_elements_->size (); j++) { @@ -234,7 +234,7 @@ System::break_into_pieces (vector const &breaking) System *system = dynamic_cast (clone ()); system->rank_ = broken_intos_.size (); - vector c (breaking[i].cols_); + vector c (breaking[i].cols_); pscore_->typeset_system (system); int st = Paper_column::get_rank (c[0]); @@ -255,7 +255,7 @@ System::break_into_pieces (vector const &breaking) system_labels = scm_append (scm_list_2 (col_labels, system_labels)); } system->set_property ("labels", system_labels); - + set_loose_columns (system, &breaking[i]); broken_intos_.push_back (system); } @@ -324,8 +324,8 @@ System::post_processing () This might seem inefficient, but Stencils are cached per grob anyway. */ - vector all_elts_sorted (all_elements_->array ()); - vector_sort (all_elts_sorted, std::less ()); + vector all_elts_sorted (all_elements_->array ()); + vector_sort (all_elts_sorted, std::less ()); uniq (all_elts_sorted); this->get_stencil (); for (vsize i = all_elts_sorted.size (); i--;) @@ -348,7 +348,6 @@ operator< (Layer_entry const &a, return a.layer_ < b.layer_; } - SCM System::get_paper_system () { @@ -363,8 +362,8 @@ System::get_paper_system () Layer_entry e; e.grob_ = all_elements_->grob (j); e.layer_ = robust_scm2int (e.grob_->get_property ("layer"), 1); - - entries.push_back (e); + + entries.push_back (e); } vector_sort (entries, std::less ()); @@ -375,7 +374,7 @@ System::get_paper_system () if (st.expr () == SCM_EOL) continue; - + Offset o; for (int a = X_AXIS; a < NO_AXES; a++) o[Axis (a)] = g->relative_coordinate (this, Axis (a)); @@ -429,26 +428,30 @@ System::get_paper_system () pl->set_property ("page-turn-penalty", right_bound->get_property ("page-turn-penalty")); Interval staff_refpoints; - extract_grob_set (this, "spaceable-staves", staves); - for (vsize i = 0; i < staves.size (); i++) - if (staves[i]->is_live ()) - staff_refpoints.add_point (staves[i]->relative_coordinate (this, Y_AXIS)); + if (Grob *align = get_vertical_alignment ()) + { + extract_grob_set (align, "elements", staves); + for (vsize i = 0; i < staves.size (); i++) + if (staves[i]->is_live () + && Page_layout_problem::is_spaceable (staves[i])) + staff_refpoints.add_point (staves[i]->relative_coordinate (this, + Y_AXIS)); + } pl->set_property ("staff-refpoint-extent", ly_interval2scm (staff_refpoints)); - pl->set_property ("system-grob", this->self_scm ()); + pl->set_property ("system-grob", this->self_scm ()); return pl->unprotect (); } -vector +vector System::broken_col_range (Item const *left, Item const *right) const { - vector ret; + vector ret; left = left->get_column (); right = right->get_column (); - extract_grob_set (this, "columns", cols); vsize i = Paper_column::get_rank (left); @@ -468,10 +471,9 @@ System::broken_col_range (Item const *left, Item const *right) const return ret; } - /** Return all columns, but filter out any unused columns , since they might disrupt the spacing problem. */ -vector +vector System::used_columns () const { extract_grob_set (this, "columns", ro_columns); @@ -484,7 +486,7 @@ System::used_columns () const break; } - vector columns; + vector columns; for (int i = 0; i <= last_breakable; i++) { if (Paper_column::is_used (ro_columns[i])) @@ -500,11 +502,11 @@ System::column (vsize which) const extract_grob_set (this, "columns", columns); if (which >= columns.size ()) return 0; - - return dynamic_cast (columns[which]); + + return dynamic_cast (columns[which]); } -Paper_score* +Paper_score * System::paper_score () const { return pscore_; @@ -517,14 +519,14 @@ System::get_rank () const } System * -get_root_system (Grob *me) +get_root_system (Grob *me) { Grob *system_grob = me; - + while (system_grob->get_parent (Y_AXIS)) system_grob = system_grob->get_parent (Y_AXIS); - return dynamic_cast (system_grob); + return dynamic_cast (system_grob); } Grob * @@ -575,27 +577,25 @@ System::part_of_line_pure_height (vsize start, vsize end, bool begin) { Grob *alignment = get_vertical_alignment (); if (!alignment) - { - programming_error("system does not have a vertical alignment"); - return Interval(); - } + return Interval (); + extract_grob_set (alignment, "elements", staves); vector offsets = Align_interface::get_minimum_translations (alignment, staves, Y_AXIS, true, start, end); Interval ret; - for (vsize i = 0; i < staves.size(); ++i) + for (vsize i = 0; i < staves.size (); ++i) { - Interval iv = begin ? - Axis_group_interface::begin_of_line_pure_height (staves[i], start) : - Axis_group_interface::rest_of_line_pure_height (staves[i], start, end); - if (i relevant_grobs; + vector relevant_grobs; SCM pure_relevant_p = ly_lily_module_constant ("pure-relevant?"); for (vsize i = 0; i < elts.size (); ++i) @@ -651,7 +651,7 @@ MAKE_SCHEME_CALLBACK (System, calc_pure_height, 3); SCM System::calc_pure_height (SCM smob, SCM start_scm, SCM end_scm) { - System *me = dynamic_cast (unsmob_grob (smob)); + System *me = dynamic_cast (unsmob_grob (smob)); int start = scm_to_int (start_scm); int end = scm_to_int (end_scm); @@ -672,7 +672,6 @@ ADD_INTERFACE (System, "columns " "labels " "pure-Y-extent " - "spaceable-staves " "skyline-distance " "skyline-horizontal-padding " - ) + ); diff --git a/lily/vertically-spaced-context-engraver.cc b/lily/vertically-spaced-context-engraver.cc deleted file mode 100644 index 8e5dee0ca7..0000000000 --- a/lily/vertically-spaced-context-engraver.cc +++ /dev/null @@ -1,81 +0,0 @@ -/* - This file is part of LilyPond, the GNU music typesetter. - - Copyright (C) 2005--2010 Han-Wen Nienhuys - - 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 . -*/ - -#include "engraver.hh" -#include "grob.hh" -#include "axis-group-interface.hh" -#include "context.hh" -#include "pointer-group-interface.hh" - -class Vertically_spaced_contexts_engraver : public Engraver -{ - TRANSLATOR_DECLARATIONS (Vertically_spaced_contexts_engraver); -protected: - virtual void initialize (); - DECLARE_ACKNOWLEDGER (vertically_spaceable); - -private: - Grob *system_; -}; - -Vertically_spaced_contexts_engraver::Vertically_spaced_contexts_engraver () -{ - system_ = 0; -} - -void -Vertically_spaced_contexts_engraver::initialize () -{ - system_ = unsmob_grob (get_property ("rootSystem")); -} - -void -Vertically_spaced_contexts_engraver::acknowledge_vertically_spaceable (Grob_info gi) -{ - if (Axis_group_interface::has_interface (gi.grob ())) - { - SCM spaceable = get_property ("verticallySpacedContexts"); - Context *orig = gi.origin_contexts (this)[0]; - - if (scm_memq (ly_symbol2scm (orig->context_name ().c_str ()), - spaceable) != SCM_BOOL_F) - { - Pointer_group_interface::add_unordered_grob (system_, - ly_symbol2scm ("spaceable-staves"), - gi.grob ()); - } - } -} - -#include "translator.icc" - -ADD_ACKNOWLEDGER (Vertically_spaced_contexts_engraver, vertically_spaceable); -ADD_TRANSLATOR (Vertically_spaced_contexts_engraver, - /* doc */ - "", - - /* create */ - "", - - /* read */ - "verticallySpacedContexts ", - - /* write */ - "verticallySpacedContexts " - ); diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 8522001347..7b21ff2fef 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -478,7 +478,6 @@ automatically when an output definition (a @code{\score} or @code{\layout} block) is processed." \consists "Paper_column_engraver" - \consists "Vertically_spaced_contexts_engraver" \consists "Repeat_acknowledge_engraver" \consists "Staff_collecting_engraver" @@ -672,7 +671,6 @@ automatically when an output definition (a @code{\score} or tuplet-span-event) instrumentTransposition = #(ly:make-pitch 0 0 0) - verticallySpacedContexts = #'(Staff) topLevelAlignment = ##t timing = ##t diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index 755c9fdf34..4a2a6736f2 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -503,9 +503,6 @@ setting this property, you can make brackets last shorter. (useBassFigureExtenders ,boolean? "Whether to use extender lines for repeated bass figures.") - (verticallySpacedContexts ,list? "List of symbols, containing -context names whose vertical axis groups should be taken into account -for vertical spacing of systems.") (vocalName ,markup? "Name of a vocal line.") (voltaSpannerDuration ,ly:moment? "This specifies the maximum duration to use for the brackets printed for @code{\\alternative}. diff --git a/scm/define-grob-interfaces.scm b/scm/define-grob-interfaces.scm index b73506790d..2949afcfbc 100644 --- a/scm/define-grob-interfaces.scm +++ b/scm/define-grob-interfaces.scm @@ -220,12 +220,6 @@ with @code{breakable=##t}." '(breakable)) (ly:add-interface - 'vertically-spaceable-interface - "Objects that should be kept at constant vertical distances. Typically: -@rinternals{VerticalAxisGroup} objects of @rinternals{Staff} contexts." - '()) - -(ly:add-interface 'volta-interface "A volta repeat." '()) diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index b3401d2261..a69a603654 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -981,8 +981,6 @@ relevant for finding the @code{pure-Y-extent}.") (side-support-elements ,ly:grob-array? "The side support, an array of grobs.") (slur ,ly:grob? "A pointer to a @code{Slur} object.") - (spaceable-staves ,ly:grob-array? "Objects to be spaced during page -layout.") (spacing ,ly:grob? "The spacing spanner governing this section.") (spacing-wishes ,ly:grob-array? "An array of note spacing or staff spacing objects.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 15d0b0d908..fc67827755 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -2300,8 +2300,7 @@ (pure-relevant-spanners . ,ly:axis-group-interface::calc-pure-relevant-spanners))) (interfaces . (axis-group-interface - hara-kiri-group-spanner-interface - vertically-spaceable-interface)))))) + hara-kiri-group-spanner-interface)))))) (VoiceFollower . ( -- 2.11.4.GIT