From b72fc08ee82eba965f91f2569ab4e43361668641 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Sun, 18 Jan 2004 19:29:01 +0000 Subject: [PATCH] * lily/hairpin.cc: use Line_interface * lily/line-interface.cc: new file. Line_interface for everything with dotted/dashed lines. * lily/tuplet-bracket.cc (make_bracket): use Line_interface. * lily/ottava-bracket.cc (brew_molecule): new file, separate routine for constructing ottava brackets. * lily/ottava-engraver.cc (acknowledge_grob): hang the bracket on the note heads. * Documentation/user/internals.itely (Engravers and performers): fix broken link. * scm/music-functions.scm (make-mark-set): new function. * lily/lookup.cc: remove Lookup::horizontal_slope (): it is functionally identical to beam. * lily/mensural-ligature.cc (brew_flexa): replace horizontal_slope () with beam (). * Documentation/user/refman.itely (Rehearsal marks): document new functionality. --- ChangeLog | 25 +++++ Documentation/user/internals.itely | 2 +- Documentation/user/refman.itely | 32 +++--- input/regression/ottava.ly | 10 +- lily/directional-element-interface.cc | 2 +- lily/hairpin.cc | 46 ++------- lily/include/lily-guile.hh | 4 +- lily/include/line-interface.hh | 24 +++++ lily/include/lookup.hh | 2 - lily/include/tuplet-bracket.hh | 4 +- lily/lily-guile.cc | 26 +++++ lily/line-interface.cc | 76 ++++++++++++++ lily/line-spanner.cc | 39 +------ lily/lookup.cc | 77 ++++---------- lily/mensural-ligature.cc | 10 +- lily/ottava-bracket.cc | 140 ++++++++++++++++++++++++++ lily/ottava-engraver.cc | 3 +- lily/text-spanner.cc | 14 +-- lily/tuplet-bracket.cc | 21 ++-- lily/volta-bracket.cc | 1 - scm/define-grobs.scm | 12 +-- scm/music-functions.scm | 5 +- 22 files changed, 384 insertions(+), 191 deletions(-) create mode 100644 lily/include/line-interface.hh create mode 100644 lily/line-interface.cc create mode 100644 lily/ottava-bracket.cc diff --git a/ChangeLog b/ChangeLog index a74997b4c5..c3ee2c36a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,30 @@ 2004-01-18 Han-Wen Nienhuys + * lily/hairpin.cc: use Line_interface + + * lily/line-interface.cc: new file. Line_interface for everything + with dotted/dashed lines. + + + * lily/tuplet-bracket.cc (make_bracket): use Line_interface. + + * lily/ottava-bracket.cc (brew_molecule): new file, separate routine + for constructing ottava brackets. + + * lily/ottava-engraver.cc (acknowledge_grob): hang the bracket on + the note heads. + + * Documentation/user/internals.itely (Engravers and performers): + fix broken link. + + * scm/music-functions.scm (make-mark-set): new function. + + * lily/lookup.cc: remove Lookup::horizontal_slope (): it is + functionally identical to beam. + + * lily/mensural-ligature.cc (brew_flexa): replace horizontal_slope + () with beam (). + * Documentation/user/refman.itely (Rehearsal marks): document new functionality. diff --git a/Documentation/user/internals.itely b/Documentation/user/internals.itely index 9d35ceb79a..3fed2a848b 100644 --- a/Documentation/user/internals.itely +++ b/Documentation/user/internals.itely @@ -452,7 +452,7 @@ the central C is at its default position, the center line: @end lilypond A list of all engravers is in the internal documentation, -see @internalsref{All engravers}. +see @internalsref{Engravers}. @node Defining new contexts @subsection Defining new contexts diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index c8bd42b319..3a798e564a 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -356,10 +356,6 @@ direction manually: Internals: @internalsref{Dots}, and @internalsref{DotColumn}. -@refbugs - -In dense chords, dots can overlap. - @node Stems @subsection Stems @@ -504,10 +500,16 @@ instead. Internals: @internalsref{TupletBracket}, and @internalsref{TimeScaledMusic}. +Examples: @inputfileref{input/regression,tuplet-nest.ly}. + @refbugs Nested tuplets are not formatted automatically. In this case, outer -tuplet brackets should be moved manually. +tuplet brackets should be moved manually, which is demonstrated in +@inputfileref{input/regression,tuplet-nest.ly}. + + + @node Easy Notation note heads @subsection Easy Notation note heads @@ -2149,7 +2151,7 @@ Internals: @internalsref{ScriptEvent}, and @internalsref{Script}. @refbugs - These note ornaments appear in the printed output but have no +These note ornaments appear in the printed output but have no effect on the MIDI rendering of the music. @@ -2373,8 +2375,6 @@ Internals: @internalsref{GraceMusic}. @refbugs -Grace notes cannot be used in the smallest size (@file{paper11.ly}). - A score that starts with an @code{\grace} section needs an explicit @code{\context Voice} declaration, otherwise the main note and grace note end up on different staves. @@ -2392,9 +2392,6 @@ Grace sections should only be used within sequential music expressions. Nesting or juxtaposing grace sections is not supported, and might produce crashes or other errors. -Overriding settings cannot be done in separate styles for appoggiatura -and acciaccatura. - @node Glissando @subsection Glissando @@ -3136,7 +3133,8 @@ handle this cross-staffing behavior. In this section we discuss the There is no support for putting chords across staves. You can get this result by increasing the length of the stem in the lower stave so it reaches the stem in the upper stave, or vice versa. An example is -included with the distribution as @inputfileref{input/test,stem-cross-staff.ly}. +included with the distribution as +@inputfileref{input/test,stem-cross-staff.ly}. Dynamics are not centered, but kludges do exist. See @inputfileref{input/template,piano-dynamics.ly}. @@ -3546,8 +3544,7 @@ Examples: @inputfileref{input/template,satb.ly}, @refbugs -@code{\lyricsto} is not automatic enough: melismata are not detected -automatically, and melismata are not stopped when they hit a rest. +Melismata are not detected automatically, and must be inserted by hand. @node More stanzas @@ -4188,6 +4185,9 @@ To print a rehearsal mark, use the @code{\mark} command: } @end lilypond +@noindent +(The letter I is skipped in accordance with engraving traditions.) + The mark is incremented automatically if you use @code{\mark \default}, but you can also use an integer argument to set the mark manually. The value to use is stored in the property @@ -4199,7 +4199,7 @@ as argument. It should return a markup object. In the following example, @code{markFormatter} is set to a canned procedure. After a few measures, it is set to function that produces a boxed number. -@lilypond[verbatim,fragment,relative 2] +@lilypond[verbatim,fragment,relative 1] \property Score.markFormatter = #format-mark-numbers c1 \mark \default c1 \mark \default @@ -8035,7 +8035,7 @@ added to LilyPond. @refbugs There is no style sheet provided for other fonts besides the @TeX{} -family. +Computer Modern family. @cindex font selection @cindex font magnification diff --git a/input/regression/ottava.ly b/input/regression/ottava.ly index 922d7a79b2..d8011816eb 100644 --- a/input/regression/ottava.ly +++ b/input/regression/ottava.ly @@ -43,9 +43,10 @@ with @code{Staff.ottavation}. a b c a #(set-octavation 0) #(set-octavation -1) - a b c a + a b c a #(set-octavation 0) - a, + \break + a, #(set-octavation 1) \property Staff.ottavation = #"8" b @@ -53,7 +54,10 @@ with @code{Staff.ottavation}. c a #(set-octavation -1) b a g #(set-octavation 0) - c + c + #(set-octavation -1) + \property Staff.ottavation = #"8" + c,,16 } } diff --git a/lily/directional-element-interface.cc b/lily/directional-element-interface.cc index 230bcc8cd0..499d828036 100644 --- a/lily/directional-element-interface.cc +++ b/lily/directional-element-interface.cc @@ -1,5 +1,5 @@ /* - directional-element.cc -- implement Directional_element + directional-element-interface.cc -- implement Directional_element source file of the GNU LilyPond music typesetter diff --git a/lily/hairpin.cc b/lily/hairpin.cc index ab3dabeee3..8dc7cda20d 100644 --- a/lily/hairpin.cc +++ b/lily/hairpin.cc @@ -7,6 +7,7 @@ */ #include "molecule.hh" +#include "line-interface.hh" #include "hairpin.hh" #include "spanner.hh" #include "font-interface.hh" @@ -120,41 +121,16 @@ Hairpin::brew_molecule (SCM smob) should do relative to staff-symbol staff-space? */ - Real period = 1.0; - s = me->get_grob_property ("dash-period"); - if (gh_number_p (s)) - period = gh_scm2double (s); - - Real fraction = 1.0; - s = me->get_grob_property ("dash-fraction"); - if (gh_number_p (s)) - fraction = gh_scm2double (s); - - /* - TODO: set line style. - */ Molecule mol; - if (fraction < 1.0) - { - mol = Lookup::dashed_line (thick, - Offset (0, starth), - Offset (width, endh), - period, fraction); - mol.add_molecule (Lookup::dashed_line (thick, - Offset (0, -starth), - Offset (width, -endh), - period, fraction)); - } - else - { - mol = Lookup::line (thick, - Offset (0, starth), - Offset (width, endh)); - mol.add_molecule (Lookup::line (thick, - Offset (0, -starth), - Offset (width, -endh) - )); - } + mol = Line_interface::dashed_line (me, + thick, + Offset (0, starth), + Offset (width, endh)); + mol.add_molecule (Line_interface::dashed_line (me, + thick, + Offset (0, -starth), + Offset (width, -endh))); + mol.translate_axis (x_points[LEFT] - bounds[LEFT]->relative_coordinate (common, X_AXIS), X_AXIS); @@ -165,5 +141,5 @@ Hairpin::brew_molecule (SCM smob) ADD_INTERFACE (Hairpin, "hairpin-interface", "hairpin crescendo.", - "dash-period dash-fraction grow-direction thickness height if-text-padding"); + "grow-direction height if-text-padding"); diff --git a/lily/include/lily-guile.hh b/lily/include/lily-guile.hh index f0c82421f2..613099e24e 100644 --- a/lily/include/lily-guile.hh +++ b/lily/include/lily-guile.hh @@ -159,7 +159,9 @@ Interval ly_scm2interval (SCM); Slice int_list_to_slice (SCM l); SCM ly_interval2scm (Drul_array); - +Real robust_scm2double (SCM, double); +Drul_array robust_scm2interval (SCM, Drul_array); +Offset robust_scm2offset (SCM, Offset); SCM ly_quote_scm (SCM s); bool type_check_assignment (SCM val, SCM sym, SCM type_symbol) ; diff --git a/lily/include/line-interface.hh b/lily/include/line-interface.hh new file mode 100644 index 0000000000..f81d9f68c1 --- /dev/null +++ b/lily/include/line-interface.hh @@ -0,0 +1,24 @@ +/* +line-interface.hh -- declare + +source file of the GNU LilyPond music typesetter + +(c) 2004 Han-Wen Nienhuys + + */ + +#ifndef LINE_INTERFACE_HH +#define LINE_INTERFACE_HH + +#include "lily-proto.hh" + +struct Line_interface +{ + static Molecule dashed_line (Grob *me, Real thick, Offset from, Offset to); + static bool has_interface (Grob*); + static Molecule make_dashed_line (Real th, Offset from, Offset to, Real, Real); + +}; +#endif /* LINE_INTERFACE_HH */ + + diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 43d5f68761..959b278a8d 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -25,7 +25,6 @@ struct Lookup static Molecule frame (Box b, Real thick, Real blot); static Molecule slur (Bezier controls, Real cthick, Real thick); static Molecule bezier_sandwich (Bezier top_curve, Bezier bottom_curve); - static Molecule horizontal_slope (Real width, Real slope, Real height); static Molecule beam (Real slope, Real width, Real thick, Real blot); static Molecule dashed_slur (Bezier, Real thick, Real dash); static Molecule blank (Box b); @@ -33,7 +32,6 @@ struct Lookup static Molecule round_filled_box (Box b, Real blotdiameter); static Molecule repeat_slash (Real w, Real slope, Real th); static Molecule line (Real th, Offset from, Offset to); - static Molecule dashed_line (Real th, Offset from, Offset to, Real, Real); static Molecule horizontal_line (Interval w, Real th); static Molecule triangle (Interval, Real, Real); }; diff --git a/lily/include/tuplet-bracket.hh b/lily/include/tuplet-bracket.hh index b0095c6d23..46ff0bd006 100644 --- a/lily/include/tuplet-bracket.hh +++ b/lily/include/tuplet-bracket.hh @@ -32,8 +32,8 @@ public: DECLARE_SCHEME_CALLBACK (after_line_breaking, (SCM )); DECLARE_SCHEME_CALLBACK (before_line_breaking, (SCM )); - static Molecule make_bracket (Axis protusion_axis, - Real dx, Real dy, Real thick, Drul_array height, + static Molecule make_bracket (Grob *me, Axis protusion_axis, + Offset dz, Real thick, Drul_array height, Real gap, Drul_array widen, Drul_array shorten); static Direction get_default_dir (Grob*); diff --git a/lily/lily-guile.cc b/lily/lily-guile.cc index b448a6396c..c7641e7447 100644 --- a/lily/lily-guile.cc +++ b/lily/lily-guile.cc @@ -714,3 +714,29 @@ robust_list_ref(int i, SCM l) return gh_car(l); } + + +Real +robust_scm2double (SCM k, double x) +{ + if (gh_number_p (k)) + x = gh_scm2double (k); + return x; +} + +Drul_array +robust_scm2interval (SCM k, Drul_array v) +{ + if (is_number_pair (k)) + v = ly_scm2interval (k); + return v; +} + +Offset +robust_scm2offset (SCM k, Offset o) +{ + if (is_number_pair (k)) + o = ly_scm2offset (k); + + return o; +} diff --git a/lily/line-interface.cc b/lily/line-interface.cc new file mode 100644 index 0000000000..cac08cc08e --- /dev/null +++ b/lily/line-interface.cc @@ -0,0 +1,76 @@ +/* +line-interface.cc -- implement Line_interface + +source file of the GNU LilyPond music typesetter + +(c) 2004 Han-Wen Nienhuys + + */ + +#include "line-interface.hh" +#include "molecule.hh" +#include "grob.hh" +#include "staff-symbol-referencer.hh" +#include "lookup.hh" + + + +Molecule +Line_interface::make_dashed_line (Real thick, Offset from, Offset to, + Real dash_period, Real dash_fraction) +{ + dash_fraction = (dash_fraction >? 0) get_grob_property ("style"); + if (type == ly_symbol2scm ("dotted-line") + || type == ly_symbol2scm ("dashed-line")) + { + Real fraction = + robust_scm2double (me->get_grob_property ("dash-fraction"), + (type == ly_symbol2scm ("dotted-line")) ? 0.0 : 0.4); + + fraction = (fraction >? 0) get_grob_property ("dash-period"), 1.0); + + if (period < 0) + return Molecule (); + + return make_dashed_line (thick, from, to, period, fraction); + } + else + { + return Lookup::line (thick, from, to); + } +} + +ADD_INTERFACE(Line_interface, "line-interface", + "Generic line objects. Any object using lines supports this. ", + "dash-period dash-fraction thickness style") diff --git a/lily/line-spanner.cc b/lily/line-spanner.cc index c47196d1f5..c6b0ff9df8 100644 --- a/lily/line-spanner.cc +++ b/lily/line-spanner.cc @@ -6,6 +6,8 @@ (c) 2000--2003 Jan Nieuwenhuizen */ +#include + #include "molecule.hh" #include "item.hh" #include "spanner.hh" @@ -17,8 +19,7 @@ #include "warn.hh" #include "align-interface.hh" #include "lookup.hh" - -#include +#include "line-interface.hh" /* TODO: convert all Molecule functions to taking arguments of the form @@ -32,37 +33,7 @@ grob-properties. Make arbitrary paths. */ -Molecule -dashed_line_molecule (Grob *me, Real thick, Offset from, Offset to) -{ - SCM type = me->get_grob_property ("style"); - if (type == ly_symbol2scm ("dotted-line") - || type == ly_symbol2scm ("dashed-line")) - { - Real fraction = (type == ly_symbol2scm ("dotted-line")) ? 0.0 : 0.4; - - SCM s = me->get_grob_property ("dash-fraction"); - if (gh_number_p (s)) - fraction = gh_scm2double (s); - - fraction = (fraction >? 0) get_grob_property ("dash-period"); - if (gh_number_p (s)) - period *= gh_scm2double (s); - - if (period < 0) - return Molecule (); - - return Lookup::dashed_line (thick, from, to, period, fraction); - } - else - { - return Lookup::line (thick, from, to); - } -} Molecule zigzag_molecule (Grob *me, Real thick, @@ -148,7 +119,7 @@ Line_spanner::line_molecule (Grob *me, Real thick, { return (type == ly_symbol2scm ("zigzag")) ? zigzag_molecule (me, thick, from, to) - : dashed_line_molecule (me, thick, from, to); + : Line_interface::dashed_line (me, thick, from, to); } else if (gh_symbol_p (type) && type == ly_symbol2scm ("trill")) @@ -340,6 +311,6 @@ ADD_INTERFACE (Line_spanner, "line-spanner-interface", "gap is measured in staff-spaces.\n" "The property 'type is one of: line, dashed-line, trill, dotted-line or zigzag.\n" "\n", - "gap dash-period dash-fraction zigzag-width zigzag-length thickness style"); + "gap zigzag-width zigzag-length thickness"); diff --git a/lily/lookup.cc b/lily/lookup.cc index 0e8a40acb8..4bb7c2d8a6 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -39,6 +39,25 @@ Lookup::dot (Offset p, Real radius) return Molecule (box, at); } + + +/* + * Horizontal Slope: + * + * /| ^ + * / | | + * / | | height + * / | | + * / | v + * | / + * | / + * (0,0) x /slope=dy/dx + * | / + * |/ + * + * <-----> + * width + */ Molecule Lookup::beam (Real slope, Real width, Real thick, Real blot) { @@ -99,33 +118,6 @@ Lookup::line (Real th, Offset from, Offset to) return Molecule (box, at); } -Molecule -Lookup::dashed_line (Real thick, Offset from, Offset to, - Real dash_period, Real dash_fraction) -{ - dash_fraction = (dash_fraction >? 0) - * width - */ -Molecule -Lookup::horizontal_slope (Real width, Real slope, Real height) -{ - SCM width_scm = gh_double2scm (width); - SCM slope_scm = gh_double2scm (slope); - SCM height_scm = gh_double2scm (height); - SCM horizontal_slope = scm_list_n (ly_symbol2scm ("beam"), - width_scm, slope_scm, - height_scm, SCM_UNDEFINED); - Box b (Interval (0, width), - Interval (-height/2, height/2 + width*slope)); - return Molecule (b, horizontal_slope); -} - /* TODO: junk me. */ diff --git a/lily/mensural-ligature.cc b/lily/mensural-ligature.cc index e978d4b518..c0bb7fac49 100644 --- a/lily/mensural-ligature.cc +++ b/lily/mensural-ligature.cc @@ -73,28 +73,28 @@ brew_flexa (Grob *me, if (solid) { Molecule solid_head = - Lookup::horizontal_slope (width, corrected_slope, height); + Lookup::beam (corrected_slope, width, height, 0.0); molecule.add_molecule (solid_head); } else // outline { Molecule left_edge = - Lookup::horizontal_slope (thickness, corrected_slope, height); + Lookup::beam (corrected_slope, thickness, height, 0.0); molecule.add_molecule(left_edge); Molecule right_edge = - Lookup::horizontal_slope (thickness, corrected_slope, height); + Lookup::beam (corrected_slope, thickness, height, 0.0); right_edge.translate_axis (width-thickness, X_AXIS); right_edge.translate_axis (corrected_slope * (width-thickness), Y_AXIS); molecule.add_molecule(right_edge); Molecule bottom_edge = - Lookup::horizontal_slope (width, corrected_slope, thickness); + Lookup::beam (corrected_slope, width, thickness, 0.0); bottom_edge.translate_axis (-0.5*height, Y_AXIS); molecule.add_molecule (bottom_edge); Molecule top_edge = - Lookup::horizontal_slope (width, corrected_slope, thickness); + Lookup::beam (corrected_slope, width, thickness, 0.0); top_edge.translate_axis (+0.5*height, Y_AXIS); molecule.add_molecule (top_edge); } diff --git a/lily/ottava-bracket.cc b/lily/ottava-bracket.cc new file mode 100644 index 0000000000..f72ccf9adc --- /dev/null +++ b/lily/ottava-bracket.cc @@ -0,0 +1,140 @@ +#include "molecule.hh" +#include "text-item.hh" +#include "text-spanner.hh" +#include "line-spanner.hh" +#include "spanner.hh" +#include "font-interface.hh" +#include "dimensions.hh" +#include "paper-def.hh" +#include "warn.hh" +#include "paper-column.hh" +#include "staff-symbol-referencer.hh" +#include "note-column.hh" +#include "directional-element-interface.hh" +#include "tuplet-bracket.hh" + +struct Ottava_bracket +{ + DECLARE_SCHEME_CALLBACK (brew_molecule, (SCM)); + static bool has_interface (Grob*); +}; + + +/* + TODO: the string for ottava shoudl depend on the available space, ie. + + + Long: 15ma Short: 15ma Empty: 15 + 8va 8va 8 + 8va bassa 8ba 8 + +*/ + +MAKE_SCHEME_CALLBACK (Ottava_bracket, brew_molecule, 1); +SCM +Ottava_bracket::brew_molecule (SCM smob) +{ + Spanner*me = dynamic_cast (unsmob_grob (smob)); + + + Interval span_points; + + Grob *common = me->get_bound (LEFT)->common_refpoint (me->get_bound (RIGHT), X_AXIS); + Paper_def * paper = me->get_paper(); + + + Drul_array broken; + Direction d = LEFT; + do + { + Item *b = me->get_bound (d); + broken[d] = (b->break_status_dir () != CENTER); + + if (Note_column::has_interface (b)) + { + common = common_refpoint_of_list (b->get_grob_property ("heads"), common, X_AXIS); + } + } + while (flip (&d) != LEFT); + + SCM properties = Font_interface::font_alist_chain (me); + SCM markup = me->get_grob_property ("text"); + Molecule text; + if (Text_item::markup_p (markup)) + text = *unsmob_molecule (Text_item::interpret_markup (paper->self_scm (), properties, markup)); + + + Drul_array shorten = robust_scm2interval (me->get_grob_property ("shorten-pair"), + Interval (0,0)); + do + { + Item *b = me->get_bound (d); + + Interval ext; + if (Note_column::has_interface (b)) + { + for (SCM s = b->get_grob_property ("note-heads"); gh_pair_p (s); s =gh_cdr (s)) + ext.unite (unsmob_grob (gh_car (s))->extent (common, X_AXIS)); + } + + if (ext.is_empty ()) + ext = Interval (0,0); + + span_points[d] = (broken [d]) ? b->extent (common, X_AXIS)[-d] : ext[d]; + + if (broken[d]) + shorten [d] = 0.0; + } + while (flip (&d) != LEFT); + + + /* + 0.3 is ~ italic correction. + */ + Real text_offset = text.extent (X_AXIS).is_empty () + ? 0.0 : text.extent (X_AXIS)[RIGHT] + 0.3; + + Interval bracket_span_points = span_points; + bracket_span_points[LEFT] += text_offset; + + Real thick = paper->get_realvar (ly_symbol2scm ("linethickness")); + thick *= robust_scm2double (me->get_grob_property ("thickness"), 1.0); + + Drul_array edge_height = robust_scm2interval (me->get_grob_property ("edge-height"), + Interval (1.0, 1.0)); + + + Drul_array flare = robust_scm2interval (me->get_grob_property ("bracket-flare"), + Interval (0,0)); + + + + edge_height[LEFT] = 0.0; + edge_height[RIGHT] *= - get_grob_direction (me); + if (broken[RIGHT]) + edge_height[RIGHT] = 0.0; + + Molecule b; + if (!bracket_span_points.is_empty ()) + b = Tuplet_bracket::make_bracket (me, + Y_AXIS, Offset (bracket_span_points.length (), 0), + thick, edge_height, + 0.0, + flare, shorten); + + + b.translate_axis (bracket_span_points[LEFT], X_AXIS); + text.translate_axis (span_points[LEFT], X_AXIS); + text.align_to (Y_AXIS, CENTER); + b.add_molecule (text); + + b.translate_axis (- me->relative_coordinate (common, X_AXIS), X_AXIS); + + return b.smobbed_copy (); +} + + +ADD_INTERFACE (Ottava_bracket, "ottava-bracket-interface", + "An ottava bracket", + "edge-height bracket-flare shorten-pair"); + diff --git a/lily/ottava-engraver.cc b/lily/ottava-engraver.cc index bd0d698f28..fba507e10c 100644 --- a/lily/ottava-engraver.cc +++ b/lily/ottava-engraver.cc @@ -50,7 +50,7 @@ Ottava_spanner_engraver::process_music () if (gh_string_p (ott)) { span_ = new Spanner (get_property ("OttavaSpanner")); - span_->set_grob_property ("edge-text", gh_cons (ott, SCM_EOL)); + span_->set_grob_property ("text", ott); announce_grob (span_, SCM_EOL); SCM c0 (get_property ("centralCPosition")); @@ -69,6 +69,7 @@ Ottava_spanner_engraver::acknowledge_grob (Grob_info info) if (span_ && it && Note_column::has_interface (info.grob_)) { Side_position_interface::add_support (span_, it); + if (!span_->get_bound (LEFT)) span_->set_bound (LEFT, it); span_->set_bound (RIGHT, it); diff --git a/lily/text-spanner.cc b/lily/text-spanner.cc index 37ca80ae3f..9b4bcadaab 100644 --- a/lily/text-spanner.cc +++ b/lily/text-spanner.cc @@ -34,14 +34,6 @@ MAKE_SCHEME_CALLBACK (Text_spanner, brew_molecule, 1); TODO: this function is too long - TODO: the string for ottava shoudl depend on the available space, ie. - - - Long: 15ma Short: 15ma Empty: 15 - 8va 8va 8 - 8va bassa 8ba 8 - - */ SCM Text_spanner::brew_molecule (SCM smob) @@ -121,9 +113,9 @@ Text_spanner::brew_molecule (SCM smob) thick *= gh_scm2double (st); } + Drul_array edge_height = robust_scm2interval (me->get_grob_property ("edge-height"), + Interval (1.0, 1.0)); Drul_array edge_line; - SCM edge_height = me->get_grob_property ("edge-height"); - if (is_number_pair (edge_height)) { Direction d = LEFT; int dir = to_dir (me->get_grob_property ("direction")); @@ -136,7 +128,7 @@ Text_spanner::brew_molecule (SCM smob) if (gh_pair_p (flare)) dx = gh_scm2double (index_get_cell (flare, d)) * d; - Real dy = gh_scm2double (index_get_cell (edge_height, d)) * - dir; + Real dy = - dir * edge_height[d] ; if (dy) edge_line[d] = Line_spanner::line_molecule (me, thick, Offset(0,0), Offset (dx, dy)); diff --git a/lily/tuplet-bracket.cc b/lily/tuplet-bracket.cc index c351f374f4..4b4d76383f 100644 --- a/lily/tuplet-bracket.cc +++ b/lily/tuplet-bracket.cc @@ -24,6 +24,7 @@ #include +#include "line-interface.hh" #include "beam.hh" #include "box.hh" #include "warn.hh" @@ -220,8 +221,8 @@ Tuplet_bracket::brew_molecule (SCM smob) } while (flip (&d) != LEFT); - Molecule brack = make_bracket (Y_AXIS, - w, ry - ly, lt, + Molecule brack = make_bracket (me, Y_AXIS, + Offset (w, ry - ly), lt, height, gh_scm2double (gap), flare, @@ -241,13 +242,14 @@ Tuplet_bracket::brew_molecule (SCM smob) brackets. */ Molecule -Tuplet_bracket::make_bracket (Axis protusion_axis, - Real dx, Real dy, Real thick, Drul_array height, +Tuplet_bracket::make_bracket (Grob *me, // for line properties. + Axis protusion_axis, + Offset dz, + Real thick, Drul_array height, Real gap, Drul_array flare, Drul_array shorten) { - Offset dz = Offset (dx,dy); Drul_array corners (Offset(0,0), dz); Real length = dz.length (); @@ -273,12 +275,11 @@ Tuplet_bracket::make_bracket (Axis protusion_axis, Molecule m; do { - - m.add_molecule (Lookup::line (thick, straight_corners[d], - gap_corners[d])); + m.add_molecule (Line_interface::dashed_line (me, thick, straight_corners[d], + gap_corners[d])); - m.add_molecule (Lookup::line (thick, straight_corners[d], - flare_corners[d])); + m.add_molecule (Line_interface::dashed_line (me, thick, straight_corners[d], + flare_corners[d])); } while (flip (&d) != LEFT); return m; diff --git a/lily/volta-bracket.cc b/lily/volta-bracket.cc index 2200983609..195b0a7d60 100644 --- a/lily/volta-bracket.cc +++ b/lily/volta-bracket.cc @@ -92,7 +92,6 @@ Volta_bracket_interface::brew_molecule (SCM smob) Real h = gh_scm2double (me->get_grob_property ("height")); Real t = staff_thick * gh_scm2double (me->get_grob_property ("thickness")); - Molecule start,end ; if (!no_vertical_start) start = Lookup::line (t, Offset (0,0), Offset (0, h)); diff --git a/scm/define-grobs.scm b/scm/define-grobs.scm index cf45e53914..41b052e138 100644 --- a/scm/define-grobs.scm +++ b/scm/define-grobs.scm @@ -397,12 +397,10 @@ (minimum-length . 2.0) (if-text-padding . 1.0) (width-correct . -1.0) - - (dash-thickness . 1.2) (dash-length . 4.0) (self-alignment-Y . 0) (Y-offset-callbacks . (,Self_alignment_interface::aligned_on_self)) - (meta . ((interfaces . (hairpin-interface self-alignment-interface dynamic-interface spanner-interface)))) + (meta . ((interfaces . (hairpin-interface line-interface self-alignment-interface dynamic-interface spanner-interface)))) )) (HorizontalBracket @@ -1079,7 +1077,7 @@ . ( (Y-offset-callbacks . (,Side_position_interface::out_of_staff ,Side_position_interface::aligned_side)) - (molecule-callback . ,Text_spanner::brew_molecule) + (molecule-callback . ,Ottava_bracket::brew_molecule) (font-shape . italic) (font-family . roman) (text-repeat-if-broken . #t) @@ -1092,7 +1090,9 @@ (dash-fraction . 0.3) (edge-height . (0 . 1.2)) (direction . 1) - (meta . ((interfaces . (text-spanner-interface side-position-interface font-interface spanner-interface)))) + (meta . ((interfaces . (ottava-bracket-interface + line-interface side-position-interface + font-interface text-interface spanner-interface)))) )) (TabNoteHead @@ -1165,7 +1165,7 @@ (font-series . bold) (font-size . -2) - (meta . ((interfaces . (text-interface tuplet-bracket-interface font-interface spanner-interface)))) + (meta . ((interfaces . (text-interface line-interface tuplet-bracket-interface font-interface spanner-interface)))) )) (UnaCordaPedal diff --git a/scm/music-functions.scm b/scm/music-functions.scm index cf9ecd7e55..ba78fc0ed7 100644 --- a/scm/music-functions.scm +++ b/scm/music-functions.scm @@ -437,10 +437,7 @@ Rest can contain a list of beat groupings (make-sequential-music basic) 'Timing))) (define-public (make-mark-set label) - " Set properties for time signature NUM/DEN. -Rest can contain a list of beat groupings - -" + "make the music for the \\mark command." (let* ((set (if (integer? label) -- 2.39.2