lmms icon indicating copy to clipboard operation
lmms copied to clipboard

Instrument window width is incorrect, shows unintentional background tiling

Open rubiefawn opened this issue 8 months ago • 4 comments

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.

image image

rubiefawn avatar Mar 19 '25 19:03 rubiefawn

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).

Image

I am on Arch Linux, GNOME 47, Wayland (though I suspect lmms doesn't use wayland).

regulus79 avatar Mar 20 '25 01:03 regulus79

Possibly related: #7876 Drag an instrument over (replacing) a SlicerT window, which is a bigger window.

anytizer avatar May 11 '25 02:05 anytizer

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.

michaelgregorius avatar May 11 '25 11:05 michaelgregorius

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:

Image

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 setBrush in 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.

michaelgregorius avatar May 13 '25 18:05 michaelgregorius

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:

Image

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.

michaelgregorius avatar Jun 22 '25 10:06 michaelgregorius