Moved the event listener from the 3d widget to the gui control class.

This commit is contained in:
dfighter1985 2014-06-15 19:16:52 +02:00
parent 29526906c4
commit 5d71cdd56d
4 changed files with 25 additions and 13 deletions

View file

@ -21,8 +21,7 @@
#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"
//#include "nel/misc/event_listener.h"
#ifdef NL_OS_WINDOWS
#include <Windows.h>
@ -42,7 +41,6 @@ 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()
@ -59,7 +57,6 @@ namespace GUIEditor
delete driver;
driver = NULL;
}
delete eventListener;
}
void Nel3DWidget::init()
@ -69,8 +66,6 @@ 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 )

View file

@ -22,11 +22,6 @@
#include "nel/misc/types_nl.h"
#include <string>
namespace NLGUI
{
class CEventListener;
}
namespace NL3D
{
class UDriver;
@ -71,7 +66,6 @@ namespace GUIEditor
private:
NL3D::UDriver *driver;
NL3D::UTextContext *textContext;
NLGUI::CEventListener *eventListener;
};
}

View file

@ -22,6 +22,7 @@
#include "nel/gui/widget_manager.h"
#include "nel/gui/action_handler.h"
#include "nel/gui/lua_manager.h"
#include "nel/gui/event_listener.h"
#include "nel/misc/path.h"
#include "nel/misc/i18n.h"
#include <set>
@ -42,6 +43,8 @@ namespace GUIEditor
guiLoaded = false;
watcher = NULL;
w = new Nel3DWidget();
eventListener = new NLGUI::CEventListener();
listening = false;
}
NelGUICtrl::~NelGUICtrl()
@ -157,6 +160,12 @@ namespace GUIEditor
{
if( timerID == 0 )
timerID = startTimer( 200 );
if( !listening )
{
eventListener->addToServer( &w->getDriver()->EventServer );
listening = true;
}
}
void NelGUICtrl::hide()
@ -166,6 +175,12 @@ namespace GUIEditor
killTimer( timerID );
timerID = 0;
}
if( listening )
{
eventListener->removeFromServer();
listening = false;
}
}
QWidget* NelGUICtrl::getViewPort()

View file

@ -23,6 +23,11 @@
class QWidget;
namespace NLGUI
{
class CEventListener;
}
namespace GUIEditor
{
class CEditorSelectionWatcher;
@ -58,8 +63,11 @@ Q_SIGNALS:
bool guiLoaded;
CEditorSelectionWatcher *watcher;
NLGUI::CEventListener *eventListener;
Nel3DWidget *w;
Nel3DWidget *w;
bool listening;
};
}