mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-19 05:36:13 +00:00
We can now drag elements, they will disappear and whatnot, but at least they can be dragged!
This commit is contained in:
parent
d365189cd7
commit
f9d92d6d6b
5 changed files with 96 additions and 4 deletions
|
@ -233,6 +233,9 @@ namespace NLGUI
|
|||
|
||||
virtual void setActive (bool state);
|
||||
|
||||
void setXReal( sint32 x ){ _XReal = x; }
|
||||
void setYReal( sint32 y ){ _YReal = y; }
|
||||
|
||||
void setX (sint32 x) { _X = x; }
|
||||
void setXAndInvalidateCoords (sint32 x) { _X = x; invalidateCoords(); }
|
||||
|
||||
|
|
|
@ -79,6 +79,9 @@ namespace NLGUI
|
|||
bool delElement (const std::string &id, bool noWarning=false);
|
||||
bool delElement (CInterfaceElement *pIE, bool noWarning=false);
|
||||
|
||||
// Take the element from the group, but don't delete it!
|
||||
CInterfaceElement* takeElement( CInterfaceElement *e );
|
||||
|
||||
uint getNumGroup() const { return (uint)_ChildrenGroups.size(); }
|
||||
CInterfaceGroup *getGroup(uint index) const;
|
||||
|
||||
|
|
|
@ -532,6 +532,11 @@ namespace NLGUI
|
|||
|
||||
NLMISC::CRefPtr< CViewBase > _CapturedView;
|
||||
|
||||
NLMISC::CRefPtr< CInterfaceElement > draggedElement;
|
||||
|
||||
bool startDragging();
|
||||
void stopDragging();
|
||||
|
||||
// What is under pointer
|
||||
std::vector< CViewBase* > _ViewsUnderPointer;
|
||||
std::vector< CCtrlBase* > _CtrlsUnderPointer;
|
||||
|
|
|
@ -1638,6 +1638,32 @@ namespace NLGUI
|
|||
return delView(static_cast<CViewBase*>(pIE));
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
CInterfaceElement* CInterfaceGroup::takeElement( CInterfaceElement *e )
|
||||
{
|
||||
bool ok = false;
|
||||
|
||||
if( e->isGroup() )
|
||||
{
|
||||
ok = delGroup( static_cast< CInterfaceGroup* >( e ), true );
|
||||
}
|
||||
else
|
||||
if( e->isCtrl() )
|
||||
{
|
||||
ok = delCtrl( static_cast< CCtrlBase* >( e ), true );
|
||||
}
|
||||
else
|
||||
if( e->isView() )
|
||||
{
|
||||
ok = delView( static_cast< CViewBase* >( e ), true );
|
||||
}
|
||||
|
||||
if( ok )
|
||||
return e;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CInterfaceGroup::isWindowUnder (sint32 x, sint32 y)
|
||||
{
|
||||
|
|
|
@ -2039,6 +2039,12 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
|
||||
if( draggedElement != NULL )
|
||||
{
|
||||
CInterfaceElement *e = draggedElement;
|
||||
static_cast< CViewBase* >( e )->draw();
|
||||
}
|
||||
|
||||
if ( (nPriority == WIN_PRIORITY_WORLD_SPACE) && !camera.empty())
|
||||
{
|
||||
driver->setMatrixMode2D11();
|
||||
|
@ -2437,11 +2443,11 @@ namespace NLGUI
|
|||
// consider clicking on a control implies handling of the event.
|
||||
handled= true;
|
||||
|
||||
// handle the capture
|
||||
if( getCapturePointerLeft() != NULL )
|
||||
getCapturePointerLeft()->handleEvent(evnt);
|
||||
else
|
||||
_CapturedView->handleEvent( evnt );
|
||||
_CapturedView = getCapturePointerLeft();
|
||||
|
||||
// handle the capture
|
||||
_CapturedView->handleEvent( evnt );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2534,6 +2540,11 @@ namespace NLGUI
|
|||
setCapturePointerLeft(NULL);
|
||||
handled = true;
|
||||
}
|
||||
|
||||
_CapturedView = NULL;
|
||||
|
||||
if( CInterfaceElement::getEditorMode() )
|
||||
stopDragging();
|
||||
}
|
||||
|
||||
|
||||
|
@ -2602,9 +2613,53 @@ namespace NLGUI
|
|||
ve.setY( getPointer()->getY() );
|
||||
}
|
||||
|
||||
if( CInterfaceElement::getEditorMode() )
|
||||
{
|
||||
if( ( _CapturedView != NULL ) && ( draggedElement == NULL ) )
|
||||
{
|
||||
startDragging();
|
||||
}
|
||||
else
|
||||
if( draggedElement != NULL )
|
||||
{
|
||||
draggedElement->setXReal( newX );
|
||||
draggedElement->setYReal( newY );
|
||||
draggedElement->invalidateCoords();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
bool CWidgetManager::startDragging()
|
||||
{
|
||||
CInterfaceElement *e = NULL;
|
||||
|
||||
CInterfaceGroup *g = _CapturedView->getParent();
|
||||
if( g != NULL )
|
||||
{
|
||||
e = g->takeElement( _CapturedView );
|
||||
if( e == NULL )
|
||||
{
|
||||
nlinfo( "Something went horribly wrong :(" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
e = _CapturedView;
|
||||
|
||||
e->setParent( NULL );
|
||||
draggedElement = e;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CWidgetManager::stopDragging()
|
||||
{
|
||||
draggedElement = NULL;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
void CWidgetManager::movePointer (sint32 dx, sint32 dy)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue