From 5fcf57739e68a8b5053e03778aaee0eed445babd Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Thu, 11 Mar 2021 22:00:22 -0500 Subject: settings editor, and lots of changes in service of that --- src/user/raleigh/d/saving_window.cpp | 55 ++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/user/raleigh/d/saving_window.cpp (limited to 'src/user/raleigh/d/saving_window.cpp') diff --git a/src/user/raleigh/d/saving_window.cpp b/src/user/raleigh/d/saving_window.cpp new file mode 100644 index 0000000..a2d57e4 --- /dev/null +++ b/src/user/raleigh/d/saving_window.cpp @@ -0,0 +1,55 @@ +#include +#include + +#include +#include +#include +#include +#include + +#include + +namespace raleigh { + bool on_saving_window_close(window_tag_t tag) { + saving_window *const sw = (saving_window *)tag; + if (sw->is_saved) + return true; + + label text("There is unsaved content in this window."); + label text2("Would you like to save before closing it?"); + + dllist rows; + rows.add_back(text); + rows.add_back(text2); + vbox vb(rows); + padding vbp(vb, 2); + + dialog diag(vbp, yes_no_cancel); + diag.show_modal(); + + switch (diag.result) { + case YES: + save: + if (!sw->save_func(sw->save_tag)) { + label text3("Failing saved. Still quit?"); + dialog diag2(text3, yes_no_retry); + diag2.show_modal(); + switch (diag2.result) { + case YES: + return true; + case RETRY: + goto save; + default: + return false; + } + } + case NO: + return true; + default: + return false; + } + } + + saving_window::saving_window(bool (*save_func)(save_tag_t), save_tag_t save_tag, widget &root, _pixel_t bg_color) + : window(root, bg_color, &on_saving_window_close, (window_tag_t)this), is_saved(true), save_func(save_func), save_tag(save_tag) {} +} \ No newline at end of file -- cgit v1.2.3