7
44
Fork
You've already forked nice-plug
22

Implement Host->Plugin editor resizing (CLAP + VST3) #48

Merged
BillyDM merged 2 commits from aidan729/nice-plug:feat/editor-resize into main 2026年06月15日 22:23:58 +02:00
Contributor
Copy link

Summary

The CLAP and VST3 wrappers ship with editor resizing stubbed out
(// TODO: Implement Host->Plugin GUI resizing). Because can_resize /
canResize return false, hosts treat every editor as fixed-size:
request_resize() has no effect and the editor only adopts a new size on a full
close and reopen.

This PR implements Host->Plugin resizing across the trait and both wrappers,
without breaking any existing adapter.

Changes

  • nice-plug-core: add Editor::set_size(width, height) -> bool, defaulting
    to a no-op that returns false. This is the counterpart to Editor::size():
    the wrapper calls it when the host resizes the view, and the editor resizes its
    window/contents to the given logical dimensions. Editors that don't support
    resizing inherit the default and behave exactly as before.

  • CLAP wrapper (crates/nice-plug/src/wrapper/clap/wrapper.rs):

    • ext_gui_can_resize -> true
    • ext_gui_get_resize_hints -> fills clap_gui_resize_hints
      (can_resize_horizontally/vertically = true, no aspect-ratio lock)
    • ext_gui_adjust_size -> accepts the proposed size as-is
    • ext_gui_set_size -> converts physical -> logical via the editor scaling
      factor and calls Editor::set_size
  • VST3 wrapper (crates/nice-plug/src/wrapper/vst3/view.rs):

    • canResize -> kResultOk
    • onSize -> converts the ViewRect to logical px and calls
      Editor::set_size

Compatibility

set_size has a default implementation, so this is a non-breaking, additive
change. Editors that don't opt in keep returning false, and the host's resize
is rejected (the previous fixed-size behavior). Adapters that want resizing just
implement set_size.

Notes / follow-ups

  • request_resize() (CLAP context, VST3 request_resize) was already correct;
    it simply had no effect while can_resize/canResize returned false.
  • Verified on Windows (CLAP + VST3) with a webview-based editor that resizes its
    window live from a UI drag handle. macOS/Linux resize paths follow the same
    trait call but haven't been exercised here; the VST3 Linux IRunLoop plumbing
    already in setFrame should cover the run-loop requirement.
### Summary The CLAP and VST3 wrappers ship with editor resizing stubbed out (`// TODO: Implement Host->Plugin GUI resizing`). Because `can_resize` / `canResize` return false, hosts treat every editor as fixed-size: `request_resize()` has no effect and the editor only adopts a new size on a full close and reopen. This PR implements Host->Plugin resizing across the trait and both wrappers, without breaking any existing adapter. ### Changes - **nice-plug-core**: add `Editor::set_size(width, height) -> bool`, defaulting to a no-op that returns `false`. This is the counterpart to `Editor::size()`: the wrapper calls it when the host resizes the view, and the editor resizes its window/contents to the given *logical* dimensions. Editors that don't support resizing inherit the default and behave exactly as before. - **CLAP wrapper** (`crates/nice-plug/src/wrapper/clap/wrapper.rs`): - `ext_gui_can_resize` -> `true` - `ext_gui_get_resize_hints` -> fills `clap_gui_resize_hints` (`can_resize_horizontally`/`vertically = true`, no aspect-ratio lock) - `ext_gui_adjust_size` -> accepts the proposed size as-is - `ext_gui_set_size` -> converts physical -> logical via the editor scaling factor and calls `Editor::set_size` - **VST3 wrapper** (`crates/nice-plug/src/wrapper/vst3/view.rs`): - `canResize` -> `kResultOk` - `onSize` -> converts the `ViewRect` to logical px and calls `Editor::set_size` ### Compatibility `set_size` has a default implementation, so this is a non-breaking, additive change. Editors that don't opt in keep returning `false`, and the host's resize is rejected (the previous fixed-size behavior). Adapters that want resizing just implement `set_size`. ### Notes / follow-ups - `request_resize()` (CLAP context, VST3 `request_resize`) was already correct; it simply had no effect while `can_resize`/`canResize` returned false. - Verified on Windows (CLAP + VST3) with a webview-based editor that resizes its window live from a UI drag handle. macOS/Linux resize paths follow the same trait call but haven't been exercised here; the VST3 Linux `IRunLoop` plumbing already in `setFrame` should cover the run-loop requirement.
Add an Editor::set_size(width, height) -> bool hook to the core trait
(default no-op returning false, so existing editors are unaffected) and
implement the previously-stubbed resize entry points in both wrappers:
- CLAP gui ext: can_resize -> true, get_resize_hints fills the hints
 struct (resizable both axes, no aspect lock), djust_size accepts the
 proposed size, set_size converts the host's physical size to logical
 and calls Editor::set_size.
- VST3 IPlugView: canResize -> kResultOk, onSize converts the
 ViewRect to logical px and calls Editor::set_size.
Editors that don't override set_size return false and the host's resize
is rejected, preserving the previous fixed-size behavior. The change is
adapter-agnostic: any editor (egui, iced, slint, or a third-party adapter)
gains host resizing simply by implementing set_size.
@ -2858,0 +2867,4 @@
hints.aspect_ratio_width=1;
hints.aspect_ratio_height=1;
true
Owner
Copy link

Instead of assuming these values for all plugins, I think we should add a Editor::resize_hint(&self) -> ResizeHint method to the Editor trait. (The ResizeHint struct will then contain those fields, as well as a "can resize" field used for ext_gui_can_resize on VST3's canResize.

Instead of assuming these values for all plugins, I think we should add a `Editor::resize_hint(&self) -> ResizeHint` method to the `Editor` trait. (The `ResizeHint` struct will then contain those fields, as well as a "can resize" field used for `ext_gui_can_resize` on VST3's `canResize`.
Author
Contributor
Copy link

This was a good call and oversight on my part also it is done. Added a ResizeHint struct and an Editor::resize_hint(&self) -> ResizeHint method to the trait. It carries can_resize (drives CLAP can_resize + VST3 canResize), the per-axis can_resize_horizontally/can_resize_vertically, and the aspect-ratio fields. Both wrappers now read it instead of assuming. Default is non-resizable, so editors keep fixed-size behavior unless they opt in (there's a ResizeHint::resizable() helper for the common freely-resizable case). ext_gui_get_resize_hints returns false when can_resize is false, as the spec expects.

This was a good call and oversight on my part also it is done. Added a ResizeHint struct and an Editor::resize_hint(&self) -> ResizeHint method to the trait. It carries can_resize (drives CLAP can_resize + VST3 canResize), the per-axis can_resize_horizontally/can_resize_vertically, and the aspect-ratio fields. Both wrappers now read it instead of assuming. Default is non-resizable, so editors keep fixed-size behavior unless they opt in (there's a ResizeHint::resizable() helper for the common freely-resizable case). ext_gui_get_resize_hints returns false when can_resize is false, as the spec expects.
aidan729 marked this conversation as resolved
Replace the hardcoded 'freely resizable, no aspect lock' assumption in
the CLAP/VST3 resize-capability callbacks with a per-editor ResizeHint
returned from a new Editor::resize_hint() method.
ResizeHint carries can_resize (drives CLAP gui.can_resize +
gui.get_resize_hints and VST3 canResize), per-axis can_resize_*, and the
preserve_aspect_ratio / aspect_ratio_* fields. It defaults to
non-resizable so editors keep their fixed-size behavior unless they opt
in; ResizeHint::resizable() covers the common freely-resizable case.
Exported from the prelude.

Alright, looks good to me now. Thanks!

Alright, looks good to me now. Thanks!
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
RustAudio/nice-plug!48
Reference in a new issue
RustAudio/nice-plug
No description provided.
Delete branch "aidan729/nice-plug:feat/editor-resize"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?