gfx/resizer.h
Dragging an editor's edges, not just the corner in the bottom right.
#include <sonore/gfx/resizer.h>- 1type
- 2other declarations
- Guides: The native editor
On this page
Design notes
What was here before
A ResizableCorner and a BoundsConstrainer, in tooltip.h, used by nothing at all. Written, correct as far as they went, and wired into no editor -- so no plugin built with this SDK has ever shown the user a grip. The classes existed and the capability did not, which is the failure this file is the second half of.
Why a plugin editor cannot drag every edge
A plugin editor does not own its window. The host does: it decides where the frame sits and how big it is, and the only correct thing an editor can do is ASK, through clap_gui_request_resize or IPlugFrame::resizeView.
That asymmetry has a consequence people get wrong. Dragging the RIGHT edge asks for a wider window and the top-left corner stays put, which the host can honour. Dragging the LEFT edge asks for a wider window whose top-left corner MOVES -- and a plugin cannot move its own frame. Wired up naively, dragging the left edge grows the window to the right, which is the opposite of what the hand did.
So the zones are individually enableable, the drag reports an ORIGIN SHIFT as well as a size, and a plugin editor turns the left and top edges off while a standalone window -- which really does own its frame -- leaves them on.
The constrainer and the descriptor must not disagree
The limits the drag enforces and the limits the host was told have to be the same numbers, or the user drags to a size the host then refuses and the window snaps back under their hand. constrainerFor() builds one from the other so there is nowhere for them to drift apart.
Types 1
class ResizableBorder : public Widget
The draggable frame around an editor.
Transparent to the mouse everywhere except its border, so it can sit OVER the interface without stealing clicks from the controls underneath. That is the whole reason it is a border rather than a component behind everything: an editor whose sliders stopped working near the edge would be a worse trade than no resizing at all.
Functions 1
- fn
inline BoundsConstrainer constrainerFor(const EditorConstraints& limits, float naturalWidth = 0.0f, float naturalHeight = 0.0f)A BoundsConstrainer carrying what the PLUGIN declared.gfx::constrainerFor · resizer.h:68More
The one place the two constraint models meet. EditorConstraints is what every host is told; BoundsConstrainer is what a drag obeys. Two hand-written copies of the same four numbers is how a user ends up dragging to a size the host refuses, and watching the window snap back.
Enums 1
- enum
enum class ResizeZoneWhich part of the border the pointer is over.gfx::ResizeZone · resizer.h:48