diff options
Diffstat (limited to 'fluid/proj/undo.h')
| -rw-r--r-- | fluid/proj/undo.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/fluid/proj/undo.h b/fluid/proj/undo.h new file mode 100644 index 000000000..f87c747bd --- /dev/null +++ b/fluid/proj/undo.h @@ -0,0 +1,93 @@ +// +// Fluid Undo header for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2025 by Bill Spitzak and others. +// +// This library is free software. Distribution and use rights are outlined in +// the file "COPYING" which should have been included with this file. If this +// file is missing or damaged, see the license at: +// +// https://www.fltk.org/COPYING.php +// +// Please see the following page on how to report bugs and issues: +// +// https://www.fltk.org/bugs.php +// + +#ifndef undo_h +#define undo_h + +#include <FL/filename.H> + +class Fl_Widget; + +namespace fld { + +class Project; + +namespace proj { + +class Undo +{ +public: + + enum class OnceType { + ALWAYS = 0, + WINDOW_RESIZE + }; + + /// Link Undo class to this project. + Project &proj_; + /// Current undo level in buffer + int current_ = 0; + /// Last undo level in buffer + int last_ = 0; + // Maximum undo level used + int max_ = 0; + /// Last undo level that was saved + int save_ = -1; + // Undo checkpointing paused? + int paused_ = 0; + // Undo file path + char path_[FL_PATH_MAX] { }; + // length w/o filename + unsigned int path_len_ = 0; + /// Suspend further undos of the same type + OnceType once_type_ = OnceType::ALWAYS; + +public: + + // Constructor. + Undo(Project &p); + // Destructor. + ~Undo(); + + // Save current file to undo buffer + void checkpoint(); + // Save undo buffer once until a different checkpoint type is called + int checkpoint(OnceType type); + // Clear undo buffer + void clear(); + // Resume undo checkpoints + void resume(); + // Suspend undo checkpoints + void suspend(); + // Return the undo filename. + char *filename(int level); + + // Redo menu callback + void redo(); + // Undo menu callback + void undo(); + + // Redo menu callback + static void redo_cb(Fl_Widget *, void *); + // Undo menu callback + static void undo_cb(Fl_Widget *, void *); +}; + +} // namespace fld +} // namespace proj + + +#endif // !undo_h |
