diff --git a/code/nel/include/nel/gui/event_listener.h b/code/nel/include/nel/gui/event_listener.h
new file mode 100644
index 000000000..233746997
--- /dev/null
+++ b/code/nel/include/nel/gui/event_listener.h
@@ -0,0 +1,44 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+#ifndef EVENT_LISTENER
+#define EVENT_LISTENER
+
+#include "nel/misc/event_listener.h"
+#include "nel/gui/input_handler.h"
+
+namespace NLGUI
+{
+ class CEventListener : public NLMISC::IEventListener
+ {
+ public:
+ CEventListener();
+ ~CEventListener();
+ void addToServer( NLMISC::CEventServer *server );
+ void removeFromServer();
+ void operator()( const NLMISC::CEvent &evnt );
+
+ private:
+ NLGUI::CInputHandler inputHandler;
+ NLMISC::CEventServer *eventServer;
+ };
+
+}
+
+#endif
+
+
diff --git a/code/nel/include/nel/gui/view_pointer.h b/code/nel/include/nel/gui/view_pointer.h
index 1bcfefc08..5d82e64ca 100644
--- a/code/nel/include/nel/gui/view_pointer.h
+++ b/code/nel/include/nel/gui/view_pointer.h
@@ -66,6 +66,7 @@ namespace NLGUI
void show(bool s) {_PointerVisible = s;}
static void setHWMouse( bool hw ){ hwMouse = hw; }
+ static void forceLink();
private:
diff --git a/code/nel/include/nel/gui/widget_manager.h b/code/nel/include/nel/gui/widget_manager.h
index 5a29aa804..763691cb7 100644
--- a/code/nel/include/nel/gui/widget_manager.h
+++ b/code/nel/include/nel/gui/widget_manager.h
@@ -29,6 +29,7 @@
#include "nel/gui/event_descriptor.h"
#include "nel/3d/u_camera.h"
#include "nel/gui/parser.h"
+#include "nel/gui/input_event_listener.h"
namespace NLMISC
{
@@ -52,7 +53,7 @@ namespace NLGUI
Manages the GUI widgets, asks them to draw themselves, etc.
*/
- class CWidgetManager{
+ class CWidgetManager : public IInputEventListener{
public:
diff --git a/code/nel/src/gui/db_manager.cpp b/code/nel/src/gui/db_manager.cpp
index 293bd2aae..9e3fdd320 100644
--- a/code/nel/src/gui/db_manager.cpp
+++ b/code/nel/src/gui/db_manager.cpp
@@ -1,3 +1,20 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
#include "nel/gui/db_manager.h"
namespace NLGUI
diff --git a/code/nel/src/gui/event_listener.cpp b/code/nel/src/gui/event_listener.cpp
new file mode 100644
index 000000000..d289a562d
--- /dev/null
+++ b/code/nel/src/gui/event_listener.cpp
@@ -0,0 +1,61 @@
+// Ryzom - MMORPG Framework
+// Copyright (C) 2010 Winch Gate Property Limited
+//
+// This program is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as
+// published by the Free Software Foundation, either version 3 of the
+// License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program. If not, see .
+
+
+#include "nel/misc/event_server.h"
+#include "nel/gui/event_listener.h"
+#include "nel/gui/interface_group.h"
+#include "nel/gui/widget_manager.h"
+
+namespace NLGUI
+{
+ CEventListener::CEventListener()
+ {
+ inputHandler.setListener( CWidgetManager::getInstance() );
+ }
+
+ CEventListener::~CEventListener()
+ {
+ }
+
+ void CEventListener::addToServer( NLMISC::CEventServer *server )
+ {
+ server->addListener( NLMISC::EventMouseMoveId, this );
+ server->addListener( NLMISC::EventMouseDownId, this );
+ server->addListener( NLMISC::EventMouseUpId, this );
+ server->addListener( NLMISC::EventMouseWheelId, this );
+ server->addListener( NLMISC::EventMouseDblClkId, this );
+
+ eventServer = server;
+ }
+
+ void CEventListener::removeFromServer()
+ {
+ eventServer->removeListener( NLMISC::EventMouseMoveId, this );
+ eventServer->removeListener( NLMISC::EventMouseDownId, this );
+ eventServer->removeListener( NLMISC::EventMouseUpId, this );
+ eventServer->removeListener( NLMISC::EventMouseWheelId, this );
+ eventServer->removeListener( NLMISC::EventMouseDblClkId, this );
+
+ eventServer = NULL;
+ }
+
+ void CEventListener::operator ()(const NLMISC::CEvent &evnt)
+ {
+ inputHandler.handleEvent( evnt );
+ }
+}
+
diff --git a/code/nel/src/gui/interface_parser.cpp b/code/nel/src/gui/interface_parser.cpp
index 035987832..12b04244d 100644
--- a/code/nel/src/gui/interface_parser.cpp
+++ b/code/nel/src/gui/interface_parser.cpp
@@ -437,6 +437,15 @@ namespace NLGUI
NLMISC::CHTimer::display(&log, CHTimer::TotalTime);
*/
+ if( ok )
+ {
+ if( CWidgetManager::getInstance()->getPointer() == NULL )
+ {
+ CViewPointer *pointer = dynamic_cast< CViewPointer* >( NLMISC_GET_FACTORY(CViewBase, std::string).createObject( "generic_pointer", CViewBase::TCtorParam() ) );
+ CWidgetManager::getInstance()->setPointer( pointer );
+ }
+ }
+
return ok;
}
diff --git a/code/nel/src/gui/link_hack.cpp b/code/nel/src/gui/link_hack.cpp
index 0ff2f4dc6..31a76a1eb 100644
--- a/code/nel/src/gui/link_hack.cpp
+++ b/code/nel/src/gui/link_hack.cpp
@@ -1,6 +1,7 @@
#include "nel/gui/dbview_bar3.h"
#include "nel/gui/dbview_number.h"
#include "nel/gui/dbview_quantity.h"
+#include "nel/gui/view_pointer.h"
namespace NLGUI
{
@@ -12,6 +13,7 @@ namespace NLGUI
CDBViewBar3::forceLink();
CDBViewNumber::forceLink();
CDBViewQuantity::forceLink();
+ CViewPointer::forceLink();
ifexprufct_forcelink();
}
}
\ No newline at end of file
diff --git a/code/nel/src/gui/view_pointer.cpp b/code/nel/src/gui/view_pointer.cpp
index 9f12926a4..b8f21bf7c 100644
--- a/code/nel/src/gui/view_pointer.cpp
+++ b/code/nel/src/gui/view_pointer.cpp
@@ -60,6 +60,10 @@ namespace NLGUI
_StringCursor = NULL;
}
+ void CViewPointer::forceLink()
+ {
+ }
+
// +++ VIEW SPECIFIC +++
diff --git a/code/nel/src/gui/widget_manager.cpp b/code/nel/src/gui/widget_manager.cpp
index 8710e530a..8fd2ee3a2 100644
--- a/code/nel/src/gui/widget_manager.cpp
+++ b/code/nel/src/gui/widget_manager.cpp
@@ -2492,6 +2492,9 @@ namespace NLGUI
bool CWidgetManager::handleMouseMoveEvent( const CEventDescriptor &eventDesc )
{
+ if( getPointer() == NULL )
+ return false;
+
if( eventDesc.getType() != CEventDescriptor::mouse )
return false;
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp
index 8b39fb98b..e344b4fad 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.cpp
@@ -21,12 +21,15 @@
#include "nel/3d/driver_user.h"
#include "nel/misc/rgba.h"
#include "nel/misc/path.h"
+#include "nel/misc/event_listener.h"
+#include "nel/gui/event_listener.h"
#ifdef NL_OS_WINDOWS
#include
#endif
+
namespace GUIEditor
{
Nel3DWidget::Nel3DWidget( QWidget *parent ) :
@@ -39,6 +42,7 @@ namespace GUIEditor
// so that we can render the widget normally ourselves, without the image
// disappearing when a widget is resized or shown on top of us
setAttribute( Qt::WA_PaintOnScreen, true );
+ eventListener = NULL;
}
Nel3DWidget::~Nel3DWidget()
@@ -55,6 +59,7 @@ namespace GUIEditor
delete driver;
driver = NULL;
}
+ delete eventListener;
}
void Nel3DWidget::init()
@@ -64,6 +69,8 @@ namespace GUIEditor
driver = NL3D::UDriver::createDriver( 0, false, 0 );
driver->setMatrixMode2D11();
driver->setDisplay( winId(), NL3D::UDriver::CMode( width(), height(), 32, true ) );
+ eventListener = new NLGUI::CEventListener();
+ eventListener->addToServer( &driver->EventServer );
}
void Nel3DWidget::createTextContext( std::string fontFile )
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h
index 2b1edc7e4..c00b5b18f 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nel3d_widget.h
@@ -22,6 +22,11 @@
#include "nel/misc/types_nl.h"
#include
+namespace NLGUI
+{
+ class CEventListener;
+}
+
namespace NL3D
{
class UDriver;
@@ -66,6 +71,7 @@ namespace GUIEditor
private:
NL3D::UDriver *driver;
NL3D::UTextContext *textContext;
+ NLGUI::CEventListener *eventListener;
};
}
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp
index fe346bb82..f58426cd3 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.cpp
@@ -24,6 +24,7 @@
#include "nel/misc/i18n.h"
#include
#include
+#include
namespace GUIEditor
{
@@ -32,10 +33,16 @@ namespace GUIEditor
NelGUIWidget::NelGUIWidget( QWidget *parent ) :
Nel3DWidget( parent )
{
+ timerID = 0;
+ guiLoaded = false;
}
NelGUIWidget::~NelGUIWidget()
{
+ guiLoaded = false;
+ if( timerID != 0 )
+ killTimer( timerID );
+
NLGUI::CViewRenderer::release();
NLMISC::CI18N::setNoResolution( false );
@@ -59,6 +66,7 @@ namespace GUIEditor
bool NelGUIWidget::parse( SProjectFiles &files )
{
+ guiLoaded = false;
CWidgetManager::getInstance()->reset();
IParser *parser = CWidgetManager::getInstance()->getParser();
parser->removeAll();
@@ -89,6 +97,9 @@ namespace GUIEditor
if( e != NULL )
e->setActive( true );
+ timerID = startTimer( 200 );
+ guiLoaded = true;
+
return true;
}
@@ -102,7 +113,31 @@ namespace GUIEditor
void NelGUIWidget::paintEvent( QPaintEvent *evnt )
{
- draw();
+ //draw();
+ }
+
+ void NelGUIWidget::timerEvent( QTimerEvent *evnt )
+ {
+ if( evnt->timerId() == timerID )
+ {
+ if( guiLoaded )
+ {
+ getDriver()->EventServer.pump();
+ draw();
+ }
+ }
+ }
+
+ void NelGUIWidget::showEvent( QShowEvent *evnt )
+ {
+ if( timerID == 0 )
+ timerID = startTimer( 200 );
+ }
+
+ void NelGUIWidget::hideEvent( QHideEvent *evnt )
+ {
+ if( timerID != 0 )
+ killTimer( timerID );
}
}
diff --git a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h
index 8d2ee3ad5..18f0e8194 100644
--- a/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h
+++ b/code/nel/tools/3d/object_viewer_qt/src/plugins/gui_editor/nelgui_widget.h
@@ -37,7 +37,14 @@ namespace GUIEditor
protected:
void paintEvent( QPaintEvent *evnt );
+ void timerEvent( QTimerEvent *evnt );
+ void showEvent( QShowEvent *evnt );
+ void hideEvent( QHideEvent *evnt );
+
+ private:
+ int timerID;
+ bool guiLoaded;
};
}