[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: strange behaviour of DynamicText alignment
From: |
Janek Warchoł |
Subject: |
Re: strange behaviour of DynamicText alignment |
Date: |
Fri, 15 Mar 2013 21:25:32 +0100 |
Hi all,
On Mon, Mar 11, 2013 at 12:47 PM, Janek Warchoł
<address@hidden> wrote:
> Why is DynamicText shifted when aligned?
> Which place in the code is responsible for this?
> I didn't found any answer yet, so help will be much appreciated.
I've found the answer; i'd appreciate if someone could confirm that i
got everything right (that's why i cc Han-Wen, since the code was
written by him).
This behavior is caused by line 274 in new-dynamic-engraver.cc:
if (x_parent)
{
script_->set_parent (x_parent, X_AXIS);
Self_alignment_interface::set_center_parent (script_, X_AXIS);
}
set_center_parent calls add_offset_callback. If i understand
add_offset_callback, it uses closures to add a return value of a
procedure to appropriate offset property. In this case, the result is
that the value calculated by centered_on_x_parent is added to whatever
value is already stored in x-offset property. That's why half a
notehead width (which is the result of centered_on_x_parent) was added
to the result of x-aligned-on-self (or whatever callback i tried to
use for x-offset).
Now, the question is why this is done in this way and not simply by
using aligned_on_x_parent. I've found that this fragment of code was
originally added in commit e456bf18 (June 2005; it was in
dynamic-engraver.cc back then), and from what i understand the
rationale was that aligned_on_x_parent produced wrong results when
grob's parent was a PaperColumn; basically, the idea of commit
e456bf18 was that we should only align on parent if that parent is a
NoteHead.
However, behaviour of aligned_on_x_parent was changed by commit
ebb1f1f1 (Jan 2007) so that PaperColumn parents are ignored.
>From what i see, there is currently nothing wrong with removing that
call to set_center_parent and declaring all alignment explicitely in
define-grobs.scm, especially since i'm going to improve
aligned_on_parent and make it much smarter.
Also, i've noticed that a similar mechanism is used in fingerings.
I'll take a closer look at it; i hope that it could be done in a
different way as well and that set_center_parent and similar stealthy
functions can be eliminated.
Did i get this right?
Suggestions welcome.
thanks,
Janek