-
Notifications
You must be signed in to change notification settings - Fork 3k
Expose Score spannerMap to plugins #31039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
313bb56 to
b2df74b
Compare
XiaoMigros
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am opposed to exposing voltas as a separate element in the API. All the newly added properties are retrievable with the API already (and if they aren't, then that is due to more systemic issues that should be solved by other means).
Exposing the spanner map is a welcome change, as those are some of the last elements that plugins have (up to now) had no easy way of finding.
Makes sense. I'll drop the voltas, and the separate |
|
For the record, volta endings can be accessed by the |
b2df74b to
60a830b
Compare
60a830b to
9dd57b8
Compare
|
Changes pushed - should resolve all review comments so far. I've also updated the title to be more accurate. The updated example to turn voltas red is: for (const spanner of curScore.spanners) {
if (spanner.type === Element.VOLTA)) {
spanner.lineColor = "#ff0000";
}
} |
XiaoMigros
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After testing locally, this is great! A very useful addition to the API.
|
This fixes: #31061 |
Currently plugins cannot access voltas, since these are in the Score's spannerMap. This PR exposes both the spannerMap and the Volta class to the API. Plugins can either iterate all Score-level spanners using
curScore.spanners, or filter down using, eg:I've tested plugins using this sort of thing and they seem to work fine.
I've tried to follow the existing conventions: just safely expose the DOM directly with a minimal API layer. In particular, iterating the spannerMap from a plugin is quadratic (
spannerListCount()andspannerListAt()both are O(n)) but the alternative seems to be building some sort of cache and knowing when to invalidate it, which is opening a can of worms. The scores I've tested have only had a small number of voltas, ties etc, and so exhibited no performance issues whatsoever.I've assumed this will be a 4.7 thing in the new
\sincedeclarations.The compiler warning fix
9da9c63becomes an error with the other changes, hence its inclusion here.