yucongj / piano-precision

GNU General Public License v2.0
8 stars 1 forks source link

Use the system extents to establish highlight rects #34

Closed cannam closed 7 months ago

cannam commented 7 months ago

This modifies the highlight areas (for mouse interaction and selection) so as to use the full system height.

The mechanism is inspired by your suggestion based on measure elements, but it works top-down instead of bottom-up and looks for system elements rather than measure ones.

The top-down part (searching through the page tree downwards from the document root) is because we really want to perform this lookup all in one go, when the document is loaded and we have access to the SVG XML - so we might as well read the tree system-by-system. At the later moment when we actually want to draw something, we only have the opaque SVG renderer available to us and it seems a shame to have to refer back to the raw XML then. Also, it is just a bit easier to descend through the tree than ascend up it.

The use of system elements instead of measure elements is solely because it was a bit simpler. It takes the system height from the vertical bar that is the first element in the system. I have only tested this so far with one single piece, the Mozart - if it turns out that this isn't good enough (e.g. because single-staff systems have no system group or vertical bar) it should be easy enough to change, now that the general logic is known to work.