From 9f3cd80128759b22321f41060eb5c53853ac0667 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 12 Mar 2004 19:05:02 +0000 Subject: [PATCH] * lily/figured-bass-engraver.cc (process_music): change calling convention. * scm/bass-figure.scm (format-bass-figure): rewrite function. * scm/define-markup-commands.scm (bracketed-y-column): new markup command. * lily/include/stencil.hh (class Stencil): add origin field. * lily/stencil-scheme.cc (LY_DEFINE): ly:stencil-move-to-edge: new function. * lily/grob-scheme.cc (LY_DEFINE): ly:grob-alist-chain: new function. * lily/lexer.ll: remove support for \$ and $ in identifiers * lily/sequential-iterator.cc: remove copy_grace_fixups (get_grace_fixup): slight abstraction of fixup code. * input/test/title-markup.ly (spaceTest): vary staff sizes. --- ChangeLog | 30 +++++++++ Documentation/topdocs/NEWS.texi | 4 ++ Documentation/user/music-glossary.tely | 8 +-- Documentation/user/notation.itely | 10 ++- input/test/title-markup.ly | 3 + lily/figured-bass-engraver.cc | 15 +++-- lily/grob-property.cc | 8 +-- lily/grob-scheme.cc | 15 +++++ lily/include/sequential-iterator.hh | 17 +++-- lily/include/stencil.hh | 10 ++- lily/lexer.ll | 19 ------ lily/lookup.cc | 5 +- lily/parse-scm.cc | 6 +- lily/parser.yy | 8 ++- lily/sequential-iterator.cc | 80 ++++++++++++----------- lily/staff-performer.cc | 3 - lily/stencil-scheme.cc | 69 ++++++++++++++++---- lily/stencil.cc | 44 +++++++++---- ly/engraver-init.ly | 2 +- scm/bass-figure.scm | 56 +++++++--------- scm/define-context-properties.scm | 4 +- scm/define-markup-commands.scm | 89 ++++++++++++++++++++++++++ scm/page-layout.scm | 10 +-- scm/part-combiner.scm | 25 ++++++-- 24 files changed, 376 insertions(+), 164 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d5f84c792..293cc67b1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2004-03-12 Han-Wen Nienhuys + + * lily/figured-bass-engraver.cc (process_music): change calling + convention. + + * scm/bass-figure.scm (format-bass-figure): rewrite function. + + * scm/define-markup-commands.scm (bracketed-y-column): new markup + command. + + * lily/include/stencil.hh (class Stencil): add origin field. + + * lily/stencil-scheme.cc (LY_DEFINE): ly:stencil-move-to-edge: new + function. + + * lily/grob-scheme.cc (LY_DEFINE): ly:grob-alist-chain: new function. + + * lily/lexer.ll: remove support for \$ and $ in identifiers + + * lily/sequential-iterator.cc: remove copy_grace_fixups + (get_grace_fixup): slight abstraction of fixup code. + + * input/test/title-markup.ly (spaceTest): vary staff sizes. + 2004-03-12 Heikki Junes * vim/lilypond-indent.vim: use (default) as indent key @@ -23,6 +47,12 @@ * lily/paper-book.cc (output): Bugfix. +2004-03-11 Han-Wen Nienhuys + + * VERSION (MY_PATCH_LEVEL): release 2.1.30 + +2004-03-11 Jan Nieuwenhuizen + * Documentation/user/lilypond.tely: Bugfix: Remove './' from direntries. diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index 5a87cbd95b..5f4aaacf45 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -8,6 +8,10 @@ @chapter New features in 2.1 since 2.0 @itemize @bullet +@item The pmx2ly script has been removed from the distribution. + +@item Pedal brackets will now run to the last bar of a piece if they are not +explicitly ended. @item Context definitions now use the word @code{\context} instead of @code{\translator}. diff --git a/Documentation/user/music-glossary.tely b/Documentation/user/music-glossary.tely index 722a73c7bc..a005d12773 100644 --- a/Documentation/user/music-glossary.tely +++ b/Documentation/user/music-glossary.tely @@ -293,7 +293,7 @@ FI: alttoavain. C clef setting middle C on the middle line of the staff @aref{C clef}. -@aitem{ambitus} +@aitem{ambit} ES: ambitus, I: ambitus, F: ambitus, @@ -303,9 +303,9 @@ DK: ambitus, S: ambitus, FI: ambitus, @"a@"aniala, soitinala. -The term ambitus (plural: ambituses) denotes a range of pitches for a -given voice in a part of music. It also may denote the pitch range -that a musical instrument is capable of playing. +The term ambit (from latin: ambitus, plural: ambitus) denotes a range +of pitches for a given voice in a part of music. It also may denote +the pitch range that a musical instrument is capable of playing. @aitem{ancient minor scale} I: scala minore naturale, diff --git a/Documentation/user/notation.itely b/Documentation/user/notation.itely index 5187c58124..2c38f4efaf 100644 --- a/Documentation/user/notation.itely +++ b/Documentation/user/notation.itely @@ -1064,7 +1064,15 @@ indicating how much of the measure has passed at this point. Bar lines and bar numbers are calculated automatically. For unmetered music (e.g. cadenzas), this is not desirable. By setting @code{Score.timing} to false, this automatic timing can be switched -off. +off. Empty bar lines, + +@example + \bar "" +@end example + +@noindent +indicate where line breaks can occur. + @refcommands diff --git a/input/test/title-markup.ly b/input/test/title-markup.ly index 3e088c5924..5b5311b403 100644 --- a/input/test/title-markup.ly +++ b/input/test/title-markup.ly @@ -64,6 +64,9 @@ spaceTest = \markup { "two space chars" } \context Staff \notes \relative c' { c2-\sizeTest c2-\spaceTest } + \paper { + #(paper-set-staff-size (* 11.0 pt)) + } } \header { diff --git a/lily/figured-bass-engraver.cc b/lily/figured-bass-engraver.cc index d5bb6aad24..b7114de9ea 100644 --- a/lily/figured-bass-engraver.cc +++ b/lily/figured-bass-engraver.cc @@ -78,14 +78,15 @@ Figured_bass_engraver::process_music () if (gh_procedure_p (proc)) { SCM l = SCM_EOL; - - for (int i = 0; i self_scm (), l); - - SCM markup = scm_call_2 (proc, l, daddy_context_->self_scm ()); - + SCM * t = &l; + for (int i = 0; i < figures_.size (); i++) + { + *t = scm_cons (figures_[i]->self_scm (), SCM_EOL); + t = SCM_CDRLOC (*t); + } figure_ = make_item ("BassFigure"); - figure_->set_property ("text", markup); + scm_call_3 (proc, l, daddy_context_->self_scm (), + figure_->self_scm ()); announce_grob (figure_, figures_[0]->self_scm ()); // todo } } diff --git a/lily/grob-property.cc b/lily/grob-property.cc index fd45e40c34..46d032c64f 100644 --- a/lily/grob-property.cc +++ b/lily/grob-property.cc @@ -21,10 +21,10 @@ SCM Grob::get_property_alist_chain (SCM def) const { - return scm_list_n (mutable_property_alist_, - immutable_property_alist_, - def, - SCM_UNDEFINED); + return scm_list_n (mutable_property_alist_, + immutable_property_alist_, + def, + SCM_UNDEFINED); } diff --git a/lily/grob-scheme.cc b/lily/grob-scheme.cc index 87b6ba4a46..f7158e7f45 100644 --- a/lily/grob-scheme.cc +++ b/lily/grob-scheme.cc @@ -68,6 +68,21 @@ LY_DEFINE (ly_grob_paper,"ly:grob-paper", 1, 0, 0, return sc->get_paper ()->self_scm (); } + +LY_DEFINE(ly_grob_alist_chain, "ly:grob-alist-chain", + 1, 0, 0, + (SCM g), + "Get an alist chain for grob @var{g}." + ) +{ + Grob * sc = unsmob_grob (g); + SCM_ASSERT_TYPE (sc, g, SCM_ARG1, __FUNCTION__, "grob"); + + SCM defaults = sc->get_paper ()->lookup_variable (ly_symbol2scm ("font-defaults")); + return sc->get_property_alist_chain (defaults); +} + + LY_DEFINE (ly_get_extent, "ly:grob-extent", 3, 0, 0, (SCM grob, SCM refp, SCM axis), "Get the extent in @var{axis} direction of @var{grob} relative to " diff --git a/lily/include/sequential-iterator.hh b/lily/include/sequential-iterator.hh index b8bf6354f7..eac01f3f77 100644 --- a/lily/include/sequential-iterator.hh +++ b/lily/include/sequential-iterator.hh @@ -51,8 +51,6 @@ struct Grace_fixup class Sequential_iterator : public Music_iterator { public: - Grace_fixup * grace_fixups_; - DECLARE_SCHEME_CALLBACK(constructor, ()); Sequential_iterator (); Sequential_iterator (Sequential_iterator const&); @@ -70,14 +68,21 @@ protected: virtual Music_iterator *try_music_in_children (Music *) const; virtual bool run_always () const; protected: - Moment here_mom_; Music_iterator * iter_; - SCM list_; + virtual SCM get_music_list ()const; + virtual void next_element (bool side_effect); + + + Grace_fixup *get_grace_fixup () const; + void next_grace_fixup (); + +private: + Moment here_mom_; + SCM list_; SCM cursor_; + Grace_fixup * grace_fixups_; - virtual void next_element (bool side_effect); virtual void descend_to_child (); - virtual SCM get_music_list ()const; }; #endif /* SEQUENTIAL_ITERATOR_HH */ diff --git a/lily/include/stencil.hh b/lily/include/stencil.hh index 9d81bdc13a..234681b7a7 100644 --- a/lily/include/stencil.hh +++ b/lily/include/stencil.hh @@ -42,7 +42,8 @@ class Stencil { friend SCM ly_stencil_set_extent_x (SCM, SCM, SCM); - + + Offset origin_; Box dim_; SCM expr_; @@ -50,14 +51,17 @@ class Stencil public: Stencil (Box, SCM s); Stencil (); - - + + Offset origin () const; SCM smobbed_copy () const; SCM get_expr () const; /** Set dimensions to empty, or to (Interval (0,0),Interval (0,0) */ void set_empty (bool); + Stencil moved_to_edge (Axis a, Direction d, const Stencil &m, Real padding, + Real minimum) const; + void add_at_edge (Axis a, Direction d, const Stencil &m, Real padding, Real minimum); void add_stencil (Stencil const &m); diff --git a/lily/lexer.ll b/lily/lexer.ll index ea5ed739e4..2a5a667c44 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -264,25 +264,6 @@ HYPHEN -- R { return MULTI_MEASURE_REST; } -\\\${BLACK}*{WHITE} { - String s=YYText () + 2; - s=s.left_string (s.length () - 1); - return scan_escaped_word (s); -} -\${BLACK}*{WHITE} { - String s=YYText () + 1; - s=s.left_string (s.length () - 1); - return scan_bare_word (s); -} -\\\${BLACK}* { // backup rule - error (_("white expected")); - exit (1); -} -\${BLACK}* { // backup rule - error (_("white expected")); - exit (1); -} - # { //embedded scm //char const* s = YYText () + 1; char const* s = here_str0 (); diff --git a/lily/lookup.cc b/lily/lookup.cc index e7d4680825..3d395f137c 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -701,9 +701,6 @@ Lookup::triangle (Interval iv, Real thick, Real protude) } -/* - TODO: use rounded boxes. - */ LY_DEFINE (ly_bracket ,"ly:bracket", 4, 0, 0, (SCM a, SCM iv, SCM t, SCM p), @@ -720,7 +717,7 @@ LY_DEFINE (ly_bracket ,"ly:bracket", return Lookup::bracket ((Axis)gh_scm2int (a), ly_scm2interval (iv), gh_scm2double (t), gh_scm2double (p), - gh_scm2double (t)).smobbed_copy (); + 0.95 * gh_scm2double (t)).smobbed_copy (); } diff --git a/lily/parse-scm.cc b/lily/parse-scm.cc index f909b5aa2c..e95eb644f7 100644 --- a/lily/parse-scm.cc +++ b/lily/parse-scm.cc @@ -32,7 +32,11 @@ internal_ly_parse_scm (Parse_start * ps, bool safe) { if (safe) { - SCM safe_module = scm_primitive_eval (ly_symbol2scm ("safe-module")); + static SCM safe_module; + if (!safe_module) + safe_module = scm_primitive_eval (ly_symbol2scm ("safe-module")); + + answer = scm_eval (form, safe_module); } else diff --git a/lily/parser.yy b/lily/parser.yy index 190b42ce83..17adedcc94 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -125,9 +125,13 @@ is_regular_identifier (SCM id) char const *s = str.to_str0 () ; bool v = true; +/* + isalpha (*s); + s++; +*/ while (*s && v) { - v = v && isalpha (*s); + v = v && isalnum (*s); s++; } return v; @@ -1936,7 +1940,7 @@ bass_figure: Music *m = unsmob_music ($1); if ($2) { SCM salter =m->get_property ("alteration"); - int alter = gh_number_p ( salter) ? gh_scm2int (salter) : 0; + int alter = gh_number_p (salter) ? gh_scm2int (salter) : 0; m->set_property ("alteration", gh_int2scm (alter + $2)); } else { diff --git a/lily/sequential-iterator.cc b/lily/sequential-iterator.cc index 6aed08927c..81e9dac296 100644 --- a/lily/sequential-iterator.cc +++ b/lily/sequential-iterator.cc @@ -11,7 +11,6 @@ #include "sequential-iterator.hh" #include "music-list.hh" -Grace_fixup *copy_grace_fixups (Grace_fixup* src); Grace_fixup *get_grace_fixups (SCM cursor); /* @@ -42,7 +41,7 @@ Sequential_iterator::Sequential_iterator () list_ = SCM_EOL; cursor_ = SCM_EOL; grace_fixups_ = 0; - iter_ =0; + iter_ = 0; } SCM @@ -80,7 +79,7 @@ Sequential_iterator::derived_substitute (Context *f,Context *t) } Grace_fixup * -get_grace_fixups (SCM cursor) +create_grace_fixup_list (SCM cursor) { Moment here; Moment last (-1); @@ -89,15 +88,15 @@ get_grace_fixups (SCM cursor) for (; gh_pair_p (cursor); cursor = ly_cdr (cursor)) { - Music * mus = unsmob_music (ly_car (cursor)); + Music *mus = unsmob_music (ly_car (cursor)); Moment s = mus->start_mom (); - Moment l =mus->get_length () - s; + Moment l = mus->get_length () - s; if (s.grace_part_) { if (last != Moment (-1)) { - Grace_fixup *p =new Grace_fixup; + Grace_fixup *p = new Grace_fixup; p->start_ = last; p->length_ = here - last; p->grace_start_ = s.grace_part_; @@ -115,22 +114,7 @@ get_grace_fixups (SCM cursor) here += l; } } - return head; -} - -Grace_fixup * -copy_grace_fixups (Grace_fixup* src) -{ - Grace_fixup * head = 0; - Grace_fixup **dest = &head; - - while (src) - { - *dest = new Grace_fixup (*src); - dest = & (*dest)->next_; - src = src ->next_; - } - + return head; } @@ -153,7 +137,7 @@ Sequential_iterator::construct_children () } here_mom_ = get_music ()->start_mom (); - grace_fixups_ = get_grace_fixups (cursor_); + grace_fixups_ = create_grace_fixup_list (cursor_); /* iter_->ok () is tautology, but what the heck. @@ -173,15 +157,15 @@ Sequential_iterator::next_element (bool) Moment len =iter_->music_get_length () - iter_->music_start_mom (); assert (!grace_fixups_ || grace_fixups_->start_ >= here_mom_); - if (len.main_part_ && grace_fixups_ && - grace_fixups_->start_ == here_mom_) + if (len.main_part_ + && get_grace_fixup ()) { - here_mom_ += grace_fixups_->length_; - here_mom_.grace_part_ += grace_fixups_->grace_start_; + Grace_fixup *gf = get_grace_fixup (); + + here_mom_ += gf->length_; + here_mom_.grace_part_ += gf->grace_start_; - Grace_fixup * n =grace_fixups_->next_; - delete grace_fixups_; - grace_fixups_ = n; + next_grace_fixup (); } else if (len.grace_part_ && !len.main_part_) { @@ -221,7 +205,7 @@ Sequential_iterator::descend_to_child () Context * c = child_report; while (c && c != me_report) { - c= c->daddy_context_; + c = c->daddy_context_; } if (c == me_report) @@ -235,10 +219,10 @@ Sequential_iterator::process (Moment until) { while (iter_) { - if (grace_fixups_ && - grace_fixups_->start_ == here_mom_ - && (grace_fixups_->start_ + grace_fixups_->length_ - + Moment (Rational (0), grace_fixups_->grace_start_) == until)) + Grace_fixup * gf = get_grace_fixup (); + if (gf + && gf->start_ + gf->length_ + + Moment (Rational (0), gf->grace_start_) == until) { /* do the stuff/note/rest preceding a grace. @@ -248,7 +232,6 @@ Sequential_iterator::process (Moment until) else { Moment w = until - here_mom_ + iter_->music_start_mom (); - // if (w >= Moment (0)) iter_->process (w); } @@ -274,10 +257,11 @@ Sequential_iterator::pending_moment () const /* Fix-up a grace note halfway in the music. */ - if (grace_fixups_ && here_mom_ == grace_fixups_->start_ - && grace_fixups_->length_ + iter_->music_start_mom () == cp) + Grace_fixup * gf = get_grace_fixup (); + if (gf + && gf->length_ + iter_->music_start_mom () == cp) { - return here_mom_ + grace_fixups_->length_ + Moment (0, grace_fixups_->grace_start_); + return here_mom_ + gf->length_ + Moment (0, gf->grace_start_); } /* @@ -306,3 +290,21 @@ Sequential_iterator::run_always () const { return iter_ ? iter_->run_always () : false; } + +void +Sequential_iterator::next_grace_fixup () +{ + Grace_fixup * n = grace_fixups_->next_; + delete grace_fixups_; + grace_fixups_ = n; +} + + +Grace_fixup* +Sequential_iterator::get_grace_fixup () const +{ + if (grace_fixups_ && grace_fixups_->start_ == here_mom_) + return grace_fixups_; + else + return 0; +} diff --git a/lily/staff-performer.cc b/lily/staff-performer.cc index adacd1c6c0..a969143440 100644 --- a/lily/staff-performer.cc +++ b/lily/staff-performer.cc @@ -91,9 +91,6 @@ Staff_performer::create_audio_elements () void Staff_performer::stop_translation_timestep () { - /* - UGH. -> don't use eval. - */ static SCM proc; if (!proc) proc = scm_primitive_eval (ly_symbol2scm ("percussion?")); diff --git a/lily/stencil-scheme.cc b/lily/stencil-scheme.cc index e274677fc4..4e30e129ae 100644 --- a/lily/stencil-scheme.cc +++ b/lily/stencil-scheme.cc @@ -9,7 +9,9 @@ #include "font-metric.hh" #include "stencil.hh" - +/* + TODO: naming add/combine. + */ /* UMGH. junkme! @@ -33,18 +35,18 @@ LY_DEFINE (ly_stencil_set_extent_x,"ly:stencil-set-extent!", LY_DEFINE (ly_translate_stencil_axis, "ly:stencil-translate-axis", 3, 0, 0, (SCM stil, SCM amount, SCM axis), - "Return a @var{stil}, " - "but translated by @var{amount} in @var{axis} direction.") + "Return a copy of @var{stil} but translated by @var{amount} in @var{axis} direction.") { Stencil *s = unsmob_stencil (stil); SCM_ASSERT_TYPE (s, stil, SCM_ARG1, __FUNCTION__, "stencil"); SCM_ASSERT_TYPE (gh_number_p (amount), amount, SCM_ARG2, __FUNCTION__, "number pair"); SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); - Stencil q (*s); - q.translate_axis (gh_scm2double (amount), Axis (gh_scm2int (axis))); + SCM new_s = s->smobbed_copy (); + Stencil *q = unsmob_stencil (new_s); + q->translate_axis (gh_scm2double (amount), Axis (gh_scm2int (axis))); + return new_s; - return q.smobbed_copy (); } LY_DEFINE (ly_translate_stencil,"ly:stencil-translate", @@ -57,9 +59,10 @@ LY_DEFINE (ly_translate_stencil,"ly:stencil-translate", SCM_ASSERT_TYPE (is_number_pair (offset), offset, SCM_ARG2, __FUNCTION__, "number pair"); Offset o = ly_scm2offset (offset); - Stencil q (*s); - q.translate (o); - return q.smobbed_copy (); + SCM new_s = s->smobbed_copy (); + Stencil *q =unsmob_stencil (new_s); + q->translate (o); + return new_s; } LY_DEFINE (ly_stencil_get_expr, "ly:stencil-get-expr", @@ -83,8 +86,51 @@ LY_DEFINE (ly_stencil_get_extent, return ly_interval2scm (s->extent (Axis (gh_scm2int (axis)))); } -LY_DEFINE (ly_stencil_combined_at_edge, - "ly:stencil-combine-at-edge", +LY_DEFINE (ly_stencil_moved_to_edge, "ly:stencil-moved-to-edge", + 4, 2, 0, (SCM first, SCM axis, SCM direction, + SCM second, + SCM padding, + SCM minimum), + "Similar to @code{ly:stencil-combine-edge}, but returns " + "@var{second} positioned to be next to @var{first}. ") +{ + /* + C&P from combine-at-edge. + */ + Stencil *s1 = unsmob_stencil (first); + Stencil *s2 = unsmob_stencil (second); + Stencil first_stencil; + + SCM_ASSERT_TYPE (is_axis (axis), axis, SCM_ARG3, __FUNCTION__, "axis"); + SCM_ASSERT_TYPE (is_direction (direction), direction, SCM_ARG4, __FUNCTION__, "dir"); + + Real p = 0.0; + if (padding != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (gh_number_p (padding), padding, SCM_ARG5, __FUNCTION__, "number"); + p = gh_scm2double (padding); + } + Real m = 0.0; + if (minimum != SCM_UNDEFINED) + { + SCM_ASSERT_TYPE (gh_number_p (minimum), minimum, SCM_ARG6, __FUNCTION__, "number"); + m = gh_scm2double (minimum); + } + + if (s1) + first_stencil = *s1; + + if (s2) + return first_stencil.moved_to_edge (Axis (gh_scm2int (axis)), + Direction (gh_scm2int (direction)), + *s2, p, m).smobbed_copy (); + else + return Stencil().smobbed_copy (); +} + + + +LY_DEFINE (ly_stencil_combine_at_edge, "ly:stencil-combine-at-edge", 4, 2, 0, (SCM first, SCM axis, SCM direction, SCM second, SCM padding, @@ -125,7 +171,6 @@ LY_DEFINE (ly_stencil_combined_at_edge, return result.smobbed_copy (); } -/* FIXME: support variable number of arguments. */ LY_DEFINE (ly_stencil_add , "ly:stencil-add", 0, 0, 1, (SCM args), "Combine stencils. Takes any number of arguments.") diff --git a/lily/stencil.cc b/lily/stencil.cc index a983241fc1..2b16efe8b6 100644 --- a/lily/stencil.cc +++ b/lily/stencil.cc @@ -27,6 +27,12 @@ Stencil::smobbed_copy () const return s->smobbed_self (); } +Offset +Stencil::origin () const +{ + return origin_; +} + Interval Stencil::extent (Axis a) const { @@ -65,6 +71,7 @@ Stencil::translate (Offset o) expr_, SCM_UNDEFINED); if (!is_empty ()) dim_.translate (o); + origin_ += o; } void @@ -73,7 +80,7 @@ Stencil::translate_axis (Real x, Axis a) Offset o (0,0); o[a] = x; translate (o); -} +} void Stencil::add_stencil (Stencil const &s) @@ -108,29 +115,44 @@ Stencil::align_to (Axis a, Real x) translate_axis (-i.linear_combination (x), a); } -/* See scheme Function. */ -void -Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding, - Real minimum) +/* + TODO: unintuitive naming, you would expect *this to be moved. Kept + API for compat with add_at_edge (). +*/ +Stencil +Stencil::moved_to_edge (Axis a, Direction d, Stencil const &s, Real padding, + Real minimum) const { Real my_extent= is_empty () ? 0.0 : dim_[a][d]; Interval i (s.extent (a)); Real his_extent; if (i.is_empty ()) { - programming_error ("Stencil::add_at_edge: adding empty stencil."); + programming_error ("Stencil::move_to_edge: adding empty stencil."); his_extent = 0.0; } else his_extent = i[-d]; Real offset = (my_extent - his_extent) + d * padding; - if (minimum > 0 && fabs (offset) < minimum) - offset = sign (offset) * minimum; - + Stencil toadd (s); - toadd.translate_axis (offset, a); - add_stencil (toadd); + toadd.translate_axis (offset,a); + + if (minimum > 0 + && d *(- origin ()[a] + toadd.origin ()[a]) < minimum) + toadd.translate_axis ( -toadd.origin ()[a] + + origin ()[a] + d* minimum, a); + + return toadd; +} + +/* See scheme Function. */ +void +Stencil::add_at_edge (Axis a, Direction d, Stencil const &s, Real padding, + Real minimum) +{ + add_stencil (moved_to_edge (a,d,s,padding, minimum)); } /* Hmm... maybe this is not such a good idea ; stuff can be empty, diff --git a/ly/engraver-init.ly b/ly/engraver-init.ly index 9ea43edbf1..6991aa835f 100644 --- a/ly/engraver-init.ly +++ b/ly/engraver-init.ly @@ -527,7 +527,7 @@ AncientRemoveEmptyStaffContext = \context { tablatureFormat = #fret-number-tablature-format %% - bassFigureFormatFunction = #make-bass-figure-markup + bassFigureFormatFunction = #format-bass-figure metronomeMarkFormatter = #format-metronome-markup graceSettings = #`#( (Voice Stem direction 1) diff --git a/scm/bass-figure.scm b/scm/bass-figure.scm index 8aa8f5dce4..804198a6c9 100644 --- a/scm/bass-figure.scm +++ b/scm/bass-figure.scm @@ -5,24 +5,9 @@ "A bass figure, including bracket" '()) -(define (recursive-split-at pred? l) - (if (null? l) - '() - (let* - ((x (split-at-predicate pred? l))) - (set-cdr! x (recursive-split-at pred? (cdr x))) - x - ))) -(define-public (make-bass-figure-markup figures context) - - (define (no-end-bracket? f1 f2) - (eq? (ly:music-property f1 'bracket-stop) '()) - ) - (define (no-start-bracket? f1 f2) - (eq? (ly:music-property f2 'bracket-start) '()) - ) +(define-public (format-bass-figure figures context grob) ;; TODO: support slashed numerals here. (define (fig-to-markup fig-music) (let* @@ -44,22 +29,25 @@ (alteration->text-accidental-markup acc))) fig-markup) )) - - (define (fig-seq-to-markup figs) - (let* - ( - (c (make-dir-column-markup (map fig-to-markup figs))) - ) - (if (eq? (ly:music-property (car figs) 'bracket-start) #t) - (make-bracket-markup c) - c - ))) - - (let* - ( - (ends (recursive-split-at no-end-bracket? (reverse figures))) - (starts (map (lambda (x) (recursive-split-at no-start-bracket? x)) ends)) - ) - (make-dir-column-markup (map fig-seq-to-markup (apply append starts))) - )) + (define (filter-brackets i figs acc) + (cond + ((null? figs) acc) + (else + (filter-brackets (1+ i) (cdr figs) + + (append + (if (eq? (ly:music-property (car figs) 'bracket-start) #t) + (list i) + '()) + (if (eq? (ly:music-property (car figs) 'bracket-stop) #t) + (list i) + '()) + + acc))))) + + (set! (ly:grob-property grob 'text) + (make-bracketed-y-column-markup + (sort (filter-brackets 0 figures '()) <) + (map fig-to-markup figures) + ))) diff --git a/scm/define-context-properties.scm b/scm/define-context-properties.scm index ffa54d5939..736e5bd296 100644 --- a/scm/define-context-properties.scm +++ b/scm/define-context-properties.scm @@ -99,7 +99,9 @@ when finding a barcheck.") (barNumberVisibility ,procedure? "Procedure that takes an int and returns whether the corresponding bar number should be printed") - (bassFigureFormatFunction ,procedure? "Procedure that produces a markup text. It takes a list of @code{BassFigureEvent}s, and a context.") + (bassFigureFormatFunction ,procedure? "Procedure that is called +to produce the formatting for a @code{BassFigure} grob. It takes a +list of @code{BassFigureEvent}s, a context, and the grob to format.") (beatLength ,ly:moment? "The length of one beat in this time signature.") (beatGrouping ,list? "List of beatgroups. Eg. in 5/8 time @code{'(2 3)}.") diff --git a/scm/define-markup-commands.scm b/scm/define-markup-commands.scm index e714adba72..114cdf5a43 100644 --- a/scm/define-markup-commands.scm +++ b/scm/define-markup-commands.scm @@ -576,3 +576,92 @@ FIXME: is this working? (skipping I), and continues with double letters." (Text_item::interpret_markup paper props (number->markletter-string num))) + + + + +(def-markup-command (bracketed-y-column paper props indices args) + (list? markup-list?) + "Make a column of the markups in @var{args}, putting brackets around +the elements marked in @var{indices}, which is a list of numbers." + + (define (sublist l start stop) + (take (drop l start) (- (1+ stop) start)) ) + + (define (stencil-list-extent ss axis) + (cons + (apply min (map (lambda (x) (car (ly:stencil-extent x axis))) ss)) + (apply max (map (lambda (x) (cdr (ly:stencil-extent x axis))) ss)))) + + (define (stack-stencils stencils bskip last-stencil) + (cond + ((null? stencils) '()) + ((not last-stencil) + (cons (car stencils) + (stack-stencils (cdr stencils) bskip (car stencils)))) + (else + (let* + ((orig (car stencils)) + (handle (chain-assoc 'direction props)) + (dir (if (and (pair? handle) (ly:dir? (cdr handle))) + (cdr handle) + DOWN)) + (new (ly:stencil-moved-to-edge last-stencil Y dir + orig + 0.1 bskip)) + ) + + (cons new (stack-stencils (cdr stencils) bskip new)))) + )) + + (define (make-brackets stencils indices acc) + (if (and stencils + (pair? indices) + (pair? (cdr indices))) + (let* + ((encl (sublist stencils (car indices) (cadr indices))) + (x-ext (stencil-list-extent encl X)) + (y-ext (stencil-list-extent encl Y)) + (thick 0.10) + (pad 0.35) + (protusion (* 2.5 thick)) + (lb + (ly:stencil-translate-axis + (ly:bracket Y y-ext thick protusion) + (- (car x-ext) pad) X)) + (rb (ly:stencil-translate-axis + (ly:bracket Y y-ext thick (- protusion)) + (+ (cdr x-ext) pad) X)) + ) + + (make-brackets + stencils (cddr indices) + (append + (list lb rb) + acc))) + acc)) + + (let* + ((stencils + (map (lambda (x) + (interpret-markup + paper + props + x)) args)) + (leading + (cdr (chain-assoc 'baseline-skip props))) + (stacked (stack-stencils stencils 1.25 #f)) + (brackets (make-brackets stacked indices '())) + ) + + (apply ly:stencil-add + (append stacked brackets) + ))) + + + + + + + + diff --git a/scm/page-layout.scm b/scm/page-layout.scm index db61cee291..3cbed697c5 100644 --- a/scm/page-layout.scm +++ b/scm/page-layout.scm @@ -90,11 +90,11 @@ paper 'linewidth)) (font-family . roman)) (ly:paper-lookup paper 'font-defaults))))) - (interpret-markup paper props - (markup #:fill-line - ;; FIXME: font not found - ;; ("" #:bold (number->string page-number)))))) - ("" (number->string page-number)))))) + (interpret-markup paper props + (markup #:fill-line + ;; FIXME: font not found + ;; ("" #:bold (number->string page-number)))))) + ("" (number->string page-number)))))) (define-public (make-footer paper page-number) (let ((props (list (append `((linewidth . ,(ly:paper-get-number diff --git a/scm/part-combiner.scm b/scm/part-combiner.scm index f27fe34a94..316878f0e5 100644 --- a/scm/part-combiner.scm +++ b/scm/part-combiner.scm @@ -435,7 +435,7 @@ the mark when there are no spanners active." ;; autochange - fairly related to part combining. (define-public (make-autochange-music music) - (define (generate-split-list event-list acc) + (define (generate-split-list change-moment event-list acc) (if (null? event-list) acc (let* ((now-tun (caar event-list)) @@ -449,16 +449,27 @@ the mark when there are no spanners active." #f))) ;; tail recursive. (if (and pitch (not (= (ly:pitch-steps pitch) 0))) - (generate-split-list (cdr event-list) - (cons (cons now (sign (ly:pitch-steps pitch))) acc)) - (generate-split-list (cdr event-list) acc))))) + (generate-split-list #f + (cdr event-list) + (cons (cons + + (if change-moment + change-moment + now) + (sign (ly:pitch-steps pitch))) acc)) + (generate-split-list + (if pitch #f now) + (cdr event-list) acc))))) + (set! noticed '()) (let* ((m (make-music 'AutoChangeMusic)) (context (ly:run-translator music part-combine-listener)) (evs (last-pair noticed)) - (split (reverse! (generate-split-list (if (pair? evs) - (reverse! (cdar evs) '()) '()) - '()) + (split (reverse! (generate-split-list + #f + (if (pair? evs) + (reverse! (cdar evs) '()) '()) + '()) '()))) (set! (ly:music-property m 'element) music) (set! (ly:music-property m 'split-list) split) -- 2.39.5