From a16fa3d5e278abdbcdd3a02e0074b0ed038ff4a2 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Tue, 14 Mar 2000 23:38:12 +0100 Subject: [PATCH] patch::: 1.3.33.jcn1 1.3.33.jcn1 =========== * Rewrote Staff_margin_engraver. Staff margin texts now hang on a new breakable item: Left_edge_item. * Fixed vertical alignment for dynamic elements. Orphaned dynamic items (not supported by a Dynamic_line_spanner) still collide with Staff, although they now have staff support, which was supposed to fix this. 1.3.32.jcn4 =========== * Fixed Staff_margin_engraver for "instrument", "instr" is still broken. * Dynamic elements are only put in a Dynamic_line_spanner if there actually is more than one adjacent note-column with a dynamic. This breaks the fine looks of all dynamics, again :-) --- CHANGES | 19 ++++ VERSION | 2 +- input/test/bar-break.ly | 23 ++++ input/test/bb.ly | 23 ++++ lily/dynamic-engraver.cc | 73 +++++++++--- lily/include/lily-proto.hh | 1 + lily/include/staff-margin-engraver.hh | 27 ----- lily/staff-margin-engraver.cc | 145 +++++++++++++++++------- ly/engraver.ly | 3 +- ly/params.ly | 1 + mutopia/Coriolan/coriolan-paper.ly | 1 + mutopia/Coriolan/coriolan-part-paper.ly | 5 +- scm/lily.scm | 1 + 13 files changed, 235 insertions(+), 89 deletions(-) create mode 100644 input/test/bar-break.ly create mode 100644 input/test/bb.ly diff --git a/CHANGES b/CHANGES index 5ee74be6f6..b12d85721c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,22 @@ +1.3.33.jcn1 +=========== + +* Rewrote Staff_margin_engraver. Staff margin texts now hang on a new + breakable item: Left_edge_item. + +* Fixed vertical alignment for dynamic elements. Orphaned dynamic items + (not supported by a Dynamic_line_spanner) still collide with Staff, + although they now have staff support, which was supposed to fix this. + +1.3.32.jcn4 +=========== + +* Fixed Staff_margin_engraver for "instrument", "instr" is still broken. + +* Dynamic elements are only put in a Dynamic_line_spanner if there + actually is more than one adjacent note-column with a dynamic. + This breaks the fine looks of all dynamics, again :-) + 1.3.33 ====== diff --git a/VERSION b/VERSION index 0c7ec16646..3aec424aab 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=3 PATCH_LEVEL=33 -MY_PATCH_LEVEL= +MY_PATCH_LEVEL=jcn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/input/test/bar-break.ly b/input/test/bar-break.ly new file mode 100644 index 0000000000..d45a9ddf01 --- /dev/null +++ b/input/test/bar-break.ly @@ -0,0 +1,23 @@ +\score +{ + \context StaffGroup = a < + \context PianoStaff = b < + \context Staff = "c" \notes\relative c'' { b1 \break b } + \context Staff = "d" \notes\relative c'' { b1 \break b } + > + > + + \paper { + indent=100.0\mm; + linewidth=150.0\mm; + \translator + { + \StaffContext + \consists "Staff_margin_engraver"; + numberOfStaffLines = #1 + marginScriptPadding = #10 % urg: this is in PT + instrument = #"Foo" + instr = #"Foo" + } + } +} diff --git a/input/test/bb.ly b/input/test/bb.ly new file mode 100644 index 0000000000..0c01477ada --- /dev/null +++ b/input/test/bb.ly @@ -0,0 +1,23 @@ +\score +{ + \context StaffGroup = a < + \context PianoStaff = b < + \context Staff = "c" \notes\relative c'' { b1 \break b } + \context Staff = "d" \notes\relative c'' { b1 \break b } + > + > + + \paper { + indent=100.0\mm; + linewidth=150.0\mm; + \translator + { + \StaffContext + \consists "Staff_margin_engraver"; + numberOfStaffLines = #1 + marginScriptPadding = #30 % urg: this is in PT + instrument = #"Foo" + instr = #"Bar" + } + } +} diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 87ab488ac6..dff3e72593 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -7,6 +7,7 @@ */ #include "debug.hh" #include "dimensions.hh" +#include "dimension-cache.hh" #include "crescendo.hh" #include "musical-request.hh" #include "lookup.hh" @@ -24,6 +25,14 @@ #include "staff-symbol-referencer.hh" #include "translator-group.hh" + +/* + TODO: + + * fix vertical placement of orphaned items + * fix padding + */ + class Dynamic_line_spanner : public Spanner { public: @@ -71,6 +80,9 @@ class Dynamic_engraver : public Engraver Dynamic_line_spanner* line_spanner_; Moment last_request_mom_; + + Note_column* pending_column_; + Link_array pending_element_arr_; void typeset_all (); @@ -87,6 +99,7 @@ protected: virtual void do_process_music (); virtual void do_pre_move_processing (); virtual void do_post_move_processing (); + virtual void typeset_element (Score_element*); }; ADD_THIS_TRANSLATOR (Dynamic_engraver); @@ -107,6 +120,7 @@ Dynamic_engraver::Dynamic_engraver () line_spanner_ = 0; span_start_req_l_ = 0; cresc_p_ =0; + pending_column_ = 0; text_req_l_ = 0; span_req_l_drul_[START] = 0; @@ -153,18 +167,32 @@ Dynamic_engraver::do_try_music (Music * m) void Dynamic_engraver::do_process_music () { - if ((span_req_l_drul_[START] || text_req_l_) && !line_spanner_) + if ((span_req_l_drul_[START] || text_req_l_) + && !line_spanner_ + && pending_element_arr_.size ()) { line_spanner_ = new Dynamic_line_spanner; + assert (pending_column_); + line_spanner_->add_column (pending_column_); side_position (line_spanner_).set_axis (Y_AXIS); announce_element (Score_element_info (line_spanner_, text_req_l_ ? text_req_l_ : span_req_l_drul_[START])); } - + + if (line_spanner_ && pending_element_arr_.size ()) + { + for (int i = 0; i < pending_element_arr_.size (); i++) + pending_element_arr_[i]->set_parent (line_spanner_, Y_AXIS); + pending_element_arr_.clear (); + } + if (span_req_l_drul_[START] || text_req_l_) last_request_mom_ = now_mom (); + else + pending_element_arr_.clear (); + if (text_req_l_) { @@ -176,9 +204,10 @@ Dynamic_engraver::do_process_music () text_p_->set_elt_property ("style", gh_str02scm ("dynamic")); text_p_->set_elt_property ("script-priority", gh_int2scm (100)); - - assert (line_spanner_); - text_p_->set_parent (line_spanner_, Y_AXIS); + pending_element_arr_.push (text_p_); + text_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0)); + text_p_->dim_cache_[Y_AXIS]->off_callbacks_.push + (Side_position_interface::aligned_on_self); announce_element (Score_element_info (text_p_, text_req_l_)); } @@ -193,7 +222,6 @@ Dynamic_engraver::do_process_music () { assert (!finished_cresc_p_); cresc_p_->set_bound(RIGHT, get_staff_info ().musical_pcol_l ()); - // cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ()); finished_cresc_p_ = cresc_p_; cresc_p_ = 0; span_start_req_l_ = 0; @@ -238,8 +266,6 @@ Dynamic_engraver::do_process_music () cresc_p_->set_bound(LEFT, get_staff_info ().musical_pcol_l ()); - // cresc_p_->add_dependency (get_staff_info ().musical_pcol_l ()); - /* We know how wide the text is, if we can be sure that the text already has relevant pointers into the paperdef, @@ -247,6 +273,12 @@ Dynamic_engraver::do_process_music () Since font-size may be set by a context higher up, we can not be sure of the size. + + + We shouldn't try to do this stuff here, the Item should + do it when the score is finished. We could maybe + set a callback to have the Item do the alignment if + it is not a special symbol, like Crescendo. */ @@ -258,10 +290,10 @@ Dynamic_engraver::do_process_music () index_set_cell (finished_cresc_p_->get_elt_property ("dynamic-drul"), RIGHT, SCM_BOOL_T); } - - assert (line_spanner_); - cresc_p_->set_parent (line_spanner_, Y_AXIS); - // cresc_p_->add_dependency (line_spanner_); + pending_element_arr_.push (cresc_p_); + cresc_p_->set_elt_property ("self-alignment-Y", gh_int2scm (0)); + cresc_p_->dim_cache_[Y_AXIS]->off_callbacks_.push + (Side_position_interface::aligned_on_self); announce_element (Score_element_info (cresc_p_, span_req_l_drul_[START])); } } @@ -291,6 +323,12 @@ Dynamic_engraver::do_removal_processing () } } +void +Dynamic_engraver::typeset_element (Score_element* e) +{ + side_position (e).add_staff_support (); + Engraver::typeset_element (e); +} void Dynamic_engraver::typeset_all () @@ -314,9 +352,6 @@ Dynamic_engraver::typeset_all () * continue through piece */ if (line_spanner_ && last_request_mom_ < now_mom ()) { - - side_position (line_spanner_).add_staff_support (); - typeset_element (line_spanner_); line_spanner_ = 0; } @@ -325,12 +360,16 @@ Dynamic_engraver::typeset_all () void Dynamic_engraver::acknowledge_element (Score_element_info i) { - if (line_spanner_) + if (Note_column* n = dynamic_cast (i.elem_l_)) { - if (Note_column* n = dynamic_cast (i.elem_l_)) + if (line_spanner_) { side_position (line_spanner_).add_support (n); line_spanner_->add_column (n); } + else + { + pending_column_ = n; + } } } diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index d5f93d6a06..8309d245a9 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -113,6 +113,7 @@ struct Key_item; struct Key_performer; struct Keyword; struct Keyword_table; +struct Left_edge_item; struct Lily_stream; struct Line_group_engraver; struct Line_of_score; diff --git a/lily/include/staff-margin-engraver.hh b/lily/include/staff-margin-engraver.hh index 3841da0deb..e69de29bb2 100644 --- a/lily/include/staff-margin-engraver.hh +++ b/lily/include/staff-margin-engraver.hh @@ -1,27 +0,0 @@ -/* - staff-margin-engraver.hh -- declare Staff_margin_engraver - - source file of the GNU LilyPond music typesetter - - (c) 1998--2000 Jan Nieuwenhuizen -*/ - - -#ifndef STAFF_MARGIN_ENGRAVER_HH -#define STAFF_MARGIN_ENGRAVER_HH - -#include "bar-script-engraver.hh" - -/** - put (instrument) text to left of line - */ -class Staff_margin_engraver : public Bar_script_engraver -{ -public: - VIRTUAL_COPY_CONS(Translator); - Staff_margin_engraver (); -protected: - void acknowledge_element (Score_element_info); -}; - -#endif // STAFF_MARGIN_ENGRAVER_HH diff --git a/lily/staff-margin-engraver.cc b/lily/staff-margin-engraver.cc index 8aecb00f3a..f3344955e4 100644 --- a/lily/staff-margin-engraver.cc +++ b/lily/staff-margin-engraver.cc @@ -6,71 +6,132 @@ (c) 1998--2000 Jan Nieuwenhuizen */ -#include "staff-margin-engraver.hh" +#include "translator.hh" +#include "engraver.hh" #include "bar.hh" +#include "dimension-cache.hh" #include "timing-translator.hh" #include "text-item.hh" #include "side-position-interface.hh" +#include "bar-script-engraver.hh" #include "staff-symbol-referencer.hh" +#include "staff-symbol.hh" + +/* + TODO: + + * padding + * merge with/derive from/add functionality to Bar_script_engraver + */ + +/** + Hang on left edge of staff to provide suppor for simple items. + */ +class Left_edge_item : public Item +{ +public: + VIRTUAL_COPY_CONS (Score_element); +}; + +/** + put (instrument) text to left of line + */ +class Staff_margin_engraver : public Engraver +{ +public: + VIRTUAL_COPY_CONS (Translator); + Staff_margin_engraver (); + +protected: + virtual void do_pre_move_processing (); + virtual void acknowledge_element (Score_element_info); + +private: + String type_; + Text_item* text_p_; + Left_edge_item* left_edge_p_; + void create_text (SCM); +}; ADD_THIS_TRANSLATOR (Staff_margin_engraver); + Staff_margin_engraver::Staff_margin_engraver () { - axis_ = X_AXIS; type_ = "margin"; + text_p_ = 0; + left_edge_p_ = 0; } +void +Staff_margin_engraver::acknowledge_element (Score_element_info info) +{ + SCM s = get_property ("instrument"); + + if (now_mom () > Moment (0)) + s = get_property ("instr"); + + //s = ly_str02scm ("HALLO"); + + if (dynamic_cast (info.elem_l_) && gh_string_p (s)) + create_text (s); +} -/* - TODO - - should be able to set whole paragraph (multiple lines, center) to - left (right?) of staff, e.g.: - ______ - |_______ - 2 Clarinetti |________ - (Bb) |___________ - |______________ -*/ void -Staff_margin_engraver::acknowledge_element (Score_element_info inf) +Staff_margin_engraver::create_text (SCM text) { - Item *i = cast_to_interesting_item (inf.elem_l_); - if (!i || inf.origin_trans_l_arr (this).size() != 1) - return; + if (!text_p_) + { + assert (!left_edge_p_); + Left_edge_item* l = new Left_edge_item; + + l->set_elt_property ("breakable", SCM_BOOL_T); + l->set_elt_property ("break-aligned", SCM_BOOL_T); + announce_element (Score_element_info (l, 0)); - SCM long_name = get_property ("instrument"); - SCM short_name = get_property ("instr"); + Staff_symbol_referencer_interface sl (l); + sl.set_interface (); + left_edge_p_ = l; + + Text_item* t = new Text_item; - if (now_mom () > Moment (0)) - long_name = short_name; + t->set_elt_property ("self-alignment-Y", gh_int2scm (0)); + t->dim_cache_[Y_AXIS]->off_callbacks_.push + (Side_position_interface::aligned_on_self); - if (gh_string_p (long_name)) - { - create_items (0); - text_p_->set_elt_property ("text", long_name); - text_p_->set_elt_property ("direction", gh_int2scm (LEFT)); - Bar_script_engraver::attach_script_to_item (i); - - /* - UGH. ignores font size settings. - */ - Interval iv(text_p_->extent (Y_AXIS)); - text_p_->translate_axis (- iv.center (), Y_AXIS); - - Real staff_space = Staff_symbol_referencer_interface (text_p_).staff_space (); - SCM s = get_property ("staffMarginHorizontalPadding"); - if (gh_number_p (s)) - { - text_p_->translate_axis (gh_scm2double (s) * staff_space, X_AXIS); - } - s = get_property ("staffMarginVerticalPadding"); + t->set_parent (l, X_AXIS); + t->set_parent (l, Y_AXIS); + + // 'just to be sure': see Clef_item::do_add_processing + l->add_dependency (t); + + announce_element (Score_element_info (t, 0)); + + SCM s = get_property (type_ + "ScriptPadding"); if (gh_number_p (s)) { - text_p_->translate_axis (gh_scm2double (s) * staff_space, Y_AXIS); + //t->set_elt_property ("padding", s); + t->translate_axis (-gh_scm2double (s), X_AXIS); } + text_p_ = t; } + //text_p_->set_elt_property ("style", s); + //text_p_->set_elt_property ("direction", gh_int2scm (RIGHT)); + text_p_->set_elt_property ("text", text); } +void +Staff_margin_engraver::do_pre_move_processing () +{ + if (text_p_) + { + text_p_->set_elt_property("visibility-lambda", + ly_eval_str ("begin-of-line-visible")); + typeset_element (text_p_); + text_p_ = 0; + assert (left_edge_p_); + typeset_element (left_edge_p_); + left_edge_p_ = 0; + } +} diff --git a/ly/engraver.ly b/ly/engraver.ly index 93ca721d07..f95e8cdf8d 100644 --- a/ly/engraver.ly +++ b/ly/engraver.ly @@ -113,7 +113,7 @@ VoiceContext = \translator { \type "Engraver_group_engraver"; \name Voice; - dynamicPadding = #5.0 + dynamicPadding = #2.0 Generic_property_list = #generic-voice-properties \consists "Output_property_engraver"; @@ -329,6 +329,7 @@ ScoreContext = \translator { % \consists "Score_priority_engraver"; \consists "Break_align_engraver"; breakAlignOrder = #'( + "Left_edge_item" "Span_bar" "Breathing_sign" "Clef_item" diff --git a/ly/params.ly b/ly/params.ly index 0f3052930e..c57a1120d5 100644 --- a/ly/params.ly +++ b/ly/params.ly @@ -41,6 +41,7 @@ arithmetic_multiplier = 0.9 * \quartwidth ; #'Stem_tremolo::beam-width = 1.5 * \quartwidth ; +#'Left_edge_item::visibility-lambda = #begin-of-line-visible #'Clef_item::visibility-lambda = #begin-of-line-visible #'Key_item::visibility-lambda = #begin-of-line-visible #'Breathing_sign::visibility-lambda = #begin-of-line-invisible diff --git a/mutopia/Coriolan/coriolan-paper.ly b/mutopia/Coriolan/coriolan-paper.ly index 9c059b4e02..a7f4dbb1d5 100644 --- a/mutopia/Coriolan/coriolan-paper.ly +++ b/mutopia/Coriolan/coriolan-paper.ly @@ -28,6 +28,7 @@ } \translator { \HaraKiriStaffContext + marginScriptPadding = #10 %% urg, this is in pt \accepts "VoiceOne"; \accepts "VoiceTwo"; } diff --git a/mutopia/Coriolan/coriolan-part-paper.ly b/mutopia/Coriolan/coriolan-part-paper.ly index 67df401e15..5f863ca3e2 100644 --- a/mutopia/Coriolan/coriolan-part-paper.ly +++ b/mutopia/Coriolan/coriolan-part-paper.ly @@ -1,5 +1,8 @@ \paper { - \translator { \OrchestralPartStaffContext } + \translator { + \OrchestralPartStaffContext + marginScriptPadding = #10 %% urg, this is in pt + } \translator { \VoiceContext \name "VoiceOne"; diff --git a/scm/lily.scm b/scm/lily.scm index aef1ec55cc..f5965cb7f2 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -100,6 +100,7 @@ ;; (Measured in staff space) (define space-alist '( + (("" "Left_edge_item") . (minimum-space -15.0)) (("" "Clef_item") . (minimum-space 1.0)) (("" "Staff_bar") . (minimum-space 0.0)) (("" "Clef_item") . (minimum-space 1.0)) -- 2.39.5