diff options
| author | Matthias Melcher <git@matthiasm.com> | 2021-12-17 18:34:51 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2021-12-17 18:38:26 +0100 |
| commit | 3626e82057e2cb581afbd5495a87c00db7d7c9b8 (patch) | |
| tree | 74c7cb984c9816542895fdd35c026cd29e908256 /fluid/undo.cxx | |
| parent | ba3041be6c86c05aef1f505a10df8c8b05e7b8de (diff) | |
GitHub #326: browser scrolling should be much improved
Code now convinces browser to rebuild when the tree changes by UI.
When widgets are move, the current widget should always be visible.
It's the responsibility of the UI callback to update the browser.
Diffstat (limited to 'fluid/undo.cxx')
| -rw-r--r-- | fluid/undo.cxx | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/fluid/undo.cxx b/fluid/undo.cxx index 09f2867d9..b7377b89f 100644 --- a/fluid/undo.cxx +++ b/fluid/undo.cxx @@ -82,6 +82,7 @@ void redo_cb(Fl_Widget *, void *) { undo_suspend(); if (!read_file(undo_filename(undo_current + 1), 0)) { // Unable to read checkpoint file, don't redo... + widget_browser->rebuild(); undo_resume(); return; } @@ -90,6 +91,7 @@ void redo_cb(Fl_Widget *, void *) { // Update modified flag... set_modflag(undo_current != undo_save); + widget_browser->rebuild(); // Update undo/redo menu items... if (undo_current >= undo_last) Main_Menu[redo_item].deactivate(); @@ -109,18 +111,17 @@ void undo_cb(Fl_Widget *, void *) { undo_suspend(); // 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. - int x = widget_browser->hposition(); - int y = widget_browser->position(); + // Save the current scroll position, so we don't scroll back to 0 at undo. + if (widget_browser) widget_browser->save_scroll_position(); if (!read_file(undo_filename(undo_current - 1), 0)) { // Unable to read checkpoint file, don't undo... + widget_browser->rebuild(); undo_resume(); return; } // Restore old browser position. // Ideally, we would save the browser position insied the undo file. - widget_browser->hposition(x); - widget_browser->position(y); + if (widget_browser) widget_browser->restore_scroll_position(); undo_current --; @@ -130,6 +131,7 @@ void undo_cb(Fl_Widget *, void *) { // Update undo/redo menu items... if (undo_current <= 0) Main_Menu[undo_item].deactivate(); Main_Menu[redo_item].activate(); + widget_browser->rebuild(); undo_resume(); } |
