FLTK logo

[master] 8b7021b - Fluid: Keep widget panel open during undo/redo (#566)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.commit  ]
 
Previous Message ]Next Message ]

[master] 8b7021b - Fluid: Keep widget panel open during undo/redo (#566) "Matthias Melcher" Nov 30, 2022  
 
commit 8b7021ba8b94680099f8f739f79dcea72729eeb7
Author:     Matthias Melcher <github@matthiasm.com>
AuthorDate: Thu Dec 1 01:00:12 2022 +0100
Commit:     GitHub <noreply@github.com>
CommitDate: Thu Dec 1 01:00:12 2022 +0100

    Fluid: Keep widget panel open during undo/redo (#566)

 fluid/Fl_Widget_Type.cxx |  2 +-
 fluid/undo.cxx           | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git fluid/Fl_Widget_Type.cxx fluid/Fl_Widget_Type.cxx
index 6c9529b..26e4072 100644
--- fluid/Fl_Widget_Type.cxx
+++ fluid/Fl_Widget_Type.cxx
@@ -295,7 +295,7 @@ Fl_Type *sort(Fl_Type *parent) {
 ////////////////////////////////////////////////////////////////
 // The control panels!
 
-static Fl_Window *the_panel;
+Fl_Window *the_panel;
 
 // All the callbacks use the argument to indicate whether to load or store.
 // This avoids the need for pointers to all the widgets, and keeps the
diff --git fluid/undo.cxx fluid/undo.cxx
index b7377b8..4f0b18c 100644
--- fluid/undo.cxx
+++ fluid/undo.cxx
@@ -19,9 +19,11 @@
 #include "fluid.h"
 #include "file.h"
 #include "Fl_Type.h"
+#include "Fl_Widget_Type.h"
 #include "widget_browser.h"
 
 #include <FL/Fl.H>
+#include <FL/Fl_Window.H>
 #include <FL/Fl_Preferences.H>
 #include <FL/Fl_Menu_Bar.H>
 #include <FL/filename.H>
@@ -43,6 +45,7 @@
 // checkpoint files.
 //
 
+extern Fl_Window* the_panel;
 
 int undo_current = 0;                   // Current undo level in buffer
 int undo_last = 0;                      // Last undo level in buffer
@@ -80,12 +83,21 @@ void redo_cb(Fl_Widget *, void *) {
   if (undo_current >= undo_last) return;
 
   undo_suspend();
+  if (widget_browser) widget_browser->save_scroll_position();
+  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...
     widget_browser->rebuild();
     undo_resume();
     return;
   }
+  if (reload_panel) {
+    for (Fl_Type *t = Fl_Type::first; t; t=t->next) {
+      if (t->is_widget() && t->selected)
+        t->open();
+    }
+  }
+  if (widget_browser) widget_browser->restore_scroll_position();
 
   undo_current ++;
 
@@ -113,12 +125,19 @@ 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.
   if (widget_browser) widget_browser->save_scroll_position();
+  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...
     widget_browser->rebuild();
     undo_resume();
     return;
   }
+  if (reload_panel) {
+    for (Fl_Type *t = Fl_Type::first; t; t=t->next) {
+      if (t->is_widget() && t->selected)
+        t->open();
+    }
+  }
   // Restore old browser position.
   // Ideally, we would save the browser position insied the undo file.
   if (widget_browser) widget_browser->restore_scroll_position();
Direct Link to Message ]
 
     
Previous Message ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.