Utility/Window: Window now automatically close on quit event
Former-commit-id: da6eb0214de58af84c0cbedffc0916a1a5b335e8 [formerly ca81aa0c8f8da61e841a1ccb85295f99efe7e317] [formerly 30f112245ee8eee0ed5f4db88cc4a7c13b9d9a9c [formerly f404a5b5bef35d9c80232371a40bd04c5acc8cfc]] Former-commit-id: c1443eed4321f48aa42e93d2679f0eddaacbbb5d [formerly 386ba36f29ace0e098fd95e4f05fec6498b4183a] Former-commit-id: 1fb357a16a42eee7d0658d09716ef7cdcca584ab
This commit is contained in:
parent
9fa65db6b9
commit
414bc1f5b4
|
|
@ -52,6 +52,7 @@ namespace Nz
|
||||||
|
|
||||||
void Destroy();
|
void Destroy();
|
||||||
|
|
||||||
|
inline void EnableCloseOnQuit(bool closeOnQuit);
|
||||||
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable);
|
NAZARA_DEPRECATED("Event pooling/waiting is deprecated, please use the EventHandler system") inline void EnableEventPolling(bool enable);
|
||||||
void EnableKeyRepeat(bool enable);
|
void EnableKeyRepeat(bool enable);
|
||||||
void EnableSmoothScrolling(bool enable);
|
void EnableSmoothScrolling(bool enable);
|
||||||
|
|
@ -122,6 +123,7 @@ namespace Nz
|
||||||
#endif
|
#endif
|
||||||
EventHandler m_eventHandler;
|
EventHandler m_eventHandler;
|
||||||
bool m_closed;
|
bool m_closed;
|
||||||
|
bool m_closeOnQuit;
|
||||||
bool m_eventPolling;
|
bool m_eventPolling;
|
||||||
bool m_ownsWindow;
|
bool m_ownsWindow;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ namespace Nz
|
||||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||||
m_waitForEvent(false),
|
m_waitForEvent(false),
|
||||||
#endif
|
#endif
|
||||||
|
m_closeOnQuit(true),
|
||||||
m_eventPolling(false)
|
m_eventPolling(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
@ -44,10 +45,11 @@ namespace Nz
|
||||||
m_eventCondition(std::move(window.m_eventCondition)),
|
m_eventCondition(std::move(window.m_eventCondition)),
|
||||||
m_eventMutex(std::move(window.m_eventMutex)),
|
m_eventMutex(std::move(window.m_eventMutex)),
|
||||||
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
|
m_eventConditionMutex(std::move(window.m_eventConditionMutex)),
|
||||||
m_eventPolling(window.m_eventPolling),
|
|
||||||
m_waitForEvent(window.m_waitForEvent),
|
m_waitForEvent(window.m_waitForEvent),
|
||||||
#endif
|
#endif
|
||||||
m_closed(window.m_closed),
|
m_closed(window.m_closed),
|
||||||
|
m_closeOnQuit(window.m_closeOnQuit),
|
||||||
|
m_eventPolling(window.m_eventPolling),
|
||||||
m_ownsWindow(window.m_ownsWindow)
|
m_ownsWindow(window.m_ownsWindow)
|
||||||
{
|
{
|
||||||
window.m_impl = nullptr;
|
window.m_impl = nullptr;
|
||||||
|
|
@ -63,6 +65,11 @@ namespace Nz
|
||||||
m_closed = true; // The window will be closed at the next non-const IsOpen() call
|
m_closed = true; // The window will be closed at the next non-const IsOpen() call
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void Window::EnableCloseOnQuit(bool closeOnQuit)
|
||||||
|
{
|
||||||
|
m_closeOnQuit = closeOnQuit;
|
||||||
|
}
|
||||||
|
|
||||||
inline void Window::EnableEventPolling(bool enable)
|
inline void Window::EnableEventPolling(bool enable)
|
||||||
{
|
{
|
||||||
m_eventPolling = enable;
|
m_eventPolling = enable;
|
||||||
|
|
@ -116,6 +123,9 @@ namespace Nz
|
||||||
if (event.type == WindowEventType_Resized)
|
if (event.type == WindowEventType_Resized)
|
||||||
OnWindowResized();
|
OnWindowResized();
|
||||||
|
|
||||||
|
if (event.type == WindowEventType_Quit && m_closeOnQuit)
|
||||||
|
Close();
|
||||||
|
|
||||||
#if NAZARA_UTILITY_THREADED_WINDOW
|
#if NAZARA_UTILITY_THREADED_WINDOW
|
||||||
m_eventMutex.Unlock();
|
m_eventMutex.Unlock();
|
||||||
|
|
||||||
|
|
@ -137,6 +147,7 @@ namespace Nz
|
||||||
Destroy();
|
Destroy();
|
||||||
|
|
||||||
m_closed = window.m_closed;
|
m_closed = window.m_closed;
|
||||||
|
m_closeOnQuit = window.m_closeOnQuit;
|
||||||
m_eventPolling = window.m_eventPolling;
|
m_eventPolling = window.m_eventPolling;
|
||||||
m_impl = window.m_impl;
|
m_impl = window.m_impl;
|
||||||
m_events = std::move(window.m_events);
|
m_events = std::move(window.m_events);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue