Expose remaining Part/Staff editing methods to Plugin API#32636
Merged
RomanPudashkin merged 6 commits intomusescore:masterfrom Mar 30, 2026
Merged
Expose remaining Part/Staff editing methods to Plugin API#32636RomanPudashkin merged 6 commits intomusescore:masterfrom
RomanPudashkin merged 6 commits intomusescore:masterfrom
Conversation
Add EditPart::appendStaff and EditPart::appendLinkedStaff static methods that create and append staves to a part, with proper key signature adjustment and bracket/barline updates. Expose both methods as Q_INVOKABLE on apiv1::Score with null checks and LOGW. Add tests for dom level operations with undo/redo and API wrapper verification.
Add EditPart::setVoiceVisible static method that delegates to Excerpt::setVoiceVisible with proper excerpt and canDisableVoice checks. Refactor NotationParts::setVoiceVisible to use the new shared method. Expose as Q_INVOKABLE on apiv1::Score. Add tests verifying it returns false on main scores (excerpt only).
Add EditPart::replaceDrumset static method that applies ChangeDrumset undo commands for all matching instruments in a part. Add Drumset ownership model (m_owned flag) to the API wrapper for safe clone lifecycle, Drumset::setDrum for modifying entries, and Instrument::cloneDrumset for creating modifiable copies. Refactor NotationParts::replaceDrumset undoable path to delegate to EditPart. Add tests for dom level drumset replacement with undo and API workflow.
Add EditPart::insertPart that creates a Part from an InstrumentTemplate with proper staff initialization and MIDI mapping rebuild, and EditPart::replacePart that removes the old part and inserts a new one at the same index. Expose both as Q_INVOKABLE on apiv1::Score with instrumentId string lookup via searchTemplate. Add tests for dom level operations with undo/redo and API wrapper verification.
Add EditPart::setScoreOrder static method that applies ChangeScoreOrder undo command and updates brackets/barlines. Refactor NotationParts::doSetScoreOrder to delegate to EditPart. Expose as Q_INVOKABLE on apiv1::Score with orderId string lookup via the global instrumentOrders vector. Add tests for dom level score order change with undo/redo and API wrapper verification.
RomanPudashkin
approved these changes
Mar 19, 2026
Replace manual pitch range checks with IF_ASSERT_FAILED macro and DRUM_INSTRUMENTS constant in all Drumset setters, as suggested in PR review.
Contributor
|
Tested Layout (Instruments) panel on Win10. No regressions found |
Contributor
|
Won't easily |
RomanPudashkin
added a commit
to RomanPudashkin/MuseScore
that referenced
this pull request
Apr 7, 2026
Expose remaining Part/Staff editing methods to Plugin API
Merged
RomanPudashkin
added a commit
to RomanPudashkin/MuseScore
that referenced
this pull request
Apr 7, 2026
Expose remaining Part/Staff editing methods to Plugin API
RomanPudashkin
added a commit
to RomanPudashkin/MuseScore
that referenced
this pull request
Apr 7, 2026
Expose remaining Part/Staff editing methods to Plugin API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to: #31201
Follow-up to: #31205, #32185
Summary
This is the third and final PR for exposing
NotationPartsmethods to the Plugin API (issue #31201). It implements the 7 methods that were deferred in PR #32185 due to prerequisite work.All new methods follow the established pattern: shared static methods in
EditPart(used by both the Plugin API andNotationParts), withQ_INVOKABLEwrappers on theScoreAPI class.NotationPartsis refactored to delegate toEditPart, eliminating logic duplication.Changes
Commit 1: appendStaff and appendLinkedStaff
appendStaff(destinationPart): Creates and appends a new default staff to a part, returns the new staffappendLinkedStaff(sourceStaff, destinationPart): Creates a staff linked to a source staff, appends it to a part, returns the new staffdoAppendStaffextracted fromNotationPartsfor shared useCommit 2: setVoiceVisible
setVoiceVisible(staff, voiceIndex, visible): Shows or hides a voice in an excerpt score. Returns false if called on a main score (excerpt only limitation)NotationParts::setVoiceVisibleto delegate toEditPartCommit 3: replaceDrumset
replaceDrumset(part, drumset): Applies a modified drumset to all matching instruments in a part (undoable)Instrument::cloneDrumset(): Creates a writable copy of an instrument's drumsetsetName,setNoteHead,setLine,setVoice,setStemDirection,setShortcutm_ownedflag) for safe lifecycle of cloned drumsetsNotationParts::replaceDrumsetundoable path to delegate toEditPartCommit 4: insertPart and replacePart
insertPart(instrumentId, index): Creates a new part from an instrument template and inserts it at the given indexreplacePart(part, instrumentId): Replaces an existing part with a new one created from an instrument templateCommit 5: setScoreOrder
setScoreOrder(orderId): Sets the score order (e.g. "orchestral", "marching-band") which controls part ordering and bracket/barline layoutNotationParts::doSetScoreOrderto delegate toEditPartImplementation checklist
Completed in PR #31205:
replaceInstrument(part, instrumentId)Completed in PR #32185:
setPartVisible(part, visible)setPartSharpFlat(part, sharpFlat)setInstrumentName(part, tick, name)setInstrumentAbbreviature(part, tick, abbreviature)setStaffType(staff, staffTypeId)removeParts(parts)removeStaves(staves)moveParts(sourceParts, destinationPart, mode)moveStaves(sourceStaves, destinationStaff, mode)addSystemObjects(staves)removeSystemObjects(staves)moveSystemObjects(sourceStaff, destinationStaff)visible,cutaway,hideSystemBarLine,mergeMatchingRests,reflectTranspositionInLinkedTab)Completed in this PR:
appendStaff(destinationPart)appendLinkedStaff(sourceStaff, destinationPart)setVoiceVisible(staff, voiceIndex, visible)replaceDrumset(part, drumset)insertPart(instrumentId, index)replacePart(part, instrumentId)setScoreOrder(orderId)Usage examples