2005-11-08 Han-Wen Nienhuys <hanwen@xs4all.nl>
+ * scm/music-functions.scm (glue-mm-rest-texts): also put other
+ events into EventChord. This fixes textspanners on mm rests.
+
+ * lily/side-position-interface.cc (get_axis): read side-axis
+ (set_axis): set side-axis.
+
+ * scm/define-grobs.scm (all-grob-descriptions): add side-axis
+ properties everywhere.
+
+ * lily/spacing-spanner.cc (breakable_column_spacing): add
+ average-spacing-wishes. Take maximum if not set.
+ (musical_column_spacing): idem.
+
+ * scm/define-grobs.scm (all-grob-descriptions): add average-spacing-wishes.
+
* lily/grob-closure.cc (add_offset_callback): bugfix: properly add
offset callbacks. This fixes alignment for Fingering objects.
/* properties */
"axes "
- "elements");
+ "elements ");
return;
text_ = make_item ("BarNumber", SCM_EOL);
- Side_position_interface::set_axis (text_, Y_AXIS);
}
ADD_TRANSLATOR (Bar_number_engraver,
}
void
-Instrument_name_engraver::acknowledge_bar_line (Grob_info i)
+Instrument_name_engraver::acknowledge_bar_line (Grob_info info)
{
- (void)i;
+ (void) info;
create_text ();
}
void
-Instrument_name_engraver::acknowledge_axis_group (Grob_info i)
+Instrument_name_engraver::acknowledge_axis_group (Grob_info info)
{
/*
Ugh - typechecking for pedal and dynamic sucks.
*/
- if (dynamic_cast<Spanner *> (i.grob ())
- && (i.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
- || i.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))))
+ if (dynamic_cast<Spanner *> (info.grob ())
+ && (info.grob ()->internal_has_interface (ly_symbol2scm ("dynamic-interface"))
+ || info.grob ()->internal_has_interface (ly_symbol2scm ("piano-pedal-interface"))))
return;
/*
We could also just use stavesFound, but lets keep this working
without staffs as well.
*/
- if (dynamic_cast<Spanner *> (i.grob ())
- && ((Axis_group_interface::has_interface (i.grob ())
- && Axis_group_interface::has_axis (i.grob (), Y_AXIS)))
- && !Align_interface::has_interface (i.grob ()))
+ if (dynamic_cast<Spanner *> (info.grob ())
+ && ((Axis_group_interface::has_interface (info.grob ())
+ && Axis_group_interface::has_axis (info.grob (), Y_AXIS)))
+ && !Align_interface::has_interface (info.grob ()))
{
- SCM nl = scm_cons (i.grob ()->self_scm (),
+ SCM nl = scm_cons (info.grob ()->self_scm (),
get_property ("instrumentSupport"));
context ()->set_property ("instrumentSupport", nl);
ADD_ACKNOWLEDGER (Instrument_name_engraver, bar_line);
ADD_ACKNOWLEDGER (Instrument_name_engraver, axis_group);
+
ADD_TRANSLATOR (Instrument_name_engraver,
/* doc */ " Prints the name of the instrument (specified by "
" @code{Staff.instrument} and @code{Staff.instr}) "
void
Side_position_interface::set_axis (Grob *me, Axis a)
{
- add_offset_callback (me,
- (a==X_AXIS)
- ? x_aligned_side_proc
- : y_aligned_side_proc,
- a);
+ if (!scm_is_number (me->get_property ("side-axis")))
+ {
+ me->set_property ("side-axis", scm_from_int (a));
+ add_offset_callback (me,
+ (a==X_AXIS)
+ ? x_aligned_side_proc
+ : y_aligned_side_proc,
+ a);
+ }
}
-
-// ugh. doesn't catch all variants.
Axis
Side_position_interface::get_axis (Grob *me)
{
- if (me->get_property_data (ly_symbol2scm ("X-offset"))
- == Side_position_interface::x_aligned_side_proc)
- return X_AXIS;
- else if (me->get_property_data (ly_symbol2scm ("Y-offset"))
- == Side_position_interface::y_aligned_side_proc)
- return Y_AXIS;
-
+ if (scm_is_number (me->get_property ("side-axis")))
+ return Axis (scm_to_int (me->get_property ("side-axis")));
+
+ programming_error ("side-axis not set.");
return NO_AXES;
}
"direction-source "
"minimum-space "
"padding "
+ "side-axis "
"side-relative-direction "
"side-support-elements "
"slur-padding "
bool expand_only = false;
Real base_note_space = note_spacing (me, left_col, right_col, options, &expand_only);
+ Real max_fixed = 0;
+ Real max_space = 0;
Real compound_note_space = 0.0;
Real compound_fixed_note_space = 0.0;
Note_spacing::get_spacing (wish, right_col, base_note_space, options->increment_, &space, &fixed);
- compound_note_space = compound_note_space + space;
- compound_fixed_note_space = compound_fixed_note_space + fixed;
+
+ max_space = max (max_space, space);
+ max_fixed = max (max_fixed, fixed);
+
+ compound_note_space += space;
+ compound_fixed_note_space += fixed;
wish_count++;
}
}
compound_note_space = base_note_space;
compound_fixed_note_space = options->increment_;
}
- else
+ else if (to_boolean (me->get_property ("average-spacing-wishes")))
{
compound_note_space /= wish_count;
compound_fixed_note_space /= wish_count;
}
+ else
+ {
+ compound_fixed_note_space = max_fixed;
+ compound_note_space = max_space;
+ }
/*
Whatever we do, the fixed space is smaller than the real
{
Real compound_fixed = 0.0;
Real compound_space = 0.0;
+ Real max_fixed = 0.0;
+ Real max_space = 0.0;
+
int wish_count = 0;
Moment dt = Paper_column::when_mom (r) - Paper_column::when_mom (l);
space *= 0.8;
}
+ max_space = max (max_space, space);
+ max_fixed = max (max_fixed, fixed_space);
+
compound_space += space;
compound_fixed += fixed_space;
wish_count++;
}
else
{
- compound_space /= wish_count;
- compound_fixed /= wish_count;
+ if (to_boolean (me->get_property ("average-spacing-wishes")))
+ {
+ compound_space /= wish_count;
+ compound_fixed /= wish_count;
+ }
+ else
+ {
+ compound_fixed = max_fixed;
+ compound_space = max_space;
+ }
+
}
if (options->stretch_uniformly_ && l->break_status_dir () != RIGHT)
"head width) A 16th note is followed by 0.5 note head width. The\n"
"quarter note is followed by 3 NHW, the half by 4 NHW, etc.\n",
+ "average-spacing-wishes "
"grace-space-factor "
"spacing-increment "
"base-shortest-duration "
(auto-knee-gap ,ly:dimension? "If a gap is found between note heads
where a horizontal beam fits that is larger than this number, make a kneed beam.")
+ (average-spacing-wishes ,boolean? "If set, the spacing wishes are averaged over staves.")
(axes ,list? "list of axis numbers.
In the case of alignment grobs, this should contain only one number.")
typeset on a Stem. Valid options include @code{()} and
@code{mensural}. Additionally, @code{\"no-flag\"} switches off the
flag.")
-
- (strict-note-spacing ,boolean? "If set, unbroken columns
-with non-musical material (clefs, barlines, etc.) are not spaced
-separately, but put before musical columns.")
+
(font-family ,symbol? "The font family is the broadest category for selecting text fonts. Options include: @code{sans}, @code{roman} ")
(font-encoding ,symbol? "The font encoding is the broadest
category for selecting a font. Options include: @code{fetaMusic},
(remove-first ,boolean? "Remove the first staff of a orchestral score?")
(right-padding ,ly:dimension? "Space to insert between note and
accidentals.")
+ (same-direction-correction ,number? "Optical correction amount
+for stems that are placed in tight configurations. This amount is used
+for stems with the same direction to compensate for note-head to stem distance.")
(script-priority ,number? "A sorting key that determines in what
order a script is within a stack of scripts.")
"Multiply direction of
@code{direction-source} with this to get the direction of this
object.")
+ (side-axis ,number? "Is this object horizontally or vertically next to another object?")
(size ,number? "Size of object, relative to standard size.")
(slope ,number? "The slope of this object.")
(slur-padding ,number? "Extra distance between slur and script.")
directions, this amount is the correction for two normal sized stems
that overlap completely.")
- (same-direction-correction ,number? "Optical correction amount
-for stems that are placed in tight configurations. This amount is used
-for stems with the same direction to compensate for note-head to stem distance.")
+ (strict-note-spacing ,boolean? "If set, unbroken columns
+with non-musical material (clefs, barlines, etc.) are not spaced
+separately, but put before musical columns.")
(string-count ,integer? "The number of strings in a fret diagram.")
(stroke-style ,string? "set to \"grace\" to turn stroke through flag on.")
(direction . ,UP)
(staff-padding . 0.25)
(script-priority . 0)
+ (side-axis . ,X)
(meta . ((class . Item)
(interfaces . (side-position-interface
script-interface
(stencil . ,Accidental_interface::print)
(after-line-breaking . ,Accidental_interface::after_line_breaking)
+ (side-axis . ,X)
(meta . ((class . Item)
(interfaces . (item-interface
(X-offset . ,Side_position_interface::x_aligned_side)
(direction . -1)
(padding . 0.5)
+ (side-axis . ,X)
(staff-position . 0.0)
(meta . ((class . Item)
(interfaces . (arpeggio-interface
(BarNumber
. (
-
(stencil . ,Text_interface::print)
- ;
(breakable . #t)
(break-visibility . ,begin-of-line-visible)
(padding . 1.0)
(font-family . roman)
(font-size . -2)
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(X-offset . ,Self_alignment_interface::x_aligned_on_self)
(self-alignment-X . 1)
(script-priority . 200)
;; todo: add X self alignment?
(baseline-skip . 2)
+ (side-axis . ,Y)
(font-series . bold)
(meta . ((class . Item)
(interfaces . (text-script-interface
(direction . 1)
(padding . 0.2)
(staff-padding . 0.25)
+ (side-axis . ,Y)
(meta . ((class . Item)
(interfaces . (side-position-interface
self-alignment-interface
(slur-padding . 0.3)
(minimum-space . 1.2)
(direction . -1)
+ (side-axis . ,Y)
(Y-extent . ,Axis_group_interface::height)
(X-extent . ,Axis_group_interface::width)
(HorizontalBracket
. (
(thickness . 1.0)
-
(stencil . ,Horizontal_bracket::print)
-
(Y-offset . ,Side_position_interface::y_aligned_side)
(padding . 0.2)
(staff-padding . 0.2)
(direction . -1)
+ (side-axis . ,Y)
(bracket-flare . (0.5 . 0.5))
(meta . ((class . Spanner)
(interfaces . (horizontal-bracket-interface
(left-edge . (extra-space . 1.0))))
(self-alignment-Y . 0)
-
(stencil . ,Text_interface::print)
-
(break-align-symbol . instrument-name)
(break-visibility . ,begin-of-line-visible)
(baseline-skip . 2)
+ (side-axis . ,X)
(meta . ((class . Item)
(interfaces . (font-interface
self-alignment-interface
(Y-offset . ,Side_position_interface::y_aligned_side)
(direction . 1)
(padding . 0.8)
+ (side-axis . ,Y)
(meta . ((class . Item)
(interfaces . (text-interface
side-position-interface
(MeasureGrouping
. (
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(stencil . ,Measure_grouping::print)
`(,+ ,(ly:make-simple-closure (list Self_alignment_interface::x_aligned_on_self))
,(ly:make-simple-closure (list Self_alignment_interface::x_centered_on_y_parent)))))
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
+
(self-alignment-X . 0)
(direction . 1)
(padding . 0.4)
(padding . 0.20)
(staff-padding . 0.25)
;; (script-priority . 0) priorities for scripts, see script.scm
- (X-offset . ,Self_alignment_interface::centered_on_x_parent)
+ (X-offset . , Self_alignment_interface::centered_on_x_parent)
+
(stencil . ,Script_interface::print)
(direction . ,Script_interface::calc_direction)
. (
(springs-and-rods . ,Spacing_spanner::set_springs)
-
+ (average-spacing-wishes . #t)
(grace-space-factor . 0.6)
(shortest-duration-space . 2.0)
(spacing-increment . 1.2)
(font-series . bold)
(padding . 1.0)
(X-offset . ,Side_position_interface::x_aligned_side)
+ (side-axis . ,X)
(direction . ,LEFT)
(meta . ((class . Item)
(interfaces . (side-position-interface
(X-extent . ,Axis_group_interface::height)
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(padding . 1.2)
(minimum-space . 1.0)
(axes . (1))
(X-extent . ,Axis_group_interface::height)
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(padding . 1.2)
(staff-padding . 1.2)
(minimum-space . 1.0)
(staff-padding . 0.8)
(dash-fraction . 0.2)
(dash-period . 3.0)
+ (side-axis . ,Y)
(direction . 1)
(meta . ((class . Spanner)
(interfaces . (text-spanner-interface
(padding . 0.5)
(direction . 1)
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(meta . ((class . Spanner)
(interfaces . (text-spanner-interface
side-position-interface
(padding . 0.2)
(direction . ,LEFT)
(font-size . -4)
+ (side-axis . ,X)
(stencil . ,Accidental_interface::print)
(meta . ((class . Item)
(interfaces . (item-interface
(font-size . -4)
(stencil . ,parenthesize-elements)
(direction . ,RIGHT)
+ (side-axis . ,X)
(padding . 0.3)
(meta . ((class . Item)
(interfaces . (side-position-interface
(axes . (1))
(X-extent . ,Axis_group_interface::height)
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(padding . 1.2)
(staff-padding . 1.2)
(minimum-space . 1.0)
(break-align-symbol . clef)
(break-visibility . ,begin-of-line-visible)
(baseline-skip . 2)
+ (side-axis . ,Y)
(meta . ((class . Item)
(interfaces . (font-interface
self-alignment-interface
(padding . 1)
(font-encoding . fetaNumber)
(Y-offset . ,Side_position_interface::y_aligned_side)
+ (side-axis . ,Y)
(thickness . 1.6) ;; linethickness
(edge-height . (2.0 . 2.0)) ;; staffspace;
(minimum-space . 5)
"Check if we have R1*4-\\markup { .. }, and if applicable convert to
a property set for MultiMeasureRestNumber."
(define (script-to-mmrest-text script-music)
- "Extract 'direction and 'text from SCRIPT-MUSIC, and transform into property sets."
+ "Extract 'direction and 'text from SCRIPT-MUSIC, and transform MultiMeasureTextEvent"
(let ((dir (ly:music-property script-music 'direction))
(p (make-music 'MultiMeasureTextEvent
'text (ly:music-property script-music 'text))))
(if (ly:dir? dir)
(set! (ly:music-property p 'direction) dir))
p))
+
(if (eq? (ly:music-property music 'name) 'MultiMeasureRestMusicGroup)
(let* ((text? (lambda (x) (memq 'script-event (ly:music-property x 'types))))
- (es (ly:music-property music 'elements))
- (texts (map script-to-mmrest-text (filter text? es)))
- (others (remove text? es)))
- (if (pair? texts)
+ (event? (lambda (x) (memq 'event (ly:music-property x 'types))))
+ (group-elts (ly:music-property music 'elements))
+ (texts '())
+ (events '())
+ (others '()))
+
+ (set! texts
+ (map script-to-mmrest-text (filter text? group-elts)))
+ (set! group-elts
+ (remove text? group-elts))
+
+ (set! events (filter event? group-elts))
+ (set! others (remove event? group-elts))
+
+ (if (or (pair? texts) (pair? events))
(set! (ly:music-property music 'elements)
- (cons (make-event-chord texts) others)))))
+ (cons (make-event-chord
+ (append texts events))
+ others)))
+
+
+ (display-scheme-music (list music))
+
+ ))
+
music)