Potential Bug: Staff Color cannot be changed with plugin
I wrote a short script to change the color of each staff in a score to white. However, when I attempt to run the program, the color of any of the staves do not change. I have the program print out the staff color to the debug log after the attempt to change it to white (#FFFFFF) and the debug log returns back #000000 (black), indicating that nothing has changed. When I change the color of a part's staff manually through "Staff/Part Properties > Staff Line Color" and then check the debug menu of the program, the program still returns the original black color hex value (#000000). Below is the code for the plugin and its QML file in case someone wants to point out that I am doing something wrong.
import QtQuick 2.9 import MuseScore 3.0 MuseScore { menuPath: "Plugins.StaffColor" description: "Re-colors all staves" version: "1.0" onRun: { var nstaves = curScore.nstaves var cursor = curScore.newCursor() cursor.rewind(0) for(var i=0; i<nstaves-1; i++) { cursor.staffIdx = i console.log(cursor.element.staff.part.longName) cursor.element.staff.color = "#ffffff" console.log(cursor.element.staff.color) } Qt.quit(); } }
Attachment | Size |
---|---|
StaffColor.qml | 585 bytes |
Comments
It seems to be just not available (or wrapped incorrectly).
Even if you change the staff line color manually and have it logged before you try to change it, it'll always show the default value of black for the staff.
And I think an attempt to set it (since we don't provide a fraction) would end up here https://github.com/musescore/MuseScore/blob/3.x/libmscore/staff.cpp#L12… in a no-op.
In reply to It seems to be just not… by jeetee
How would I use the program you sent me to help with this? Also if I may ask, what is a no-op? Just for the record, I am an amateur programmer and have only been piecing together what to do through various tutorials.
In reply to How would I use the program… by [DELETED] 30709869
> "How would I use the program you sent me to help with this?"
You wouldn't, it's a link to the source code of MuseScore itself. In particular that is the function within MuseScore I believe to be called when you try to assign a new color from within the plugin.
> "Also if I may ask, what is a no-op?"
A no-op is programmer slang for "No Operation"; meaning nothing happens. It dates back to an assembly instruction (NOP) that resulted in the processor doing nothing for that instruction time.
Since the internal MuseScore function linked above goes to a function in which there is no code (it is commented out), the function in effect does nothing.
So my conclusion is that it seems that changing the staff lines color via QML is a thing that is simply not implemented in the MuseScore code.
Side note: you're not attempting to set every staff to white, since your loop condition is "<
nstaves-1
" meaning you don't alter the last staff in the score.