Delay before resetting the demo when resizing

Maybe it will prevent the laptop from crashing.
This commit is contained in:
Emmanuel BENOîT 2017-10-05 08:45:40 +02:00
parent 93308ac578
commit 2bbf14d827

15
main.cc
View file

@ -13,6 +13,8 @@
struct T_Main
{
static constexpr uint32_t ResizeDelay = 50;
T_Main( );
~T_Main( );
@ -24,6 +26,9 @@ struct T_Main
ImVec2 mouseInitial;
ImVec2 mouseMove;
uint32_t stopResize = 0;
ImVec2 prevSize;
std::unique_ptr< T_Demo > demo;
void initDemo( );
@ -39,6 +44,7 @@ struct T_Main
T_Main::T_Main( )
{
Globals::Init( );
prevSize = ImVec2( 1280 , 720 );
}
void T_Main::mainLoop( )
@ -47,7 +53,14 @@ void T_Main::mainLoop( )
while ( !done ) {
if ( demo ) {
auto const& dspSize( ImGui::GetIO( ).DisplaySize );
if ( demo->width != dspSize.x || demo->height != dspSize.y ) {
if ( prevSize.x != dspSize.x || prevSize.y != dspSize.y ) {
stopResize = ResizeDelay;
prevSize = dspSize;
}
}
if ( stopResize > 0 ) {
stopResize --;
if ( stopResize == 0 ) {
demo.reset( );
}
}