gfx/selection.h
Choosing several things, and moving them.
#include <sonore/gfx/selection.h>- 3types
- Guides: The native editor
On this page
Design notes
What it is for
A step sequencer where you drag a box round eight steps. A modular patch where nodes move. An envelope with points you can grab. The moment an editor has more than one of something, "which ones" and "move them" stop being obvious and start being the two things everybody implements slightly differently.
The click rules
These are not arbitrary and they are not ours: a plain click selects only the thing clicked, Ctrl toggles it, and a drag on empty space starts a lasso. Every user already knows them from every other application, and a plugin that invented its own would be one people have to learn.
The one worth stating: a plain click on something ALREADY selected must not collapse the selection to it, or dragging a group of four becomes impossible -- the press deselects the other three before the drag begins. So the collapse happens on RELEASE, and only if nothing was dragged.
Types 3
template <typename ItemType> class SelectedItemSet
The set of things currently chosen.
A vector rather than a set: a selection is a handful of items, ORDER matters for "the first one" and "the last one", and a caller iterating it wants the order they clicked in rather than whatever a hash produced.
class LassoComponent : public Widget
The rubber band.
Owns only the rectangle and its drawing. WHAT it covers is the owner's business -- this has no idea what the items are, where they are, or how to compare them, and a version that did would need a model interface for every kind of thing anybody ever lassoes.
Moving a component with the mouse.
Works in ROOT coordinates, which is the whole trick. A dragger that used the event's local position would move the component, which moves the coordinate system the next event is reported in, which moves the component again -- the classic runaway where a dragged thing accelerates away from the pointer.