Skip to content

Instantly share code, notes, and snippets.

@paniq
Created June 10, 2016 07:29
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save paniq/4bf7848fc33ccf24ec1c39a114897da1 to your computer and use it in GitHub Desktop.
struct DropInfo
typeid : uint
source : ImGuiID
struct DragState
item : DropInfo
active : DropInfo
last_source : DropInfo
last_target : DropInfo
target : DropInfo
const dragstate : DragState
static BeginDragSource(name typeid) :
bool <- (rawstring uint)
.= dragstate.last_source
source
GetID name
typeid typeid
do-if
and (dragstate.active.source == dragstate.last_source.source)
IsMouseDragging 0
dragstate.item = dragstate.active
BeginGroup ;
dragstate.item.source == dragstate.last_source.source
static EndDragSource () :
void <- ()
EndGroup ;
do-if
and
IsMouseClicked 0
IsItemHoveredRect ;
dragstate.active = dragstate.last_source
static BeginDropTarget (*)
static (name typeid typemask) :
bool <- (rawstring uint uint)
.= dragstate.last_target
source
GetID name
typeid
if ((dragstate.item.typeid & typemask) == typeid)
dragstate.item.typeid
0
BeginGroup ;
dragstate.target.source == dragstate.last_target.source
static (name typeid) :
bool <- (rawstring uint)
BeginDropTarget name typeid 0xffffffff
static EndDropTarget () :
void <- ()
EndGroup ;
do-if
and
dragstate.item.typeid != 0
dragstate.item.typeid == dragstate.last_target.typeid
cond
(IsItemHoveredRect)
dragstate.target = dragstate.last_target
(dragstate.target.source == dragstate.last_target.source)
.= dragstate.target
source 0
typeid 0
tuple ;
static GetDropType () :
uint <- ()
dragstate.item.typeid
static BeginDropHandle () :
bool <- ()
cond
(IsMouseReleased 0)
.= dragstate.item
source 0
typeid 0
.= dragstate.active
source 0
typeid 0
.= dragstate.target
source 0
typeid 0
false
(dragstate.item.typeid == 0)
false
else
BeginTooltip ;
true
static EndDropHandle () :
void <- ()
EndTooltip ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment