lmms
lmms copied to clipboard
Instrument window width is incorrect, shows unintentional background tiling
Some instrument windows are wider than they should be (most of them are designed for artwork that is 250px wide). This causes the background artwork to visibly repeat. The amount of extra width appears to vary from user to user.
I have had difficultly tracking down the cause of this. However, I noticed that it only occurs on ZynAddSubFX, OpulenZ, and VeSTige. Also, while it does occur on my self-compiled build, I noticed it did not occur on an appimage build while I was testing a PR (I can't remember which one).
I am on Arch Linux, GNOME 47, Wayland (though I suspect lmms doesn't use wayland).
Possibly related: #7876 Drag an instrument over (replacing) a SlicerT window, which is a bigger window.
The problem is caused by the plugin widgets simply setting the background image as the background brush without setting a fixed size according to the used background image for themselves. See for example here: https://github.com/LMMS/lmms/blob/e50f31281862ab0d58a6b398d46a757c6727a056/plugins/ZynAddSubFx/ZynAddSubFx.cpp#L501
This means that if the plugin widget gets space assigned which is larger than the background image then it will simply use that space and fill it with the repeated background image (because its set as a brush). IMO the proper fix is to adjust all plugin widgets so that they do not grow beyond the background image size as most of them assume that as the maximum size anyway, i.e. they do not move child widgets outside of that area. I guess the widgets should also explicitly paint the background image instead of setting it as a brush so that it cannot get repeated in the first place.
If you search for setBrush( you will find that unfortunately it is implemented in a lot of places like this.
A more dirty and subpar fix might be to wrap the plugin widgets into a fixed size widget which then gets displayed and managed by the instrument view. The problem with that approach is that it would assume that all plugin views have a size of 250x250 pixels which is not the case, e.g. for SlicerT. Hence it would be better if each plugin view would encode its own requirements. The outside world should not make any assumptions about their implementation details anyway.
The repeating background can indeed be fixed by setting a fixed size. I have tested this with ZynAddSubFx by replacing
https://github.com/LMMS/lmms/blob/e50f31281862ab0d58a6b398d46a757c6727a056/plugins/ZynAddSubFx/ZynAddSubFx.cpp#L501
with
auto pixmap(PLUGIN_NAME::getIconPixmap("artwork"));
pal.setBrush( backgroundRole(), pixmap);
setFixedSize(pixmap.size());
Here's how the ZynAddSubFx window looks after the following steps:
- Pull ZynAddSubFx onto the song editor.
- Open the ZynAddSubFx window.
- Pull SlicerT on the ZynAddSubFx so that the instrument windows becomes larger.
- Pull ZynAddSubFx onto the SlicerT instance.
This is the result:
So fixing this as described above might be a good first issue which consists of lots of grunt work. It would coarsely look as follows:
- Search for
setBrushin the code. - For each instrument that you find:
- Fix the code with the pattern shown above.
- Test this by adding and opening the fixed instrument. Drag SlicerT on the tested instrument. Drag an instance of the tested instrument onto SlicerT and check if the background pattern is not repeated.
Edit: I have noticed that this PR links https://github.com/LMMS/lmms/pull/7805 which has already identified and somewhat fixed the problem described below.
The cause of some plugins being wider is the message "Microtuner is not available for MIDI-based instruments." on the "Tuning and transposition" page:
See also here: https://github.com/LMMS/lmms/issues/7582#issuecomment-2993719397
IMO this should be fixed as described above by making sure that the plugins do not repeat their background brush, either by setting them to a fixed size or by not using a brush to paint the background.