mirror of
https://github.com/aharabada/glitchy-engine-beef.git
synced 2026-09-05 13:01:52 +00:00
Fire WindowResizeEvent when window minimizes
Also no longer updates layer-stack when the application is minimized
This commit is contained in:
@@ -14,6 +14,7 @@ namespace GlitchyEngine
|
|||||||
private EffectLibrary _effectLibrary ~ delete _;
|
private EffectLibrary _effectLibrary ~ delete _;
|
||||||
|
|
||||||
private bool _running = true;
|
private bool _running = true;
|
||||||
|
private bool _isMinimized = false;
|
||||||
|
|
||||||
private LayerStack _layerStack = new LayerStack() ~ delete _;
|
private LayerStack _layerStack = new LayerStack() ~ delete _;
|
||||||
|
|
||||||
@@ -26,6 +27,8 @@ namespace GlitchyEngine
|
|||||||
|
|
||||||
public EffectLibrary EffectLibrary => _effectLibrary;
|
public EffectLibrary EffectLibrary => _effectLibrary;
|
||||||
|
|
||||||
|
public bool IsMinimized => _isMinimized;
|
||||||
|
|
||||||
[Inline]
|
[Inline]
|
||||||
public static Application Get() => s_Instance;
|
public static Application Get() => s_Instance;
|
||||||
|
|
||||||
@@ -65,6 +68,8 @@ namespace GlitchyEngine
|
|||||||
EventDispatcher dispatcher = EventDispatcher(e);
|
EventDispatcher dispatcher = EventDispatcher(e);
|
||||||
dispatcher.Dispatch<WindowCloseEvent>(scope => OnWindowClose);
|
dispatcher.Dispatch<WindowCloseEvent>(scope => OnWindowClose);
|
||||||
|
|
||||||
|
dispatcher.Dispatch<WindowResizeEvent>(scope => OnWindowResize);
|
||||||
|
|
||||||
for(Layer layer in _layerStack)
|
for(Layer layer in _layerStack)
|
||||||
{
|
{
|
||||||
layer.OnEvent(e);
|
layer.OnEvent(e);
|
||||||
@@ -100,7 +105,7 @@ namespace GlitchyEngine
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(allowFrame)
|
if(allowFrame && !_isMinimized)
|
||||||
{
|
{
|
||||||
for(Layer layer in _layerStack)
|
for(Layer layer in _layerStack)
|
||||||
layer.Update(_gameTime);
|
layer.Update(_gameTime);
|
||||||
@@ -126,5 +131,18 @@ namespace GlitchyEngine
|
|||||||
_running = false;
|
_running = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool OnWindowResize(WindowResizeEvent e)
|
||||||
|
{
|
||||||
|
if(e.Width == 0 || e.Height == 0)
|
||||||
|
{
|
||||||
|
_isMinimized = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_isMinimized = false;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -263,26 +263,21 @@ namespace GlitchyEngine
|
|||||||
// Window size changed
|
// Window size changed
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
{
|
{
|
||||||
if (wParam == (.)ResizingType.Minimized)
|
window._isMinimized = wParam == (.)ResizingType.Minimized;
|
||||||
{
|
|
||||||
window._isMinimized = true;
|
|
||||||
}
|
|
||||||
else if (window._isMinimized)
|
|
||||||
{
|
|
||||||
window._isMinimized = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SplitHighAndLowOrder!(lParam, out window._clientRect.Width, out window._clientRect.Height);
|
|
||||||
|
|
||||||
|
|
||||||
|
SplitHighAndLowOrder!(lParam, out window._clientRect.Width, out window._clientRect.Height);
|
||||||
|
|
||||||
|
if(window._clientRect.Width != 0 && window._clientRect.Height != 0)
|
||||||
|
{
|
||||||
window._graphicsContext.SwapChain.Width = (.)window._clientRect.Width;
|
window._graphicsContext.SwapChain.Width = (.)window._clientRect.Width;
|
||||||
window._graphicsContext.SwapChain.Height = (.)window._clientRect.Height;
|
window._graphicsContext.SwapChain.Height = (.)window._clientRect.Height;
|
||||||
|
|
||||||
window._graphicsContext.SwapChain.ApplyChanges();
|
window._graphicsContext.SwapChain.ApplyChanges();
|
||||||
|
|
||||||
WindowResizeEvent event = scope WindowResizeEvent(window._clientRect.Width, window._clientRect.Height, window._isResizingOrMoving);
|
|
||||||
window._eventCallback(event);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WindowResizeEvent event = scope WindowResizeEvent(window._clientRect.Width, window._clientRect.Height, window._isResizingOrMoving);
|
||||||
|
window._eventCallback(event);
|
||||||
}
|
}
|
||||||
// Window position changed
|
// Window position changed
|
||||||
case WM_MOVE:
|
case WM_MOVE:
|
||||||
|
|||||||
Reference in New Issue
Block a user