source file of the GNU LilyPond music typesetter
-(c) 2002 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+(c) 2002--2004 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
Grob * me =unsmob_grob (s);
Grob * par = me->get_parent (X_AXIS);
- if (!to_boolean (par->get_grob_property ("alignment-done")))
+ if (!to_boolean (par->get_grob_property ("positioning-done")))
{
- par->set_grob_property ("alignment-done", SCM_BOOL_T);
+ par->set_grob_property ("positioning-done", SCM_BOOL_T);
position_accidentals (par);
}
- return gh_int2scm (0);
+ return scm_int2num (0);
}
-
void
Accidental_placement::add_accidental (Grob* me, Grob* a)
{
Pitch *p= unsmob_pitch (mcause->get_mus_property ("pitch"));
- int n = p->notename_;
+ int n = p->get_notename ();
SCM accs = me->get_grob_property ("accidental-grobs");
- SCM key = gh_int2scm (n);
+ SCM key = scm_int2num (n);
SCM entry = scm_assq (key, accs);
if (entry == SCM_BOOL_F)
{
extent.unite (which->elem(i)->extent (item_col, X_AXIS));
}
- if (!extent.empty_b())
+ if (!extent.is_empty ())
{
- Real p = gh_scm2double (me->get_grob_property ("left-padding"));
+ Real p = robust_scm2double (me->get_grob_property ("left-padding"), 0.2);
extent[LEFT] -= p;
}
*/
+/*
+ TODO: there should be more space in the following situation
+
+
+ Natural + downstem
+
+ |_
+ | | X
+ |_| |
+ | |
+
+ */
SCM
Accidental_placement::position_accidentals (Grob * me)
{
/*
TODO: there is a bug in this code. If two accs are on the same
- Y-position, they share an Ape, and will be pritned in overstrike.
+ Y-position, they share an Ape, and will be printed in overstrike.
*/
Link_array<Accidental_placement_entry> apes;
for (SCM s = accs; gh_pair_p (s); s =gh_cdr (s))
head_ape-> left_skyline_ = head_skyline;
head_ape->offset_ = 0.0;
- SCM rs = me->get_grob_property ("right-padding");
- if (gh_number_p (rs))
- head_ape->offset_ -= gh_scm2double (rs);
+ head_ape->offset_ -= robust_scm2double ( me->get_grob_property ("right-padding"), 0);
- Real padding = 0.2;
- SCM spad = me->get_grob_property ("padding");
- if (gh_number_p (spad))
- padding = gh_scm2double (spad);
-
+ Real padding = robust_scm2double (me->get_grob_property ("padding"),0.2);
+ Array<Skyline_entry> left_skyline = head_ape->left_skyline_;
/*
- TODO:
-
- There is a bug in this code: the left_skylines should be
- accumulated, otherwise the b will collide with bb in
-
- bb
- b
- n
-
+ Add accs entries right-to-left.
*/
- apes.push (head_ape);
- for (int i= apes.size () -1 ; i-- > 0;)
+ for (int i= apes.size (); i-- > 0;)
{
- Accidental_placement_entry *ape = apes[i];
- Real d = 0.0;
- int j = i+1;
- do {
- d = - skyline_meshing_distance (ape->right_skyline_,
- apes[j]->left_skyline_);
-
- if (!isinf(d)
- || j + 1 == apes.size())
- break;
-
- j = j+ 1;
- } while (1);
-
- if (isinf(d))
- d = 0.0;
-
- d -= padding;
- ape->offset_ += apes[j]->offset_ + d;
- }
+ Real offset =
+ -skyline_meshing_distance (apes[i]->right_skyline_, left_skyline);
+ if (isinf (offset))
+ offset = (i < apes.size () - 1) ? apes[i+1]->offset_ : 0.0;
+ else
+ offset -= padding;
+
+ apes[i]->offset_ = offset;
+
+ Array<Skyline_entry> new_left_skyline = apes[i]->left_skyline_;
+ heighten_skyline (&new_left_skyline, apes[i]->offset_);
+ merge_skyline (&new_left_skyline, left_skyline, LEFT);
+ left_skyline = new_left_skyline;
+ }
- apes.pop();
for (int i = apes.size(); i--;)
{
Accidental_placement_entry* ape = apes[i];
for (int i = ape->extents_.size(); i--;)
right_extent.unite (ape->offset_ + ape->extents_[i][X_AXIS]);
- SCM ls = me->get_grob_property ("left-padding");
- if (gh_number_p (rs))
- left_extent[LEFT] -= gh_scm2double (ls);
+
+ left_extent[LEFT] -= robust_scm2double (me->get_grob_property ("left-padding"), 0);
Interval width(left_extent[LEFT], right_extent[RIGHT]);
ADD_INTERFACE(Accidental_placement,
"accidental-placement-interface",
"Take care of complex accidental collisions.",
- "left-padding padding right-padding accidental-grobs alignment-done")
+ "left-padding padding right-padding accidental-grobs positioning-done")