Save on exit; test before closing

Detect window close or quit events to make sure a filename is given if save-on-exit is active.
This commit is contained in:
Bruno Herbelin
2022-01-05 15:08:52 +01:00
parent d402143989
commit 5fb70a9b9a
3 changed files with 84 additions and 28 deletions

View File

@@ -174,6 +174,17 @@ static void WindowToggleFullscreen( GLFWwindow *w, int button, int action, int)
}
}
static void WindowCloseCallback( GLFWwindow* w )
{
if (!UserInterface::manager().TryClose())
glfwSetWindowShouldClose(w, GLFW_FALSE);
}
void Rendering::close()
{
glfwSetWindowShouldClose(main_.window(), GLFW_TRUE);
}
Rendering::Rendering()
{
// main_window_ = nullptr;
@@ -206,6 +217,7 @@ bool Rendering::init()
// set application icon
main_.setIcon("images/vimix_256x256.png");
// additional window callbacks for main window
glfwSetWindowCloseCallback( main_.window(), WindowCloseCallback );
glfwSetWindowRefreshCallback( main_.window(), WindowRefreshCallback );
glfwSetDropCallback( main_.window(), Rendering::FileDropped);
@@ -357,7 +369,6 @@ void Rendering::draw()
}
void Rendering::terminate()
{
// close window
@@ -366,13 +377,6 @@ void Rendering::terminate()
// glfwTerminate();
}
void Rendering::close()
{
glfwSetWindowShouldClose(main_.window(), true);
}
void Rendering::pushAttrib(RenderingAttrib ra)
{
// push it to top of pile