Skip to content
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

Plugin API: merge changes from onScoreStateChanged with user action in undo stack #5626

Conversation

dmitrio95
Copy link
Contributor

After having tried some of the suggestions in dmitrio95/fretboard-plugin#1 (comment) it turned out that the experimental score changes notification API does not play well with the concept of undoable actions. As a part of handling score state change a plugin may want to make some adjustment to a score (for example, update some elements or their properties). In order to make it undoable it must call startCmd()/endCmd(). However this creates a separate entry in undo stack with the changes made by a plugin. When user tries to undo this action, only plugin-originated action will be undone and not the one made by user. Moreover, as plugin-originated changes are likely to depend on score state it will likely try to redo this change again. In this case his will lead to inability to undo anything at all while such plugin is running.

In order to make this situation better it is proposed to merge plugin-originated changes made in response to user action with the user action itself, so invoking "Undo" command would undo both plugin-originated and user-originated changes. This should enable creating plugins which modify score editing process in certain way. An example of such plugin could be a "Note Names" plugin which updates note names for the relevant range on each score change without requiring explicit invocation by user. It might be useful for plugin developers to have such an example plugin bundled with MuseScore so I will probably create a modified version of this plugin shortly.

@Jojo-Schmitz
Copy link
Contributor

Compile error.

@dmitrio95 dmitrio95 force-pushed the plugin-scorestatechanged-undo-commands-merge branch from 133fa5f to e3d44b6 Compare January 20, 2020 11:46
@dmitrio95 dmitrio95 merged commit 6f93230 into musescore:master Jan 21, 2020
@dmitrio95 dmitrio95 deleted the plugin-scorestatechanged-undo-commands-merge branch January 21, 2020 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants