AuburnSounds / Dplug

Make VST2 / VST3 / AU / AAX / CLAP / LV2 / FLP plug-ins for Linux/macOS/Windows, using D.
https://dplug.org/
Other
488 stars 32 forks source link

Resizeable UI #64

Closed p0nce closed 3 years ago

p0nce commented 9 years ago
p0nce commented 8 years ago

In AU sometimes getting the view frame yield surprising results, currently disabled. This will be something to fix before considering resizeable UI.

abaga129 commented 4 years ago

I would like to work on this one next. It would be very beneficial for Convergence. Do you foresee any major complications besides the AU view frame issue?

p0nce commented 4 years ago

This is how I think it should work, some of the work was put in place years ago already:

After that, when and if the host does resize the parent window:

The method that becomes important is reflow, a virtual method from UIElement in which all lines touching .position of widgets should go. UIElement.reflow is completely overriden by the background widgets, so the default implementation in UIElement should be empty.

I don't think we'll support live resize (the window is resizeable, reflow while resizing the window), sounds more complicated.

abaga129 commented 4 years ago

There is more to this than I had considered. I was thinking that resizing would only be from the windowing side of things. I was only considering the case where the plug-in window could be "stretched" to fit the window when it was resized (from the host). In my mind, we would be able to use bi-linear interpolation to draw to the new window size. I'm going to have to put much more thought into this clearly.

p0nce commented 4 years ago

Actually the two solutions are possible and are independent.

I think both type of resizing are needed in the end.

One is about IGraphics having a changing size. (the one I described)

One is about the Windows having a different size than the IGraphics object. Useful for HiDPI(?) and iPad. It's not that easy since rect invalidation is already messy on Windows and currently the code convert IGraphics unit into Window unit without care.

Both can be implemented independently but in both we also need a way to resize an image first (probably could be another subpackage). I think Voxengo has an image resizing library.

p0nce commented 3 years ago

Trying to clarify the situation we want to be in.

EDIT : NOT ACCURATE AT ALL

how resizing works in Dplug
p0nce commented 3 years ago

Important concept:

p0nce commented 3 years ago

There is a problem right now:

p0nce commented 3 years ago

For proper invalidation, onResized must be put outside WM_PAINT. (EDIT: OK)

Here are the messages seen when creating a plugin window sequence:

Inside CreateWindowEx:
129 WM_NCCREATE
131 WM_NCCALCSIZE
1 WM_CREATE
5 WM_SIZE
3 WM_MOVE
24 WM_SHOWWINDOW
70 WM_WINDOWPOSCHANGING
133 WM_NCPAINT
20 WM_ERASEBKGND
71 WM_WINDOWPOSCHANGED
// following messages are after CreateWindowEx, so you can access the Win32Window
641 WM_IME_SETCONTEXT
7 WM_SETFOCUS
8 WM_KILLFOCUS
641 WM_IME_SETCONTEXT
642 WM_IME_NOTIFY
3 WM_MOVE
15 WM_PAINT
p0nce commented 3 years ago
p0nce commented 3 years ago

I'm happy to say that plugin resizing is now supported! That was the oldest ticket alive. Support in 11.0.8+

p0nce commented 3 years ago

Remaining known issues:

redthing1 commented 3 years ago

Is there a code example?

p0nce commented 3 years ago

Distort and ClipIt now have a resizing widget in the bottom-right corner. They are the reference examples to copy.

p0nce commented 2 years ago

Didn't see any issue with Cubase 12 + Win 11 + VST2 or VST3