rmp::behavior::Draggable
Picked up with the pointer and put down somewhere. It takes the object's on_drag. Let go over an object with an Area — on a layer of drop_on, and accepts saying yes — it is dropped there: on_drop, and centred on it with centre_on_drop. Let go anywhere else it goes back where it was picked up, with return_if_rejected, or stays, snapped to snap, and with throwable keeps the pointer's speed and slides to a stop.
Added to an object with add<rmp::behavior::Draggable>(); the framework calls its _ready, _update with the object it is on.
Fields
| Field | Type | Default | What it is |
|---|---|---|---|
snap | Vector2 | {} | The grid it lands on; {0,0} = none |
throwable | bool | false | Keeps the pointer's speed when let go |
friction | float | 6 | How fast a throw slows: the share of its speed lost per second |
bounds | Rectangle | {} | Where it can be dragged; {0,0,0,0} = anywhere |
drop_on | unsigned | 0xFFFFFFFFu | The layers of the Areas it can be dropped on |
return_if_rejected | bool | true | No Area took it: back where it was picked up |
centre_on_drop | bool | true | Dropped on an Area: put on its centre |
accepts | Condition<Object &, Object &> | (this, the area); empty = every Area does | |
on_pick | Callback<Object &> | The first time it moves under the pointer | |
on_drop | Callback<Object &, Object &> | (this, the area it was dropped on) | |
on_reject | Callback<Object &> | Let go where no Area took it | |
ours | struct { … } | What it is keeping track of. Readable, because sometimes you want it; not yours to write. It is one PUBLIC member and not a private block because a struct with a private member is not an aggregate in C++20, and then |
held
Whether the pointer holds it now.
drop
Lets go of it here, as the pointer letting go would: onto the Area under it, or back, or where it is.