41 lines
642 B
C++
41 lines
642 B
C++
#include "dl_component_use.h"
|
|
#include "io/dl_input.h"
|
|
|
|
namespace dl
|
|
{
|
|
namespace Cpt
|
|
{
|
|
void Drag::Update(Coor* coor, bool is_pickup)
|
|
{
|
|
_posMove = {};
|
|
if (_state == 0)
|
|
{
|
|
if (g_input->KeyDown(_key))
|
|
{
|
|
if (is_pickup)
|
|
{
|
|
_state = 1;
|
|
_xyClick = g_input->GetCursorPosition();
|
|
_posOld = coor->GetPosition();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (g_input->KeyUp(_key))
|
|
{
|
|
_state = 0;
|
|
}
|
|
else
|
|
{
|
|
Point dt = g_input->GetCursorPosition() - _xyClick;
|
|
_posMove = coor->WorldToThis(toPosition(dt));
|
|
_posMove = coor->ThisToParent(_posMove);
|
|
coor->SetPosition(_posOld + _posMove);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|