On this page
  1. Fields
    1. held
    2. drop

rmp::behavior::Draggable

behavior #include <rmp/behavior.h> include/rmp/behavior.h:983
struct 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

FieldTypeDefaultWhat it is
snapVector2{}

The grid it lands on; {0,0} = none

throwableboolfalse

Keeps the pointer's speed when let go

frictionfloat6

How fast a throw slows: the share of its speed lost per second

boundsRectangle{}

Where it can be dragged; {0,0,0,0} = anywhere

drop_onunsigned0xFFFFFFFFu

The layers of the Areas it can be dropped on

return_if_rejectedbooltrue

No Area took it: back where it was picked up

centre_on_dropbooltrue

Dropped on an Area: put on its centre

acceptsCondition<Object &, Object &>

(this, the area); empty = every Area does

on_pickCallback<Object &>

The first time it moves under the pointer

on_dropCallback<Object &, Object &>

(this, the area it was dropped on)

on_rejectCallback<Object &>

Let go where no Area took it

oursstruct { … }

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 { .speed = 320 } stops compiling — which is the whole design. The name is the fence.

held

bool held() const

Whether the pointer holds it now.

drop

void drop(Object &self)

Lets go of it here, as the pointer letting go would: onto the Area under it, or back, or where it is.