request save on exit wip

This commit is contained in:
2018-07-30 23:35:27 +02:00
parent a66af9abb8
commit 87fcea61b8
7 changed files with 42 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ void android_async_unlock(struct engine* engine);
void async_lock();
void async_swap();
void async_unlock();
void destroy_window();
#endif
using namespace ui;
@@ -29,6 +30,30 @@ void App::create()
height = 1080/2;
}
bool App::request_close()
{
static bool dialog_already_opened = false;
if (ui::Canvas::I->m_unsaved && !dialog_already_opened)
{
async_start();
auto* m = layout[main_id]->add_child<NodeMessageBox>();
m->m_title->set_text("Unsaved document");
m->m_message->set_text("Would you like to save before closing?");
m->btn_ok->m_text->set_text("Yes");
m->btn_ok->on_click = [](Node*) {
};
m->btn_cancel->m_text->set_text("No");
m->btn_cancel->on_click = [](Node*) {
destroy_window();
PostQuitMessage(0);
};
async_redraw();
async_end();
dialog_already_opened = true;
}
return false;
}
void App::clear()
{
glClearColor(.1f, .1f, .1f, 1.f);