I haven't tested this patch yet and I don't want to distract anyone
from answering Julie's query, but I would like to comment on one thing
in the patch:

    int width=m_rulerScale->getXForTime(e->getDuration());

The mapping from time to pixel position provided by a RulerScale is
not necessarily linear.  You can't just call getXForTime with a
duration and expect to get the right pixel width back -- the pixel
width corresponding to a given duration may vary depending on where in
the timeline that duration begins.

Always use RulerScale::getWidthForDuration(timeT startTime, timeT
duration) when you want to map from duration to pixel width.

In a perfect world, "time" and "duration" would have different data
types, and this sort of confusion would be prevented by the compiler.
In hindsight, I really wish we had done that in Rosegarden.

(Of course, calling getXForTime will work by accident much of the
time.  In the matrix, the mapping _is_ linear.  But it's a pattern
that it pays to get right, as there are plenty of places in Rosegarden
where this kind of mix-up can lead to serious consequences -- most
notably when using the conceptually similar conversions between
musical time and real-time in Composition.h, where mixing up time and
duration will give you the wrong result as soon as you hit a tempo
change.)


Chris

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Rosegarden-devel mailing list
[email protected] - use the link below to unsubscribe
https://lists.sourceforge.net/lists/listinfo/rosegarden-devel

Reply via email to