From 3512ac1f9e6ac4d96f0a486ba8f5968ccf0ce507 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 26 Jul 2006 11:40:14 +0000 Subject: [PATCH] * scm/output-ps.scm (dashed-line): add phase argument to dashed-line. * lily/bar-line.cc (dashed_bar_line): new function. (compound_barline): support \bar "dashed". * lily/lily-parser-scheme.cc (LY_DEFINE): only write --output=DIR to DIR/BASE if it is a dir. * flower/file-name.cc (file_part): new function (dir_part): new function * lily/lily-parser-scheme.cc (LY_DEFINE): * DEDICATION: update --- ChangeLog | 29 +++++++++- DEDICATION | 4 +- Documentation/topdocs/NEWS.tely | 9 ++++ flower/file-name.cc | 39 ++++++++++++-- flower/include/file-name.hh | 3 ++ input/regression/bar-line-dashed.ly | 17 ++++++ lily/bar-line.cc | 82 ++++++++++++++++++++++++++++- lily/include/bar-line.hh | 1 + lily/instrument-name-engraver.cc | 8 ++- lily/lily-parser-scheme.cc | 11 +++- lily/line-interface.cc | 1 + python/convertrules.py | 2 +- scm/define-grobs.scm | 1 + scm/output-ps.scm | 9 ++-- scm/output-svg.scm | 2 +- scm/output-tex.scm | 4 +- scripts/midi2ly.py | 2 - 17 files changed, 201 insertions(+), 23 deletions(-) create mode 100644 input/regression/bar-line-dashed.ly diff --git a/ChangeLog b/ChangeLog index 1bf8a51173..91450f9371 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,33 @@ +2006-07-26 Han-Wen Nienhuys + + * scm/output-ps.scm (dashed-line): add phase argument to + dashed-line. + + * lily/bar-line.cc (dashed_bar_line): new function. + (compound_barline): support \bar "dashed". + + * lily/lily-parser-scheme.cc (LY_DEFINE): only write + --output=DIR to DIR/BASE if it is a dir. + + * flower/file-name.cc (file_part): new function + (dir_part): new function + + * lily/lily-parser-scheme.cc (LY_DEFINE): + + * DEDICATION: update + +2006-07-25 Han-Wen Nienhuys + + * lily/instrument-name-engraver.cc: formatting. + + * python/convertrules.py (conv): bugfix for \epsfile. + 2006-07-25 Joe Neeman * lily/grob.cc: - * lily/gourlay-breaking.cc: Oops, these should have been included in my last - commit + + * lily/gourlay-breaking.cc: Oops, these should have been included + in my last commit 2006-07-24 Han-Wen Nienhuys diff --git a/DEDICATION b/DEDICATION index f7bbafa0a4..264945471c 100644 --- a/DEDICATION +++ b/DEDICATION @@ -8,8 +8,8 @@ Those deserving special mentioning (in no particular order): Esther, Marijke, Heike, Inge, Judith, Hannah, Auke, Ilse, Evelyn, Maartje, Suzanne, Ilse (gee, again?), Marieke, Irene, Martine, Idwine, -Hanna, Lonneke, Elisha, Anna and last (but certainly not least) -Janneke! +Hanna, Lonneke, Elisha, Anna, Janneke and last (but certainly not +least) Janneke! HWN diff --git a/Documentation/topdocs/NEWS.tely b/Documentation/topdocs/NEWS.tely index df0c374f26..974baf3111 100644 --- a/Documentation/topdocs/NEWS.tely +++ b/Documentation/topdocs/NEWS.tely @@ -66,6 +66,15 @@ which scares away people. @end ignore +@item +Barlines can be dashed now, + +@lilypond[relative,ragged-right,fragment] +c4 \bar "dashed" c4 +@end lilypond + +This feature was sponsored by Kieren MacMillan. + @item Grace notes maybe forced to use floating spacing, diff --git a/flower/file-name.cc b/flower/file-name.cc index 66b1aaa114..787c27f25a 100644 --- a/flower/file-name.cc +++ b/flower/file-name.cc @@ -73,7 +73,13 @@ dir_name (string const file_name) ssize n = s.length (); if (n && s[n - 1] == '/') s[n - 1] = 0; - s = s.substr (0, s.rfind ('/')); + if (s.rfind ('/') != NPOS) + { + s = s.substr (0, s.rfind ('/')); + } + else + s = ""; + return s; } @@ -88,23 +94,46 @@ get_working_directory () /* Join components to full file_name. */ string -File_name::to_string () const +File_name::dir_part () const { string s; if (!root_.empty ()) s = root_ + ::to_string (ROOTSEP); + if (!dir_.empty ()) { s += dir_; - if (!base_.empty () || !ext_.empty ()) - s += ::to_string (DIRSEP); } - s += base_; + + return s; +} + + +string +File_name::file_part () const +{ + string s; + s = base_; if (!ext_.empty ()) s += ::to_string (EXTSEP) + ext_; return s; } +string +File_name::to_string () const +{ + string d = dir_part (); + string f = file_part (); + + if (!f.empty () + && !dir_.empty()) + { + d += ::to_string (DIRSEP); + } + + return d + f; +} + File_name::File_name (string file_name) { #ifdef __CYGWIN__ diff --git a/flower/include/file-name.hh b/flower/include/file-name.hh index edfa72c23f..3d1a2d0fb2 100644 --- a/flower/include/file-name.hh +++ b/flower/include/file-name.hh @@ -27,6 +27,9 @@ public: bool is_absolute () const; string to_string () const; + + string dir_part () const; + string file_part () const; }; #endif /* FILE_NAME */ diff --git a/input/regression/bar-line-dashed.ly b/input/regression/bar-line-dashed.ly new file mode 100644 index 0000000000..11138d2640 --- /dev/null +++ b/input/regression/bar-line-dashed.ly @@ -0,0 +1,17 @@ + +\header { texidoc = "The dashes in a dashed bar line covers staff + lines exactly. Dashed barlines between staves start and end on a + half dash precisely." } + +\version "2.9.13" + +\paper { ragged-right = ##t } + +\relative \new StaffGroup << + \new Staff { + c4 \bar "dashed" c } + \new Staff { + c c + } +>> + diff --git a/lily/bar-line.cc b/lily/bar-line.cc index cd508de8bf..0c5c768f22 100644 --- a/lily/bar-line.cc +++ b/lily/bar-line.cc @@ -14,6 +14,7 @@ #include "output-def.hh" #include "paper-column.hh" #include "staff-symbol-referencer.hh" +#include "line-interface.hh" MAKE_SCHEME_CALLBACK (Bar_line, print, 1); SCM @@ -131,6 +132,10 @@ Bar_line::compound_barline (Grob *me, string str, Real h, m.add_stencil (d); } } + else if (str == "dashed") + { + m = dashed_bar_line (me, h, hair); + } else if (str == ".") { m = dot; @@ -167,6 +172,72 @@ Bar_line::calc_bar_size (SCM smob) } +Stencil +Bar_line::dashed_bar_line (Grob *me, Real h, Real thick) +{ + Real dash_size + = 1.0 - robust_scm2double (me->get_property ("gap"), 0.3); + /* + this is a tad complex for what we want to achieve, but with a + simple line, the round blotting interferes with staff line + connections. + */ + Real ss = Staff_symbol_referencer::staff_space (me); + int count = Staff_symbol_referencer::line_count (me); + Real line_thick = Staff_symbol_referencer::line_thickness (me); + + if (fabs (line_thick + (count -1) * ss - h) < 0.1) // ugh. + { + Real blot = + me->layout ()->get_dimension (ly_symbol2scm ("blot-diameter")); + + Real half_space = ss/2; + Stencil bar; + + for (int i = (count-1); i >= -(count-1); i -= 2) + { + Real top_y = min ((i + dash_size) * half_space, + (count-1) * half_space + line_thick / 2); + Real bot_y = max ((i - dash_size) * half_space, + -(count-1) * half_space - line_thick/2); + + bar.add_stencil (Lookup::round_filled_box (Box (Interval (0,thick), + Interval (bot_y, top_y)), + blot)); + } + return bar; + } + else + { + /* + We have to scale the dashing so it starts and ends with half a + dash exactly. + */ + int dashes = int (rint (h / ss)); + Real total_dash_size = h / dashes; + Real factor = (dash_size - thick) / ss; + + SCM at = scm_list_n (ly_symbol2scm ("dashed-line"), + scm_from_double (thick), + scm_from_double (factor * total_dash_size), + scm_from_double ((1-factor) * total_dash_size), + scm_from_double (0), + scm_from_double (h), + scm_from_double (factor * total_dash_size * 0.5), + SCM_UNDEFINED); + + Box box; + box.add_point (Offset (0, 0)); + box.add_point (Offset (0, h)); + + Stencil s (box, at); + s.translate (Offset (thick/2, -h/2)); + return s; + } + return Stencil(); +} + + ADD_INTERFACE (Bar_line, "bar-line-interface", @@ -183,10 +254,15 @@ ADD_INTERFACE (Bar_line, "These produce, respectively, a right repeat, a left repeat, a double\n" "repeat, a double bar, a start bar, an end bar, and a thick double bar.\n" "If @var{bartype} is set to @code{empty} then nothing is printed,\n" - "but a line break is allowed at that spot.\n", + "but a line break is allowed at that spot.\n" + "\n\n" + "@code{gap} is used for the gaps in dashed barlines." + , - /* properties */ + + /* properties */ + "gap " "kern " "thin-kern " "hair-thickness " @@ -195,3 +271,5 @@ ADD_INTERFACE (Bar_line, "glyph-name " "bar-size " ); + + diff --git a/lily/include/bar-line.hh b/lily/include/bar-line.hh index 4744aef855..39253a7b8d 100644 --- a/lily/include/bar-line.hh +++ b/lily/include/bar-line.hh @@ -18,6 +18,7 @@ class Bar_line public: static bool has_interface (Grob *); + static Stencil dashed_bar_line (Grob *me, Real h, Real thick); static Stencil compound_barline (Grob *, string, Real height, bool rounded); static Stencil simple_barline (Grob *, Real wid, Real height, bool rounded); DECLARE_SCHEME_CALLBACK (calc_bar_size, (SCM)); diff --git a/lily/instrument-name-engraver.cc b/lily/instrument-name-engraver.cc index 2f361f0fe5..5a19610479 100644 --- a/lily/instrument-name-engraver.cc +++ b/lily/instrument-name-engraver.cc @@ -114,7 +114,11 @@ ADD_TRANSLATOR (Instrument_name_engraver, "", /* read */ - "vocNam vocalName instrument instr " - "currentCommandColumn", + "currentCommandColumn " + "instr " + "instrument " + "vocNam " + "vocalName " + , /* write */ ""); diff --git a/lily/lily-parser-scheme.cc b/lily/lily-parser-scheme.cc index 2521f4e039..56de47abbd 100644 --- a/lily/lily-parser-scheme.cc +++ b/lily/lily-parser-scheme.cc @@ -65,6 +65,7 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", if (!output_name_global.empty ()) { + /* Interpret --output=DIR to mean --output=DIR/BASE. */ string dir; if (is_dir (output_name_global)) @@ -73,7 +74,15 @@ LY_DEFINE (ly_parse_file, "ly:parse-file", output_name_global = ""; } else - dir = dir_name (output_name_global); + { + File_name out (output_name_global); + if (is_dir (out.dir_part ())) + { + dir = out.dir_part (); + out_file_name = out.file_part (); + } + } + if (dir != "" && dir != "." && dir != get_working_directory ()) { global_path.prepend (get_working_directory ()); diff --git a/lily/line-interface.cc b/lily/line-interface.cc index 6401b3896a..ff7fae5783 100644 --- a/lily/line-interface.cc +++ b/lily/line-interface.cc @@ -44,6 +44,7 @@ Line_interface::make_dashed_line (Real thick, Offset from, Offset to, scm_from_double (off), scm_from_double (to[X_AXIS] - from[X_AXIS]), scm_from_double (to[Y_AXIS] - from[Y_AXIS]), + scm_from_double (0.0), SCM_UNDEFINED); Box box; diff --git a/python/convertrules.py b/python/convertrules.py index 7ba205c498..1d128d38a7 100644 --- a/python/convertrules.py +++ b/python/convertrules.py @@ -2691,7 +2691,7 @@ conversions.append (((2, 7, 29), conv, """override Stem #'beamed-* -> #'details #'beamed-*""")) def conv (str): - str = re.sub (r'\epsfile *#"', r'\epsfile #X #10 #"', str) + str = re.sub (r'\\epsfile *#"', r'\\epsfile #X #10 #"', str) return str conversions.append (((2, 7, 30), conv, diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index b0d023b2be..d4c3636043 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -142,6 +142,7 @@ . ( (break-align-symbol . staff-bar) (glyph . "|") + (gap . 0.4) (layer . 0) (break-visibility . ,all-visible) (non-musical . #t) diff --git a/scm/output-ps.scm b/scm/output-ps.scm index 010e8f15a2..108771ee4b 100644 --- a/scm/output-ps.scm +++ b/scm/output-ps.scm @@ -112,13 +112,16 @@ "false") (round4 radius) (round4 thick))) -(define (dashed-line thick on off dx dy) - (format #f "~a ~a ~a [ ~a ~a ] 0 draw_dashed_line" +(define (dashed-line thick on off dx dy phase) + (format #f "~a ~a ~a [ ~a ~a ] ~a draw_dashed_line" (str4 dx) (str4 dy) (str4 thick) (str4 on) - (str4 off))) + (str4 off) + (str4 phase) + + )) ;; what the heck is this interface ? (define (dashed-slur thick on off l) diff --git a/scm/output-svg.scm b/scm/output-svg.scm index 3ed5e22c14..2e953a94b2 100644 --- a/scm/output-svg.scm +++ b/scm/output-svg.scm @@ -267,7 +267,7 @@ (y2 . ,(- y2))) alist))) -(define (dashed-line thick on off dx dy) +(define (dashed-line thick on off dx dy phase) (draw-line thick 0 0 dx dy `(style . ,(format "stroke-dasharray:~a,~a;" on off)))) (define (named-glyph font name) diff --git a/scm/output-tex.scm b/scm/output-tex.scm index c9697f5f12..0f36375f0d 100644 --- a/scm/output-tex.scm +++ b/scm/output-tex.scm @@ -98,8 +98,8 @@ (ly:warning (_ "can't find ~a in ~a" name font)) "")))) -(define (dashed-line thick on off dx dy) - (embedded-ps (list 'dashed-line thick on off dx dy))) +(define (dashed-line thick on off dx dy phase) + (embedded-ps (list 'dashed-line thick on off dx dy phase))) (define (zigzag-line centre? zzw zzh thick dx dy) (embedded-ps (list 'zigzag-line centre? zzw zzh thick dx dy))) diff --git a/scripts/midi2ly.py b/scripts/midi2ly.py index e35e9d13ea..4a0d956211 100644 --- a/scripts/midi2ly.py +++ b/scripts/midi2ly.py @@ -33,8 +33,6 @@ for d in ['@lilypond_datadir@', '@lilypond_libdir@']: sys.path.insert (0, os.path.join (d, 'python')) -sys.path.insert (0, os.path.join (datadir, 'python')) - # dynamic relocation, for GUB binaries. bindir = os.path.abspath (os.path.split (sys.argv[0])[0]) for p in ['share', 'lib']: -- 2.39.2