summaryrefslogtreecommitdiff
path: root/fluid
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2024-12-04 15:44:33 +0100
committerMatthias Melcher <github@matthiasm.com>2024-12-04 15:44:39 +0100
commitb315422a372b5589392ba46c27a95eb8f3b49b72 (patch)
tree2e65de61b19d1f440e99e62a53e8c6c0ef3c0320 /fluid
parentfcae10e29607408e797067b60d2821fdb3c02e10 (diff)
FLUID: clearing caches browser values (#1152)
Diffstat (limited to 'fluid')
-rw-r--r--fluid/Fl_Window_Type.cxx3
-rw-r--r--fluid/undo.cxx25
-rw-r--r--fluid/undo.h2
-rw-r--r--fluid/widget_browser.h1
4 files changed, 25 insertions, 6 deletions
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx
index a911905b6..878d802db 100644
--- a/fluid/Fl_Window_Type.cxx
+++ b/fluid/Fl_Window_Type.cxx
@@ -418,7 +418,8 @@ void Overlay_Window::resize(int X,int Y,int W,int H) {
if (X!=x() || Y!=y() || W!=w() || H!=h()) {
// Set a checkpoint on the first resize event, ignore further resizes until
// a different type of checkpoint is triggered.
- undo_checkpoint_once(kUndoWindowResize);
+ if (undo_checkpoint_once(kUndoWindowResize))
+ set_modflag(1);
}
Fl_Widget* t = resizable();
diff --git a/fluid/undo.cxx b/fluid/undo.cxx
index 3738d9d71..49aea2d98 100644
--- a/fluid/undo.cxx
+++ b/fluid/undo.cxx
@@ -89,7 +89,10 @@ void redo_cb(Fl_Widget *, void *) {
}
undo_suspend();
- if (widget_browser) widget_browser->save_scroll_position();
+ if (widget_browser) {
+ widget_browser->save_scroll_position();
+ widget_browser->new_list();
+ }
int reload_panel = (the_panel && the_panel->visible());
if (!read_file(undo_filename(undo_current + 1), 0)) {
// Unable to read checkpoint file, don't redo...
@@ -116,6 +119,7 @@ void redo_cb(Fl_Widget *, void *) {
// Update undo/redo menu items...
// if (undo_current >= undo_last) Main_Menu[redo_item].deactivate();
// Main_Menu[undo_item].activate();
+ undo_resume();
}
// Undo menu callback
@@ -137,7 +141,10 @@ void undo_cb(Fl_Widget *, void *) {
// Undo first deletes all widgets which resets the widget_tree browser.
// Save the current scroll position, so we don't scroll back to 0 at undo.
// TODO: make the scroll position part of the .fl project file
- if (widget_browser) widget_browser->save_scroll_position();
+ if (widget_browser) {
+ widget_browser->save_scroll_position();
+ widget_browser->new_list();
+ }
int reload_panel = (the_panel && the_panel->visible());
if (!read_file(undo_filename(undo_current - 1), 0)) {
// Unable to read checkpoint file, don't undo...
@@ -172,13 +179,23 @@ void undo_cb(Fl_Widget *, void *) {
undo_resume();
}
-void undo_checkpoint_once(int type) {
- if (undo_paused) return;
+/**
+ \param[in] type set a new type, or set to 0 to clear the once_type without setting a checkpoint
+ \return 1 if the checkpoint was set, 0 if this is a repeating event
+ */
+int undo_checkpoint_once(int type) {
+ if (type == 0) {
+ undo_once_type = 0;
+ return 0;
+ }
+ if (undo_paused) return 0;
if (undo_once_type != type) {
undo_checkpoint();
undo_once_type = type;
+ return 1;
} else {
// do not add more checkpoints for the same undo type
+ return 0;
}
}
diff --git a/fluid/undo.h b/fluid/undo.h
index c5fae3306..20572351d 100644
--- a/fluid/undo.h
+++ b/fluid/undo.h
@@ -29,7 +29,7 @@ extern int undo_once_type; // Suspend further undos of the same typ
void redo_cb(Fl_Widget *, void *); // Redo menu callback
void undo_cb(Fl_Widget *, void *); // Undo menu callback
void undo_checkpoint(); // Save current file to undo buffer
-void undo_checkpoint_once(int type); // Save undo buffer once until a different checkpoint type is called
+int undo_checkpoint_once(int type); // Save undo buffer once until a different checkpoint type is called
void undo_clear(); // Clear undo buffer
void undo_resume(); // Resume undo checkpoints
void undo_suspend(); // Suspend undo checkpoints
diff --git a/fluid/widget_browser.h b/fluid/widget_browser.h
index 0325fad67..86c60777c 100644
--- a/fluid/widget_browser.h
+++ b/fluid/widget_browser.h
@@ -62,6 +62,7 @@ public:
void save_scroll_position();
void restore_scroll_position();
void rebuild();
+ void new_list() { Fl_Browser_::new_list(); }
void display(Fl_Type *);
void load_prefs();
void save_prefs();