mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-24 16:16:14 +00:00
MODIFIED: Views can now be selected too from the central widget.
This commit is contained in:
parent
93de10c56d
commit
dcad62844b
10 changed files with 72 additions and 11 deletions
|
@ -68,9 +68,7 @@ namespace NLGUI
|
|||
// special parse
|
||||
virtual bool parse(xmlNodePtr cur, CInterfaceGroup *parentGroup);
|
||||
|
||||
|
||||
/// Handle all events (implemented by derived classes) (return true to signal event handled)
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
bool handleEvent (const NLGUI::CEventDescriptor &event);
|
||||
|
||||
virtual CCtrlBase *getSubCtrl (sint32 /* x */, sint32 /* y */) { return this; }
|
||||
|
||||
|
|
|
@ -473,6 +473,7 @@ namespace NLGUI
|
|||
bool isInGroup( CInterfaceGroup *group );
|
||||
|
||||
static void setEditorMode( bool b ){ editorMode = b; }
|
||||
static bool getEditorMode(){ return editorMode; }
|
||||
|
||||
void setEditorSelected( bool b ){ editorSelected = b; }
|
||||
bool isEditorSelected() const{ return editorSelected; }
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
namespace NLGUI
|
||||
{
|
||||
class CEventDescriptor;
|
||||
|
||||
class CViewBase : public CInterfaceElement
|
||||
{
|
||||
|
@ -77,6 +78,9 @@ namespace NLGUI
|
|||
// special for mouse over : return true and fill the name of the cursor to display
|
||||
virtual bool getMouseOverShape(std::string &/* texName */, uint8 &/* rot */, NLMISC::CRGBA &/* col */) { return false; }
|
||||
|
||||
/// Handle all events (implemented by derived classes) (return true to signal event handled)
|
||||
virtual bool handleEvent (const NLGUI::CEventDescriptor &evnt);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -188,6 +188,8 @@ namespace NLGUI
|
|||
|
||||
int luaSetLineMaxW(CLuaState &ls);
|
||||
|
||||
bool handleEvent( const NLGUI::CEventDescriptor &evnt );
|
||||
|
||||
REFLECT_EXPORT_START(CViewText, CViewBase)
|
||||
REFLECT_STRING("hardtext", getHardText, setHardText);
|
||||
REFLECT_UCSTRING("uc_hardtext", getText, setText);
|
||||
|
|
|
@ -341,6 +341,7 @@ namespace NLGUI
|
|||
/**
|
||||
* Capture
|
||||
*/
|
||||
CViewBase *getCapturedView(){ return _CapturedView; }
|
||||
CCtrlBase *getCapturePointerLeft() { return _CapturePointerLeft; }
|
||||
CCtrlBase *getCapturePointerRight() { return _CapturePointerRight; }
|
||||
CCtrlBase *getCaptureKeyboard() { return _CaptureKeyboard; }
|
||||
|
@ -510,6 +511,8 @@ namespace NLGUI
|
|||
NLMISC::CRefPtr<CCtrlBase> _CapturePointerLeft;
|
||||
NLMISC::CRefPtr<CCtrlBase> _CapturePointerRight;
|
||||
|
||||
NLMISC::CRefPtr< CViewBase > _CapturedView;
|
||||
|
||||
// What is under pointer
|
||||
std::vector< CViewBase* > _ViewsUnderPointer;
|
||||
std::vector< CCtrlBase* > _CtrlsUnderPointer;
|
||||
|
|
|
@ -37,6 +37,9 @@ namespace NLGUI
|
|||
// ***************************************************************************
|
||||
bool CCtrlBase::handleEvent(const NLGUI::CEventDescriptor &event)
|
||||
{
|
||||
if( CViewBase::handleEvent( event ) )
|
||||
return true;
|
||||
|
||||
if (event.getType() == NLGUI::CEventDescriptor::system)
|
||||
{
|
||||
NLGUI::CEventDescriptorSystem &eds = (NLGUI::CEventDescriptorSystem&)event;
|
||||
|
|
|
@ -668,12 +668,6 @@ namespace NLGUI
|
|||
if (CWidgetManager::getInstance()->getCapturePointerLeft() != this)
|
||||
return false;
|
||||
|
||||
if( editorMode )
|
||||
{
|
||||
CWidgetManager::getInstance()->setCurrentEditorSelection( getId() );
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_LeftDblClickHandled) // no effect on mouse up after double click has been handled
|
||||
{
|
||||
_LeftDblClickHandled = false;
|
||||
|
|
|
@ -45,5 +45,23 @@ namespace NLGUI
|
|||
CInterfaceElement::visit(visitor);
|
||||
}
|
||||
|
||||
|
||||
bool CViewBase::handleEvent( const NLGUI::CEventDescriptor &evnt )
|
||||
{
|
||||
if( evnt.getType() == NLGUI::CEventDescriptor::mouse )
|
||||
{
|
||||
const NLGUI::CEventDescriptorMouse &eventDesc = ( const NLGUI::CEventDescriptorMouse& )evnt;
|
||||
if( eventDesc.getEventTypeExtended() == NLGUI::CEventDescriptorMouse::mouseleftdown )
|
||||
{
|
||||
if( editorMode )
|
||||
{
|
||||
CWidgetManager::getInstance()->setCurrentEditorSelection( getId() );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2945,6 +2945,11 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
|
||||
bool CViewText::handleEvent( const NLGUI::CEventDescriptor &evnt )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// ***************************************************************************
|
||||
void CViewText::serial(NLMISC::IStream &f)
|
||||
{
|
||||
|
|
|
@ -1031,6 +1031,7 @@ namespace NLGUI
|
|||
_OldCaptureKeyboard = NULL;
|
||||
setCapturePointerLeft(NULL);
|
||||
setCapturePointerRight(NULL);
|
||||
_CapturedView = NULL;
|
||||
|
||||
resetColorProps();
|
||||
|
||||
|
@ -2086,6 +2087,12 @@ namespace NLGUI
|
|||
getCapturePointerRight()->handleEvent( evnt );
|
||||
setCapturePointerRight( NULL );
|
||||
}
|
||||
|
||||
if( _CapturedView != NULL )
|
||||
{
|
||||
_CapturedView->handleEvent( evnt );
|
||||
_CapturedView = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2249,6 +2256,9 @@ namespace NLGUI
|
|||
getCapturePointerLeft() != getCapturePointerRight() )
|
||||
handled|= getCapturePointerRight()->handleEvent(evnt);
|
||||
|
||||
if( _CapturedView != NULL )
|
||||
_CapturedView->handleEvent( evnt );
|
||||
|
||||
CInterfaceGroup *ptr = getWindowUnder (eventDesc.getX(), eventDesc.getY());
|
||||
setCurrentWindowUnder( ptr );
|
||||
|
||||
|
@ -2326,6 +2336,8 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
|
||||
bool captured = false;
|
||||
|
||||
// must not capture a new element if a sheet is currentlty being dragged.
|
||||
// This may happen when alt-tab has been used => the sheet is dragged but the left button is up
|
||||
if (!CCtrlDraggable::getDraggedSheet())
|
||||
|
@ -2343,9 +2355,25 @@ namespace NLGUI
|
|||
{
|
||||
nMaxDepth = d;
|
||||
setCapturePointerLeft( ctrl );
|
||||
captured = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( CInterfaceElement::getEditorMode() && !captured )
|
||||
{
|
||||
for( sint32 i = _ViewsUnderPointer.size()-1; i >= 0; i-- )
|
||||
{
|
||||
CViewBase *v = _ViewsUnderPointer[i];
|
||||
if( ( v != NULL ) && v->isInGroup( pNewCurrentWnd ) )
|
||||
{
|
||||
_CapturedView = v;
|
||||
captured = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
notifyElementCaptured( getCapturePointerLeft() );
|
||||
if (clickedOutModalWindow && !clickedOutModalWindow->OnPostClickOut.empty())
|
||||
{
|
||||
|
@ -2353,13 +2381,16 @@ namespace NLGUI
|
|||
}
|
||||
}
|
||||
//if found
|
||||
if ( getCapturePointerLeft() != NULL)
|
||||
if ( captured )
|
||||
{
|
||||
// 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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2588,6 +2619,8 @@ namespace NLGUI
|
|||
// ***************************************************************************
|
||||
void CWidgetManager::setCapturePointerLeft(CCtrlBase *c)
|
||||
{
|
||||
_CapturedView = NULL;
|
||||
|
||||
// additionally, abort any dragging
|
||||
if( CCtrlDraggable::getDraggedSheet() != NULL )
|
||||
CCtrlDraggable::getDraggedSheet()->abortDragging();
|
||||
|
|
Loading…
Reference in a new issue