From c62c797100967eb753e5d9c6e30d32e493196fd5 Mon Sep 17 00:00:00 2001 From: hanwen Date: Mon, 19 Jan 2004 12:34:05 +0000 Subject: [PATCH] * lily/tuplet-bracket.cc (calc_position_and_height): check musical slope against graphical slope. * lily/ottava-bracket.cc (brew_molecule): support minimum-length for ottava bracket. * lily/side-position-interface.cc (general_side_position): opps. reinstate *dir. * lily/parser.yy: plug many memory leaks. We're down to 4 for each parser run. * lily/tuplet-bracket.cc: remove calc_dy (). * Documentation/user/refman.itely (Balloon help): document balloon help --- ChangeLog | 23 ++++++++++++++++++- Documentation/user/refman.itely | 39 +++++++++++++++++++++++++-------- lily/include/paper-score.hh | 1 - lily/include/tuplet-bracket.hh | 1 - lily/music-output-def.cc | 4 +++- lily/ottava-bracket.cc | 14 +++++++----- lily/ottava-engraver.cc | 2 +- lily/paper-def.cc | 10 +++++++-- lily/paper-score.cc | 7 +----- lily/parser.yy | 13 ++++++++--- lily/side-position-interface.cc | 2 +- lily/translator-ctors.cc | 2 ++ lily/tuplet-bracket.cc | 30 +++++++++++-------------- ly/init.ly | 2 -- scm/define-grob-properties.scm | 1 - scm/define-grobs.scm | 8 ++----- scm/lily.scm | 2 ++ scripts/convert-ly.py | 7 ++++++ scripts/lilypond-book.py | 3 ++- 19 files changed, 113 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7e3a118da2..87d8afc3fa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,30 @@ +2004-01-19 Han-Wen Nienhuys + + * lily/tuplet-bracket.cc (calc_position_and_height): check musical + slope against graphical slope. + + * lily/ottava-bracket.cc (brew_molecule): support minimum-length + for ottava bracket. + + * lily/side-position-interface.cc (general_side_position): + opps. reinstate *dir. + + * lily/parser.yy: plug many memory leaks. We're down to 4 for each + parser run. + + * lily/tuplet-bracket.cc: remove calc_dy (). + + * Documentation/user/refman.itely (Balloon help): document balloon + help + 2004-01-19 Jan Nieuwenhuizen * scm/document-backend.scm (check-dangling-properties): Grob properties are defined define-grob-properties.scm. - + 2004-01-19 Han-Wen Nienhuys + + * VERSION: release 2.1.12 * scm/define-grobs.scm (all-grob-descriptions): larger font for ChordName diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index a474382d0a..1e1046de27 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -7482,7 +7482,33 @@ such as fermatas to a @code{\notes@{@}} block. @node Balloon help @subsection Balloon help +Elements of notation can be marked and named with the help of a square +balloon. The primary purpose of this feature is to explain notation. +The following example demonstrates its use. + +@lilypond[verbatim,fragment,singleline,relative 1] + \context Voice + \applyoutput + #(add-balloon-text 'NoteHead "heads, or tails?" + '(1 . -3)) + c8 +@end lilypond + +@noindent +The function @code{add-balloon-text} takes the name of a grob, the +label to print and where to put the label relative to the object. In +the above example, the text ``heads or tails?'' ends 3 spaces below +the `balloon.' + +@cindex balloon +@cindex notation, explaining + +@seealso + +Internals: @internalsref{text-balloon-interface} + +Examples: @inputfileref{input/regression,balloon.ly} @node Easy Notation note heads @subsection Easy Notation note heads @@ -7500,19 +7526,14 @@ used in music aimed at beginners: } @end lilypond -The @code{EasyNotation} variable overrides a @internalsref{Score} context. -You probably will want to print it with magnification or a -large font size to make it more readable. To print with -magnification, you must create a DVI file (with @file{lilypond}) and -then enlarge it with something like @file{dvips -x 2000 file.dvi}. -See the @code{dvips} documentation for more details. To print with a -larger font, see @ref{Font Size}. - +The @code{EasyNotation} variable overrides a @internalsref{Score} +context. To make the letters readable, it has to be printed in a +large font size. To print with a larger font, see @ref{Font Size}. @cindex Xdvi @cindex ghostscript -If you view the result with Xdvi, then staff lines will show through +If you view the result with Xdvi, then staff lines may show through the letters. Printing the PostScript file obtained does produce the correct result. diff --git a/lily/include/paper-score.hh b/lily/include/paper-score.hh index 505a2fc571..d6ff25c7d6 100644 --- a/lily/include/paper-score.hh +++ b/lily/include/paper-score.hh @@ -43,7 +43,6 @@ public: protected: /* MAIN ROUTINES */ virtual void process (String); - private: /// before calc_breaking void preprocess (); diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index 004e1485a3..c0c6be4540 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -26,7 +26,6 @@ public: static void add_column (Grob*me,Item*); static void add_beam (Grob*me,Grob*); static Grob *parallel_beam (Grob *me, Link_array const&cols, bool *equally_long); - static void calc_dy (Grob*,Real *) ; static void calc_position_and_height (Grob*,Real*,Real *dy); DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); diff --git a/lily/music-output-def.cc b/lily/music-output-def.cc index ea96c452be..c7ddfb2688 100644 --- a/lily/music-output-def.cc +++ b/lily/music-output-def.cc @@ -113,7 +113,9 @@ int Music_output_def::print_smob (SCM s, SCM p, scm_print_state *) { Music_output_def * def = unsmob_music_output_def (s); - scm_puts ("#", p); return 1; diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc index bd64057891..1df2dbafbe 100644 --- a/lily/ottava-bracket.cc +++ b/lily/ottava-bracket.cc @@ -91,11 +91,15 @@ Ottava_bracket::brew_molecule (SCM smob) /* 0.3 is ~ italic correction. */ - Real text_offset = text.extent (X_AXIS).is_empty () + Real text_size = text.extent (X_AXIS).is_empty () ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; - + + span_points[LEFT] = span_points[LEFT] + get_grob_property ("minimum-length"), -1.0)); + Interval bracket_span_points = span_points; - bracket_span_points[LEFT] += text_offset; + bracket_span_points[LEFT] += text_size; Drul_array edge_height = robust_scm2interval (me->get_grob_property ("edge-height"), Interval (1.0, 1.0)); @@ -112,7 +116,7 @@ Ottava_bracket::brew_molecule (SCM smob) edge_height[RIGHT] = 0.0; Molecule b; - if (!bracket_span_points.is_empty ()) + if (!bracket_span_points.is_empty () && bracket_span_points.length () > 0.001) b = Tuplet_bracket::make_bracket (me, Y_AXIS, Offset (bracket_span_points.length (), 0), edge_height, @@ -133,5 +137,5 @@ Ottava_bracket::brew_molecule (SCM smob) ADD_INTERFACE (Ottava_bracket, "ottava-bracket-interface", "An ottava bracket", - "edge-height bracket-flare shorten-pair"); + "edge-height bracket-flare shorten-pair minimum-length"); diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index fba507e10c..c612e147ff 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -49,7 +49,7 @@ Ottava_spanner_engraver::process_music () span_ = 0; if (gh_string_p (ott)) { - span_ = new Spanner (get_property ("OttavaSpanner")); + span_ = new Spanner (get_property ("OttavaBracket")); span_->set_grob_property ("text", ott); announce_grob (span_, SCM_EOL); diff --git a/lily/paper-def.cc b/lily/paper-def.cc index a784bfab15..125eadbdfa 100644 --- a/lily/paper-def.cc +++ b/lily/paper-def.cc @@ -85,7 +85,7 @@ Paper_def::get_paper_outputter (String outname) const /* - todo: use symbols and hashtable idx? + Todo: use symbols and hashtable idx? */ Font_metric * Paper_def::find_font (SCM fn, Real m) @@ -103,7 +103,10 @@ Paper_def::find_font (SCM fn, Real m) Font_metric* f=0; if (gh_list_p (fn)) { - f = new Virtual_font_metric (fn, m, this); + f = new Virtual_font_metric (fn, m, this); // TODO: GC protection. + + scaled_fonts_ = scm_acons (key, f->self_scm (), scaled_fonts_); + scm_gc_unprotect_object (f->self_scm ()); } else { @@ -132,6 +135,9 @@ Paper_def::font_descriptions ()const for (SCM s = scaled_fonts_; gh_pair_p (s); s = ly_cdr (s)) { SCM desc = ly_caar (s); + if (!gh_string_p (gh_car (desc))) + continue ; + SCM mdesc = unsmob_metrics (ly_cdar (s))->description_; l = gh_cons (gh_cons (mdesc, desc), l); diff --git a/lily/paper-score.cc b/lily/paper-score.cc index 5e31a512ec..887f4a7a67 100644 --- a/lily/paper-score.cc +++ b/lily/paper-score.cc @@ -42,15 +42,10 @@ Paper_score::typeset_line (System *l) main_smob_ = gh_cons (l->self_scm (), main_smob_); l->pscore_ = this; -#if 0 - /* - We don't unprotect l->self_scm (), we haven't got any place else to - protect it from collection. */ -#endif - scm_gc_unprotect_object (l->self_scm()); } + Paper_score::Paper_score (Paper_score const &s) : Music_output (s) { diff --git a/lily/parser.yy b/lily/parser.yy index 91fd3b613f..a2da89103c 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -464,10 +464,13 @@ toplevel_expression: scm_gc_unprotect_object (sc->self_scm()); } | output_def { + SCM id = SCM_EOL; if (dynamic_cast ($1)) - THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultpaper"), $1->self_scm ()); + id = scm_makfrom0str ("$defaultpaper"); else if (dynamic_cast ($1)) - THIS->lexer_->set_identifier (scm_makfrom0str ("$defaultmidi"), $1->self_scm ()); + id = scm_makfrom0str ("$defaultmidi"); + THIS->lexer_->set_identifier (id, $1->self_scm ()); + scm_gc_unprotect_object ($1->self_scm ()); } ; @@ -645,7 +648,7 @@ score_body: } | SCORE_IDENTIFIER { - $$ = unsmob_score ($1); + $$ = new Score ( *unsmob_score ($1)); $$->set_spot (THIS->here_input ()); } | score_body lilypond_header { @@ -653,6 +656,7 @@ score_body: } | score_body output_def { $$->defs_.push ($2); + scm_gc_unprotect_object ($2->self_scm ()); } | score_body error { @@ -724,6 +728,7 @@ music_output_def_body: Midi_def * md = dynamic_cast ($$); if (md) md->set_tempo (d->get_length (), m); + scm_gc_unprotect_object ($2->self_scm ()); } | music_output_def_body error { @@ -1993,6 +1998,8 @@ simple_element: velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED)); velt->set_spot (i); + scm_gc_unprotect_object (ev->self_scm()); + $$ = velt; } | MULTI_MEASURE_REST optional_notemode_duration { diff --git a/lily/side-position-interface.cc b/lily/side-position-interface.cc index f10f80073a..af50501c94 100644 --- a/lily/side-position-interface.cc +++ b/lily/side-position-interface.cc @@ -106,7 +106,7 @@ Side_position_interface::general_side_position (Grob * me, Axis a, bool use_exte SCM minimum = me->get_grob_property ("minimum-space"); Real total_off = dim.linear_combination (dir) - off; - total_off += robust_scm2double ( me->get_grob_property ("padding"), 0); + total_off += dir * robust_scm2double (me->get_grob_property ("padding"), 0); if (gh_number_p (minimum) && dir diff --git a/lily/translator-ctors.cc b/lily/translator-ctors.cc index 783c39698b..a1e7fca4db 100644 --- a/lily/translator-ctors.cc +++ b/lily/translator-ctors.cc @@ -38,6 +38,8 @@ add_translator (Translator *t) SCM k= ly_symbol2scm (classname (t)); global_translator_dict->set (k, t->self_scm ()); + + scm_gc_unprotect_object (t->self_scm ()); } Translator* diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 7e589483ac..18e21a57df 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -318,8 +318,20 @@ Tuplet_bracket::calc_position_and_height (Grob*me,Real *offset, Real * dy) Interval lv =columns[l]->extent (commony, Y_AXIS); rv.unite (staff); lv.unite (staff); + Real graphical_dy = rv[dir] - lv[dir]; + + Slice ls = Note_column::head_positions_interval (columns[l]); + Slice rs = Note_column::head_positions_interval (columns[r]); - *dy = rv[dir] - lv[dir]; + Interval musical_dy; + musical_dy[UP] = rs[UP] - ls[UP]; + musical_dy[DOWN] = rs[DOWN] - ls[DOWN]; + if (sign (musical_dy[UP]) != sign (musical_dy[DOWN])) + *dy = 0.0; + else if (sign (graphical_dy) != sign (musical_dy[DOWN])) + *dy = 0.0; + else + *dy = graphical_dy; } else * dy = 0; @@ -379,22 +391,6 @@ Tuplet_bracket::calc_position_and_height (Grob*me,Real *offset, Real * dy) } -/* - use first -> last note for slope, -*/ -void -Tuplet_bracket::calc_dy (Grob*me,Real * dy) -{ - Link_array columns= - Pointer_group_interface__extract_grobs (me, (Grob*)0, "note-columns"); - - /* - ugh. refps. - */ - Direction d = get_grob_direction (me); - *dy = columns.top ()->extent (columns.top (), Y_AXIS) [d] - - columns[0]->extent (columns[0], Y_AXIS) [d]; -} /* diff --git a/ly/init.ly b/ly/init.ly index 0bd5ec749a..4971f64381 100644 --- a/ly/init.ly +++ b/ly/init.ly @@ -1,7 +1,5 @@ % Toplevel initialisation file. - - #(define-public point-and-click #f) #(define-public midi-debug #f) diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index 5141b56c17..3550de13ce 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -483,7 +483,6 @@ The following variables are predefined: @code{all-visible}, (grob-property-description 'word-space ly:dimension? "elongate left (?) by this much (FIXME: cumbersome semantics).") (grob-property-description 'width ly:dimension? "width of a grob measured in staff space.") -(grob-property-description 'width-correct ly:dimension? "width correction for (de)cresc. text spanners.") (grob-property-description 'x-gap ly:dimension? "horizontal gap between notehead and tie.") (grob-property-description 'x-offset ly:dimension? "extra horizontal offset for ligature heads.") (grob-property-description 'y-free ly:dimension? "minimal vertical gap between slur and noteheads or stems.") diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index 18e30c6bf0..d963bf5a7c 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -397,7 +397,6 @@ (spacing-procedure . ,Spanner::set_spacing_rods) (minimum-length . 2.0) (if-text-padding . 1.0) - (width-correct . -1.0) (dash-length . 4.0) (self-alignment-Y . 0) (Y-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) @@ -724,7 +723,6 @@ (font-family . roman) (style . line) (if-text-padding . 1.0) - (width-correct . 0) (enclose-bounds . #t) (direction . -1) (bracket-flare . (0.5 . 0.5)) @@ -1067,14 +1065,13 @@ ;; urg, only for (de)cresc. text spanners (if-text-padding . 1.0) - (width-correct . -1) (dash-fraction . 0.2) (dash-period . 3.0) (direction . 1) (meta . ((interfaces . (text-spanner-interface side-position-interface font-interface spanner-interface)))) )) - (OttavaSpanner + (OttavaBracket . ( (Y-offset-callbacks . (,Side_position_interface::out_of_staff ,Side_position_interface::aligned_side)) @@ -1086,8 +1083,7 @@ (staff-padding . 1.0) (padding . 1.0) (enclose-bounds . #t) - (width-correct . 0.0) - (style . dashed-line) + (minimum-length . 1.0) (dash-fraction . 0.3) (edge-height . (0 . 1.2)) (direction . 1) diff --git a/scm/lily.scm b/scm/lily.scm index 63d09e7d70..a1d7552b1c 100644 --- a/scm/lily.scm +++ b/scm/lily.scm @@ -13,6 +13,8 @@ (srfi srfi-13) ;strings ) +(define-public (myd k v) (display k) (display ": ") (display v) (display ", ")) + ;;; General settings ;;; debugging evaluator is slower. This should ;;; have a more sensible default. diff --git a/scripts/convert-ly.py b/scripts/convert-ly.py index c09c24a366..b896051802 100644 --- a/scripts/convert-ly.py +++ b/scripts/convert-ly.py @@ -1687,6 +1687,13 @@ conversions.append (((2,1,11), conv, """\\include "paper16.ly" -> #(set-staff-si """)) +def conv (str): + str =re.sub (r"OttavaSpanner", r"OttavaBracket", str) + return str + +conversions.append (((2,1,12), conv, """OttavaSpanner -> OttavaBracket""")) + + ################################ # END OF CONVERSIONS ################################ diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index 10b5863d74..65032d824b 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -1414,7 +1414,8 @@ def compile_all_files (chunks): ly.system ("dvips -Ppdf -u+lilypond.map -E -o %s.eps %s" % (file, file)) map (to_eps, eps) - map (ly.make_ps_images, map (lambda x: x + '.eps', png)) + for p in png: + ly.make_ps_images (p + '.eps', resolution=110) os.chdir (d) -- 2.39.5