Disable Automatic Placement within plugin

• Mar 23, 2019 - 09:19

Hello,
I created a plugin to help in the diatonic accordion tablature.
So the plugin create for each note one (or two) number (with "Stave Texte") below the note.
So each number is placed with offsetY =...
But the problem is than the numbers, after to apply the plugin, are not in the right place, because the "Automatic Placement".
I must to select all the numbers, and after to disable "Automatic Placement" in the Inspector to have the right place of numbers.
It's not very easy.
So is it possible to disable "Automatic Placement" directly in the plugin code ?

Thanks.


Comments

I don't know the answer, but I'm not quite understanding how disabling automatic placement would help. Are you perhaps not setting placement to below? Merely setting Y offset wouldn't be sufficient, or even advisable.

In reply to by Marc Sabatella

Thanks for your answer.
I don't really understand :-)
So I'll try to explain more clearly (sorry for my english).

The purpose of the plugin is, for a note, to display a number on the tablature.
So the good result is like this :
MuseScore3_Accord_diaton_012.jpg
That's what I would like to have directly.

As you can see above, some numbers are in the first line, others on the second, at a specific location.
So, in the plugin code, the placement is done with offsetY = 18; and offsetY = 13.5;
The numbers are inserted in "Stave Text".

The problem is than "Automatic Placement" is enable by default.
So, when I apply the plugin, I have this :
MuseScore3_Accord_diaton_013.jpg

The numbers are not in the good place.
To resolve this, I must to select a number, and right click, "Select" > "All Similar Elements", and after to disable "Automatic Placement" in the Inspector to have the right place of numbers.

If Automatic Placements were not enabled by default, or if it was possible to disable them by the plugin, no problem. The numbers would be in their good location immediately.
But it's not the case.

I hope my problem is clearer.
Now maybe I do not quite understand all and that can be solved more easily.
Maybe the problem is me :-)

Thanks.

In reply to by Jipsi

What I am saying is, don't uncheck automatic placement and try to force the numbers below with a big vertical offset, just set the Placement field to Below. At least, this would work if you didn't also have a totally separate staff you are trying to place the fingering on. In that case, simply attach the fingering to the correct staff. But I wouldn't recommend using a separate staff for this personally.

In reply to by Marc Sabatella

Marc, why now systematically you reply, a priori, for a raison or another one: "but" I'm not quite understanding how disabling automatic placement would help"

It may help, of course.
Each time you ask for a use case in the real world. I understand the reason, but I also believe that no one can really realize the incredible quantity and diversity of ways to input music in notes or tablatures according to styles, periods, instruments etc.

"But I wouldn't recommend using a separate staff for this personally."

Sorry, but you're on the wrong track here.
Precisely, here is a case of very frequent use in the notation of traditional accordions (with tablature systems). And there are, in addition, variants. But basically, they require this display (image below) Of course, as you can see, it's published scores.

Some users simply ask you to take into account that version 3 complicates the task, is much less flexible to adapt certain ways of scoring in comparison with the versions 2.x
And when the request to disable automatic placement is expressed: try to hear it. It is not a users whim, it's a request that may be quite relevant.

diato.jpg

In reply to by cadiz1

OK, thanks for the info, this was new to me and I thought to the person to whom I was replying was making up their own notation system.

We don't really have a good way of creating layouts like the above, but I'd probably go with two single-line staff, and then place text above or below each as appropriate. All without ever disabling automatic placement.

Which again is why I usually start by wanting to understand why people are thinking they need to disable it - it is very rarely necessary, and the majority of times when people show why they are wanting to, it turns out there is a far better way to do the job without disabling it. My goal is to help users to their job more easily, and very often the best way to do this is to show them how to work even more efficiently than they possibly could have imagined. And I think this is a perfect case in point. So far, all evidence suggests you could do what is needed here more easily without disabling automatic placement, if you set up your score appropriately.

When cases come up where disabling automatic placement is the best way to go, I always tell people this. And as you know, I have a pending PR to make that process simpler.

My goal is help people by giving them the best tools I can and the best information I can on how to use those tools in the most efficient manner.

In reply to by Marc Sabatella

You don't want to understand. For the user, it is not a matter of entering a line of text below/above with two single-line staff.
We talk about a plugin.
It is the only one who does the work, and it is not smart enough to bypass automatic placement. It simply indicates which fingering alternatives are available.
And when it is applied, it comes as shown in the second image of this comment: two rows of fingering above standard staff (https://musescore.org/en/node/286552#comment-906671)
And you are forced to disable everything and move with the offsets.

In reply to by cadiz1

Of course I want to understand. I wouldn't ask for information if I didn't. Please don't insult me by accusing me of not wanting to understand. I work hard to help people. I respect the work you do helping people here, I would appreciate the same.

I get that this is a plugin. I am not familiar with all the ins and outs of how plugins work, so I can't address all the specifics of that. But I do know, plugins work by using the same features that are available within the program itself. And if it's possible to do something in the program itself a particular way, it's reasonable to want to do that in the plugin. The OP was thinking they wanted to disable automatic placement within the plugin to get the job one, and right now I guess that option isn't available, but since that's not even necessarily the best way to do it outside a plugin. I don't see why it would be assumed to be the best way to do it within a plugin either. And in any case, it's not available as far as I know, so I am trying to help the user find a way to get the job done.

That said, what I would suggest as a "quick fix" rather than re-designing the plugin to work more way it probably should is to simply set the "Autoplace min. distance" style setting to -9999 in Format / Style / Staff Text (perhaps that can be done via a plugin? or load an MSS file to accomplish the same)? This has the effect of disabling autoplace for all staff text elements.

In reply to by cadiz1

OK, I will attribute that misunderstanding to a language issue. I do trust that you believe I want to understand and help, just as I know that you want to understand and help.

FWIW, attached is one way I might have set up the score shown above, using one-line staves so you can attach text directly to them. I've actually used both chord symbols and staff text because I wasn't sure which I preferred. All of this should be easily doable from a plugin, and none of it requires disabling automatic placement. If I were doing it by hand, I'd use a similar approach if I had a lot of them to do, as it is more setup initially but then easier after that. If I were just doing a few bars, it's also possible I'd try to do it all with text attached to the top staff, large offsets, and disabling autoplace for staff text via the method I described.

Here's what it looks like using the method I chose, actually attaching the tablature to the one-line staves:

accordion.png

Attachment Size
accordion.mscz 5.73 KB

In reply to by Marc Sabatella

Ok,
Thank you both for your help.
No, I'm not creating my own notation system :-)

I tried to set the "Autoplace min. distance" style setting to -9999 in Format / Style / Staff Text of the score file, but I can't set more than -99, and it doesn't work.

Thanks Marc for your file.
But when I open it, I have this :
MuseScore3_accordion_001.jpg

Maybe I haven't the same Musescore Version ?
I have this :
OS: Windows 10 (10.0), Arch.: x86_64, MuseScore version (64-bit): 3.0.5.5992, revision: 58dd23d

But, if I'm not mistaken, here you enter the number by hand, not automatically.

To be as clear as possible and to work on the same basis, here is the complete basic file of my score :
Jipsi_Base_Accordeon Diatonique_4-4_01.mscz
And my plugin file :
Jipsi_TAD_Tablature_pour_Accordeon_Diatonique_G-C_21T_V3_3002-.qml

As you can see, all works when we apply the plugin (well, I hope, because here it's good), excepted de placement of the numbers.
The only problem here is the "Automatic placement".
If they could be disabled by default in the base file of the score, or through the plugin, everything would be perfect and functional.
I understand that automatic placement may be convenient in some cases, but in mine or others, the ability to disable would solve many problems, in my opinion.
I also had problems opening v2 files with v3 just because of automatic placements. The files could have been compatible without these "compulsory" automatic placements, and there they are unusable. I hope you understand what I mean.
But maybe I'm asking too much.

Anyway, thanks for your help attempt.

In reply to by Jipsi

Sorry, I forgot about a bug involving setting of offsets when using both above & below placements, so some of the offsets were lost on save/reload. I could adjust it to work differently if necessary.

Anyhow, yes, I did this by hand, but I did it using the methodology I would recommend if I were doing it programmatically - basically, just setting the track / staff of the annotations to be that of the lower staff, not the upper. This to me is simpler and more logical than attaching the amrking to the top staff but then trying to guess at a vertical offset that will happen to place it in the right place for the staff below (your method won't work if the staff distance ever change, for example).

But indeed, if you do use the large vertical offset approach, you will need to disable automatic placement. I'm not familiar enough with the plugin framework to know if that can be done programmatically, but the method I mentioned before works (and -99 works just as well, as long as you aren't trying to trying to create offsets larger than that).

In reply to by Marc Sabatella

Ok, I understand what you mean, Marc.

But with your method, I have two major problems :

1- This bug with above and below is a real problem : I must to select manually all the numbers which are above, and in the editor, to click on below, and after on above to have the correct placement.
And after, I must to do the same thing with the numbers which are below.
In the end it is even longer than the first method.
But maybe there is another solution I don't know.

  1. I don't know what code to use in the plugin to insert numbers on this first Claves Stave 1. And after this, to insert below or above.

But we must recognize that it is a shame to have x and y offset functions in the software, and not to be able to use them directly.

I try the -99 method directly in the score file, and not with the plugin.
It's almost good.
Numbers are in the good place, but there is a problem : the numbers "push" the lines down (and the automatic placement is still checked in the inspector), as you can see :
MuseScore3_accordion_002.jpg

In reply to by Jipsi

Ah yes, good point about the -99sp method still resulting in staves spacing themselves. FWIW, you can get around this by also setting minVerticalDistance to -99sp. Not exposed in the UI, but you can edit a style file to add that line.

As for how to add text directly to the staff you need, in principle it's a question of once you have the segment of the note, just change the "track" when adding the text. But I am not up on the current state of the [lugin framework to advise further on how to do that.

But anyhow, if there is no way to disable autoplace on a given element from a plugin, I agree it should be added, so I'd encourage you to file a formal "Suggestion" to via "Suppport / Issue tracker" on that.

Regarding x & y, I would say you can use them directly, they work exactly the way they do internally - to set the default position of an element before autoplace starts looking for collisions.

Do you still have an unanswered question? Please log in first to post your question.