#include "engraver.hh"
+#include "accidental-placement.hh"
#include "axis-group-interface.hh"
#include "item.hh"
#include "note-head.hh"
#include "pointer-group-interface.hh"
#include "protected-scm.hh"
#include "side-position-interface.hh"
+#include "separation-item.hh"
#include "staff-symbol-referencer.hh"
#include "stream-event.hh"
Item *group_;
Drul_array<Item *> heads_;
Drul_array<Item *> accidentals_;
+ Drul_array<Stream_event *> causes_;
Pitch_interval pitch_interval_;
bool is_typeset_;
int start_c0_;
accidentals_[d]->self_scm ());
Axis_group_interface::add_element (group_, heads_[d]);
Axis_group_interface::add_element (group_, accidentals_[d]);
- Side_position_interface::add_support (accidentals_[d], heads_[d]);
}
while (flip (&d) != DOWN);
if (nr && nr->in_event_class ("note-event"))
{
Pitch pitch = *unsmob_pitch (nr->get_property ("pitch"));
- pitch_interval_.add_point (pitch);
+ Direction expand_dir = pitch_interval_.add_point (pitch);
+ if (expand_dir)
+ causes_[expand_dir] = nr;
}
}
{
if (ambitus_ && !pitch_interval_.is_empty ())
{
+ Grob * accidental_placement =
+ make_item ("AccidentalPlacement",
+ accidentals_[DOWN]->self_scm ());
+
Direction d = DOWN;
do
{
Pitch p = pitch_interval_[d];
+ heads_[d]->set_property ("cause", causes_[d]->self_scm());
heads_[d]->set_property ("staff-position",
scm_from_int (start_c0_
+ p.steps ()));
{
accidentals_[d]->set_property ("alteration", ly_rational2scm (p.get_alteration ()));
}
+ Separation_item::add_conditional_item (heads_[d], accidental_placement);
+ Accidental_placement::add_accidental (accidental_placement, accidentals_[d]);
}
while (flip (&d) != DOWN);
Pointer_group_interface::add_grob (ambitus_, ly_symbol2scm ("note-heads"), heads_[DOWN]);
Pointer_group_interface::add_grob (ambitus_, ly_symbol2scm ("note-heads"), heads_[UP]);
+ Axis_group_interface::add_element (group_, accidental_placement);
}
else
{
return at (LEFT) > at (RIGHT);
}
-void
+Direction
Pitch_interval::add_point (Pitch p)
{
if (at (LEFT).tone_pitch () > p.tone_pitch ())
- at (LEFT) = p;
- if (at (RIGHT).tone_pitch () < p.tone_pitch ())
- at (RIGHT) = p;
+ {
+ at (LEFT) = p;
+ return LEFT;
+ }
+ else if (at (RIGHT).tone_pitch () < p.tone_pitch ())
+ {
+ at (RIGHT) = p;
+ return RIGHT;
+ }
+ else
+ return CENTER;
}
return at (LEFT) > at (RIGHT);
}
-void
+Direction
Pitch_lexicographic_interval::add_point (Pitch p)
{
if (at (LEFT) > p)
- at (LEFT) = p;
- if (at (RIGHT) < p)
- at (RIGHT) = p;
+ {
+ at (LEFT) = p;
+ return LEFT;
+ }
+ else if (at (RIGHT) < p)
+ {
+ at (RIGHT) = p;
+ return RIGHT;
+ }
+ else
+ return CENTER;
}
"Ideal distance between `line' reference position and `next-line'
reference position. If next-line is #f, return #f."
(and next-line
- (max 0
- (+ (- (+ (interval-end (paper-system-staff-extents next-line))
- (if ignore-padding 0 (line-next-padding line next-line layout)))
- (interval-start (paper-system-staff-extents line)))
- (line-next-space line next-line layout)))))
+ (max (+ (max 0 (- (+ (interval-end (paper-system-staff-extents next-line))
+ (if ignore-padding 0 (line-next-padding line next-line layout)))
+ (interval-start (paper-system-staff-extents line))))
+ (line-next-space line next-line layout))
+ (line-minimum-distance line next-line layout ignore-padding))))
(define (first-line-position line layout)
"Position of the first line on page"