From 226f7fd73e5dd8c207d0551c54adb4313ed35d10 Mon Sep 17 00:00:00 2001 From: hanwen Date: Wed, 23 Jul 2003 13:18:22 +0000 Subject: [PATCH] * buildscripts/lilypond-profile.sh: error message if script is not sourced. * lily/tuplet-bracket.cc (make_bracket): change edge-widen to bracket-flare (make_bracket): simplify code. * lily/parser.yy (verbose_command_req): catch typos in \key scale argument. * python/lilylib.py (lilypond_version_check): new function * scripts/lilypond-book.py (TexiPaper.incl_opt): idem * scripts/ly2dvi.py (run_lilypond): add version check. * scripts/lilypond-book.py (option_definitions): typo * scripts/ly2dvi.py (include_path): typo * Documentation/user/refman.itely: updates, fixes. --- ChangeLog | 16 ++++++++ Documentation/user/refman.itely | 2 +- buildscripts/lilypond-profile.sh | 10 ++++- input/regression/tup.ly | 35 ---------------- lily/lookup.cc | 14 +++---- lily/parser.yy | 13 ++++-- lily/piano-pedal-engraver.cc | 12 +++--- lily/text-spanner.cc | 19 ++++----- lily/tuplet-bracket.cc | 87 ++++++++++++++++++++-------------------- python/lilylib.py | 25 +++++++++--- scm/define-grob-properties.scm | 5 ++- scripts/lilypond-book.py | 4 ++ scripts/ly2dvi.py | 6 ++- 13 files changed, 131 insertions(+), 117 deletions(-) delete mode 100644 input/regression/tup.ly diff --git a/ChangeLog b/ChangeLog index 2b449c53a5..49345f56fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,21 @@ 2003-07-23 Han-Wen Nienhuys + * buildscripts/lilypond-profile.sh: error message if script is not + sourced. + + * lily/tuplet-bracket.cc (make_bracket): change edge-widen to + bracket-flare + (make_bracket): simplify code. + + * lily/parser.yy (verbose_command_req): catch typos in \key scale + argument. + + * python/lilylib.py (lilypond_version_check): new function + + * scripts/lilypond-book.py (TexiPaper.incl_opt): idem + + * scripts/ly2dvi.py (run_lilypond): add version check. + * scripts/lilypond-book.py (option_definitions): typo * scripts/ly2dvi.py (include_path): typo diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index 06e7ef0369..38ef0b1cfe 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -2614,7 +2614,7 @@ staff are squashed, and the staff itself has a single line: @menu * Percussion staves:: -* Percussion midi output:: +* Percussion MIDI output:: @end menu @node Percussion staves diff --git a/buildscripts/lilypond-profile.sh b/buildscripts/lilypond-profile.sh index f1a941c411..bc05e39979 100644 --- a/buildscripts/lilypond-profile.sh +++ b/buildscripts/lilypond-profile.sh @@ -6,8 +6,14 @@ # If run by hand or from you .profile, run as follows # . lilypond-profile - - +if [ `basename "$0"` = "lilypond-profile" ] ; then + echo "This script must be sourced, i.e." + echo "" + echo " . lilypond-profile" + echo "" + + exit 2 +fi if [ -z "$LILYPONDPREFIX" ]; then datadir=`echo "@local_lilypond_datadir@" | sed 's!//!/!g'` else diff --git a/input/regression/tup.ly b/input/regression/tup.ly deleted file mode 100644 index 0d6ef52e83..0000000000 --- a/input/regression/tup.ly +++ /dev/null @@ -1,35 +0,0 @@ -\version "1.7.18" -\header{ - -texidoc=" -Tuplets are indicated by a bracket with a number. There should be no -bracket if there is a beam exactly matching the length of the tuplet. -The bracket does not interfere with the stafflines, and the number is -centered in the gap in the bracket. - -The bracket stops at the end of the stems, if the stems have the same -direction as the - - -" - -} -\paper { raggedright= ##t } - -\score{ - \notes \context Voice \relative c'' { - \times 2/3 { \times 2/3 { a8 b c} c } - \times 2/3 { r8 b-[ f] } - \times 2/3 { r8 b r8 } - c4 | - - \times 3/4 { c4 c4 c4 c4 } c4 | - - \time 6/8 - \times 6/9 { c8 c c c c c c c c } - - } -} - - - diff --git a/lily/lookup.cc b/lily/lookup.cc index 0f7d9b8d76..b439d28c91 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -81,19 +81,19 @@ Lookup::dashed_slur (Bezier b, Real thick, Real dash) } Molecule -Lookup::line (Real th, Offset f, Offset t) +Lookup::line (Real th, Offset from, Offset to) { SCM at = scm_list_n (ly_symbol2scm ("draw-line"), gh_double2scm (th), - gh_double2scm (f[X_AXIS]), - gh_double2scm (f[Y_AXIS]), - gh_double2scm (t[X_AXIS]), - gh_double2scm (t[Y_AXIS]), + gh_double2scm (from[X_AXIS]), + gh_double2scm (from[Y_AXIS]), + gh_double2scm (to[X_AXIS]), + gh_double2scm (to[Y_AXIS]), SCM_UNDEFINED); Box box; - box.add_point (f); - box.add_point (t); + box.add_point (from); + box.add_point (to); box[X_AXIS].widen (th/2); box[Y_AXIS].widen (th/2); diff --git a/lily/parser.yy b/lily/parser.yy index cb9d8f14ce..7b8ba1f0cb 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -1433,11 +1433,16 @@ verbose_command_req: $$ = key; } | KEY NOTENAME_PITCH SCM_IDENTIFIER { + Music *key= MY_MAKE_MUSIC("KeyChangeEvent"); - - key->set_mus_property ("pitch-alist", $3); - key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy()); - ((Music*)key)->transpose (* unsmob_pitch ($2)); + if (scm_ilength ($3) > 0) + { + key->set_mus_property ("pitch-alist", $3); + key->set_mus_property ("tonic", Pitch (0,0,0).smobbed_copy()); + ((Music*)key)->transpose (* unsmob_pitch ($2)); + } else { + THIS->parser_error (_("Second argument must be pitch list.")); + } $$ = key; } diff --git a/lily/piano-pedal-engraver.cc b/lily/piano-pedal-engraver.cc index 60c9379321..5781110d76 100644 --- a/lily/piano-pedal-engraver.cc +++ b/lily/piano-pedal-engraver.cc @@ -219,7 +219,6 @@ Piano_pedal_engraver::process_acknowledged_grobs () void Piano_pedal_engraver::create_text_grobs (Pedal_info *p, SCM pedaltype) { - SCM b; SCM s = SCM_EOL; SCM strings = get_property ( ("pedal" + String (p->name_) + "Strings").to_str0 ()); @@ -293,7 +292,8 @@ Piano_pedal_engraver::create_text_grobs (Pedal_info *p, SCM pedaltype) if (gh_string_p (s)) { String propname = String (p->name_) + "Pedal"; - b = get_property (propname.to_str0 ()); + + SCM b = get_property (propname.to_str0 ()); p->item_ = new Item (b); p->item_->set_grob_property ("text", s); Axis_group_interface::add_element (p->line_spanner_, p->item_); @@ -381,11 +381,11 @@ Piano_pedal_engraver::create_bracket_grobs (Pedal_info *p, SCM pedaltype) /* Set this property for 'mixed style' pedals, Ped._______/\ , so the molecule function will shorten the ____ line by the length of the Ped. text. */ - + p->bracket_->set_grob_property ("text-start", - pedaltype == ly_symbol2scm ("mixed") ? - gh_bool2scm ( (bool) ! p->req_l_drul_[STOP]) : - gh_bool2scm (false)); + pedaltype == ly_symbol2scm ("mixed") + ? gh_bool2scm ( (bool) ! p->req_l_drul_[STOP]) + : gh_bool2scm (false)); /* Mixed style: Store a pointer to the preceding text for use in diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 8432a6cd76..5161d1bf2a 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -75,13 +75,6 @@ Text_spanner::brew_molecule (SCM smob) while (flip (&d) != LEFT); -#if 0 - /* - FIXME. - this switch sucks. --hwn - */ - // FIXME: ecs tells us -- only for (de)cresc. spanners - width += gh_scm2double (me->get_grob_property ("width-correct")); -#endif SCM properties = Font_interface::font_alist_chain (me); SCM edge_text = me->get_grob_property ("edge-text"); @@ -113,12 +106,18 @@ Text_spanner::brew_molecule (SCM smob) shorten[LEFT] = 0; shorten[RIGHT] = 0; + SCM ew = me->get_grob_property ("edge-flare"); SCM s = me->get_grob_property ("shorten-pair"); if (gh_pair_p (s)) { span_points[LEFT] += gh_scm2double (ly_car (s)); span_points[RIGHT] -= gh_scm2double (ly_cdr (s)); } + if (gh_pair_p (ew)) + { + span_points[LEFT] += gh_scm2double (ly_car (ew)); + span_points[RIGHT] -= gh_scm2double (ly_cdr (ew)); + } Real thick = me->get_paper ()->get_var ("linethickness"); SCM st = me->get_grob_property ("thickness"); @@ -129,7 +128,6 @@ Text_spanner::brew_molecule (SCM smob) Drul_array edge_line; s = me->get_grob_property ("edge-height"); - SCM ew = me->get_grob_property ("edge-widen"); if (gh_pair_p (s)) { Direction d = LEFT; @@ -212,7 +210,6 @@ Text_spanner::setup_pedal_bracket(Spanner *me) Drul_array height, width, shorten, r; SCM pa = me->get_grob_property ("if-text-padding"); - SCM ew = me->get_grob_property ("edge-widen"); SCM eh = me->get_grob_property ("edge-height"); SCM sp = me->get_grob_property ("shorten-pair"); @@ -235,8 +232,6 @@ Text_spanner::setup_pedal_bracket(Spanner *me) width[d] = 0; height[d] = 0; shorten[d] = 0; - if (ly_number_pair_p (ew)) - width[d] += gh_scm2double (index_get_cell (ew, d)); if (!broken[d] && (ly_number_pair_p (eh))) height[d] += gh_scm2double (index_get_cell (eh, d)); if (ly_number_pair_p (sp)) @@ -245,6 +240,7 @@ Text_spanner::setup_pedal_bracket(Spanner *me) while (flip (&d) != LEFT); Real extra_short = 0; + // For 'Mixed' style pedals, i.e. a bracket preceded by text: Ped._____| // need to shorten by the extent of the text grob if (to_boolean (me->get_grob_property ("text-start"))) @@ -286,7 +282,6 @@ Text_spanner::setup_pedal_bracket(Spanner *me) } me->set_grob_property ("edge-height", ly_interval2scm (height)); - me->set_grob_property ("edge-widen", ly_interval2scm(width)); me->set_grob_property ("shorten-pair", ly_interval2scm (shorten)); } diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index 3832249a07..56f9585c8f 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -69,7 +69,7 @@ Tuplet_bracket::parallel_beam (Grob *me, Link_array const &cols, bool *equ Spanner*sp = dynamic_cast (me); *equally_long= false; - if (! ( b1 && (b1 == b2) && !sp->broken_b() )) + if (! (b1 && (b1 == b2) && !sp->broken_b())) return 0; Link_array beam_stems = Pointer_group_interface__extract_grobs @@ -177,19 +177,19 @@ Tuplet_bracket::brew_molecule (SCM smob) lt *= gh_scm2double (thick); SCM gap = me->get_grob_property ("gap"); - SCM ew = me->get_grob_property ("edge-widen"); + SCM fl = me->get_grob_property ("bracket-flare"); SCM eh = me->get_grob_property ("edge-height"); SCM sp = me->get_grob_property ("shorten-pair"); Direction d = LEFT; - Drul_array height, width, shorten; + Drul_array height, flare, shorten; do { - width[d] = height[d] = shorten[d] = 0.0; - if ( ly_number_pair_p (ew) ) - width[d] += gh_scm2double (index_get_cell (ew, d)); - if ( ly_number_pair_p (eh) ) + flare[d] = height[d] = shorten[d] = 0.0; + if (ly_number_pair_p (fl)) + flare[d] += gh_scm2double (index_get_cell (fl, d)); + if (ly_number_pair_p (eh)) height[d] += gh_scm2double (index_get_cell (eh, d)) * - dir; - if ( ly_number_pair_p (sp) ) + if (ly_number_pair_p (sp)) shorten[d] += gh_scm2double (index_get_cell (sp, d)); } while (flip (&d) != LEFT); @@ -198,7 +198,7 @@ Tuplet_bracket::brew_molecule (SCM smob) w, ry - ly, lt, height, gh_scm2double (gap), - width, + flare, shorten); mol.add_molecule (brack); } @@ -210,49 +210,50 @@ Tuplet_bracket::brew_molecule (SCM smob) /* should move to lookup? + + TODO: this will fail for very short (shorter than the flare) + brackets. */ Molecule Tuplet_bracket::make_bracket (Axis protusion_axis, Real dx, Real dy, Real thick, Drul_array height, Real gap, - Drul_array widen, + Drul_array flare, Drul_array shorten) { - Real len = Offset (dx,dy).length (); - Real gapx = dx * (gap / len); - Real gapy = dy * (gap / len); - Drul_array shortx, shorty; + Offset dz = Offset (dx,dy); + Drul_array corners (Offset(0,0), dz); + + Real length = dz.length (); + Drul_array gap_corners; + + + Axis bracket_axis = other_axis (protusion_axis); + + Drul_array straight_corners = corners; + Direction d = LEFT; do { - shortx[d] = dx * (shorten[d] / len); - shorty[d] = dy * (shorten[d] / len); - } - while (flip (&d) != LEFT); - Axis other = other_axis (protusion_axis); - - Molecule l1 = Lookup::line (thick, Offset(shortx[LEFT], shorty[LEFT]), - Offset ( (dx - gapx)/2, (dy - gapy)/2 )); - - Molecule l2 = Lookup::line (thick, Offset((dx + gapx) / 2,(dy + gapy) / 2), - Offset (dx - shortx[RIGHT], dy - shorty[RIGHT])); - - Offset protusion; - protusion[other] = -widen[LEFT]; - protusion[protusion_axis] = height[LEFT]; - Molecule p1 = Lookup::line (thick, - Offset(shortx[LEFT], shorty[LEFT]), - Offset(shortx[LEFT], shorty[LEFT]) + protusion); - protusion[other] = widen[RIGHT]; - protusion[protusion_axis] = height[RIGHT]; - Molecule p2 = Lookup::line (thick, - Offset(dx - shortx[RIGHT], dy - shorty[RIGHT]), - Offset(dx - shortx[RIGHT], dy - shorty[RIGHT]) + protusion); + straight_corners[d] += - d * shorten[d] /length * dz; + gap_corners[d] = (dz * 0.5) + d * gap / length * dz; + } while (flip (&d) != LEFT); + + Drul_array flare_corners = straight_corners; + do { + flare_corners[d][bracket_axis] = straight_corners[d][bracket_axis]; + flare_corners[d][protusion_axis] += height[d]; + straight_corners[d][bracket_axis] += - d * flare[d]; + } while (flip (&d) != LEFT); Molecule m; - m.add_molecule (p1); - m.add_molecule (p2); - m.add_molecule (l1); - m.add_molecule (l2); + do { + + m.add_molecule (Lookup::line (thick, straight_corners[d], + gap_corners[d])); + + m.add_molecule (Lookup::line (thick, straight_corners[d], + flare_corners[d])); + } while (flip (&d) != LEFT); return m; } @@ -403,7 +404,7 @@ Tuplet_bracket::after_line_breaking (SCM smob) } if (dynamic_cast (me)->broken_b ()) { - me->warning ( "Tuplet_bracket was across linebreak. Farewell cruel world."); + me->warning ("Tuplet_bracket was across linebreak. Farewell cruel world."); me->suicide(); return SCM_UNSPECIFIED; } @@ -501,5 +502,5 @@ Tuplet_bracket::add_column (Grob*me, Item*n) ADD_INTERFACE (Tuplet_bracket,"tuplet-bracket-interface", "A bracket with a number in the middle, used for tuplets.", - "note-columns edge-widen edge-height shorten-pair padding gap left-position right-position bracket-visibility number-visibility thickness direction"); + "note-columns bracket-flare edge-height shorten-pair padding gap left-position right-position bracket-visibility number-visibility thickness direction"); diff --git a/python/lilylib.py b/python/lilylib.py index a7b6411bab..ccd5ab842e 100644 --- a/python/lilylib.py +++ b/python/lilylib.py @@ -101,12 +101,8 @@ except: return s underscore = _ -program_version = '@TOPLEVEL_VERSION@' -if program_version == '@' + 'TOPLEVEL_VERSION' + '@': - program_version = '1.7.14' - def identify (port): - port.write ('%s (GNU LilyPond) %s\n' % (__main__.program_name, program_version)) + port.write ('%s (GNU LilyPond) %s\n' % (__main__.program_name, __main__.program_version)) def warranty (): identify (sys.stdout) @@ -202,6 +198,25 @@ def help (): (_ ("Report bugs to %s") % 'bug-lilypond@gnu.org'), ('\n')] map (sys.stdout.write, ls) + +def lilypond_version (binary): + p = read_pipe ('%s --version ' % binary) + x = [] + def catch_version (match): + x.append (match.group (1)) + re.sub ('GNU LilyPond ([^\n]+)\n', catch_version, p) + x.append ('not found') + + return x[0] + +def lilypond_version_check (binary, req): + if req[0] <> '@' : + v = lilypond_version (binary) + if v <> req: + error (_("Binary %s has version %s, looking for version %s") % \ + (binary, v, req)) + sys.exit (1) + def setup_temp (): diff --git a/scm/define-grob-properties.scm b/scm/define-grob-properties.scm index cf6484e9ad..a7f4818082 100644 --- a/scm/define-grob-properties.scm +++ b/scm/define-grob-properties.scm @@ -177,7 +177,10 @@ mean centre distance weighted per note (grob-property-description 'dot-count integer? "number of dots.") (grob-property-description 'duration-log integer? "2-log of the notehead duration, i.e. 0=whole note, 1 = half note, etc.") (grob-property-description 'edge-height pair? "a cons that specifies the heights of the vertical edges '(LEFT-height . RIGHT-height).") -(grob-property-description 'edge-widen pair? "a cons that specifies the widths of the slanted edges '(LEFT-width . RIGHT-width).") +(grob-property-description 'bracket-flare number-pair? "a pair + that specifies how much edges of brackets should slant outward. + Value 0.0 means straight edges") + (grob-property-description 'edge-text pair? "a cons that specifies the texts to be set at the edges '(LEFT-text . RIGHT-text).") (grob-property-description 'elements grob-list? "list of grobs, type depending on the Grob where this is set in.") (grob-property-description 'expand-limit integer? "maximum number of measures expanded in church rests.") diff --git a/scripts/lilypond-book.py b/scripts/lilypond-book.py index df3aba4508..54a70d3847 100644 --- a/scripts/lilypond-book.py +++ b/scripts/lilypond-book.py @@ -103,6 +103,7 @@ global _;_=ly._ global re;re = ly.re # lilylib globals +program_version = '@TOPLEVEL_VERSION@' program_name = 'lilypond-book' verbose_p = 0 pseudo_filter_p = 0 @@ -1371,6 +1372,9 @@ def compile_all_files (chunks): texfiles = string.join (tex) cmd = string.join ((lilypond_binary, lilyopts, g_extra_opts, texfiles)) + + ly.lilypond_version_check (lilypond_binary, '@TOPLEVEL_VERSION@') + ly.system (cmd, ignore_error = 0, progress_p = 1) # diff --git a/scripts/ly2dvi.py b/scripts/ly2dvi.py index d8133ee214..dc3725b117 100644 --- a/scripts/ly2dvi.py +++ b/scripts/ly2dvi.py @@ -95,6 +95,7 @@ if os.environ.has_key ('LILYPONDPREFIX') : while datadir[-1] == os.sep: datadir= datadir[:-1] + sys.path.insert (0, os.path.join (datadir, 'python')) # Customize these @@ -106,6 +107,7 @@ global re;re = ly.re # lilylib globals program_name = 'ly2dvi' +program_version = '@TOPLEVEL_VERSION@' verbose_p = 0 pseudo_filter_p = 0 original_dir = os.getcwd () @@ -262,7 +264,7 @@ def run_lilypond (files, dep_prefix): if debug_p: ly.print_environment () - + cmd = string.join ((lilypond_binary, opts, fs)) status = ly.system (cmd, ignore_error = 1, progress_p = 1) signal = 0x0f & status @@ -779,6 +781,8 @@ if not files: if 1: ly.identify (sys.stderr) + ly.lilypond_version_check (lilypond_binary, '@TOPLEVEL_VERSION@') + original_output = output_name # Ugh, maybe make a setup () function -- 2.11.4.GIT