Utility/Window: Add new event system, based on signals
Old pooling-based system remains for now but is now deprecated Former-commit-id: 803c6f51e8287613610ede8433bef8112bc70352 [formerly 9f60f0fabea7fa0d0d62feba217e28c421522e36] [formerly f05d3dededee17402669ec9e4060c95d77c74bb4 [formerly 5b96073b92c3a10a5c485abcc7c33ecedb819fca]] Former-commit-id: 4280c668fb5ec67c0b765a80516b9b4fe466135d [formerly c8ce15aa230bf2f1040b00153ec81aa1f39ef48d] Former-commit-id: 71893d639b5e1628776d8a4577b0309437865c16
This commit is contained in:
@@ -11,39 +11,24 @@ namespace Nz
|
||||
/*!
|
||||
* \class Nz::Window
|
||||
*/
|
||||
|
||||
inline Window::Window() :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_waitForEvent(false),
|
||||
#endif
|
||||
m_eventPolling(false)
|
||||
{
|
||||
}
|
||||
|
||||
inline Window::Window(VideoMode mode, const String& title, UInt32 style) :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(mode, title, style);
|
||||
}
|
||||
|
||||
inline Window::Window(WindowHandle handle) :
|
||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||
m_impl(nullptr),
|
||||
m_eventListener(true),
|
||||
m_waitForEvent(false)
|
||||
#else
|
||||
m_impl(nullptr)
|
||||
#endif
|
||||
Window()
|
||||
{
|
||||
ErrorFlags flags(ErrorFlag_ThrowException, true);
|
||||
Create(handle);
|
||||
@@ -59,7 +44,7 @@ namespace Nz
|
||||
m_eventCondition(std::move(window.m_eventCondition)),
|
||||
m_eventMutex(std::move(window.m_eventMutex)),
|
||||
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
|
||||
m_eventListener(window.m_eventListener),
|
||||
m_eventPolling(window.m_eventPolling),
|
||||
m_waitForEvent(window.m_waitForEvent),
|
||||
#endif
|
||||
m_closed(window.m_closed),
|
||||
@@ -78,6 +63,21 @@ namespace Nz
|
||||
m_closed = true; // The window will be closed at the next non-const IsOpen() call
|
||||
}
|
||||
|
||||
inline void Window::EnableEventPolling(bool enable)
|
||||
{
|
||||
m_eventPolling = enable;
|
||||
if (!m_eventPolling)
|
||||
{
|
||||
while (!m_events.empty())
|
||||
m_events.pop();
|
||||
}
|
||||
}
|
||||
|
||||
inline EventHandler& Nz::Window::GetEventHandler()
|
||||
{
|
||||
return m_eventHandler;
|
||||
}
|
||||
|
||||
inline bool Window::IsOpen(bool checkClosed)
|
||||
{
|
||||
if (!m_impl)
|
||||
@@ -108,7 +108,11 @@ namespace Nz
|
||||
m_eventMutex.Lock();
|
||||
#endif
|
||||
|
||||
m_events.push(event);
|
||||
if (m_eventPolling)
|
||||
m_events.push(event);
|
||||
|
||||
m_eventHandler.Dispatch(event);
|
||||
|
||||
if (event.type == WindowEventType_Resized)
|
||||
OnWindowResized();
|
||||
|
||||
@@ -132,10 +136,11 @@ namespace Nz
|
||||
{
|
||||
Destroy();
|
||||
|
||||
m_closed = window.m_closed;
|
||||
m_impl = window.m_impl;
|
||||
m_events = std::move(window.m_events);
|
||||
m_ownsWindow = window.m_ownsWindow;
|
||||
m_closed = window.m_closed;
|
||||
m_eventPolling = window.m_eventPolling;
|
||||
m_impl = window.m_impl;
|
||||
m_events = std::move(window.m_events);
|
||||
m_ownsWindow = window.m_ownsWindow;
|
||||
|
||||
window.m_impl = nullptr;
|
||||
|
||||
@@ -143,7 +148,6 @@ namespace Nz
|
||||
m_eventCondition = std::move(window.m_eventCondition);
|
||||
m_eventMutex = std::move(window.m_eventMutex);
|
||||
m_eventConditionMutex = std::move(window.m_eventConditionMutex);
|
||||
m_eventListener = window.m_eventListener;
|
||||
m_waitForEvent = window.m_waitForEvent;
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user