diff options
| author | Matthias Melcher <github@matthiasm.com> | 2024-08-31 20:36:34 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2024-08-31 20:36:34 +0200 |
| commit | d51046cdeaf1dceac91e70fe6be358502280a431 (patch) | |
| tree | fccd991be47f4b69935bb378d737a0f9de242f2e | |
| parent | e01c9ff6a03f3775e0d93a56d671a8c2f8cf96a2 (diff) | |
FLUID: Add Synchronized Resize. #1055
| -rw-r--r-- | fluid/Fl_Window_Type.cxx | 9 | ||||
| -rw-r--r-- | fluid/documentation/src/page_main_window.dox | 5 | ||||
| -rw-r--r-- | fluid/fluid.cxx | 6 | ||||
| -rw-r--r-- | fluid/undo.cxx | 16 | ||||
| -rw-r--r-- | fluid/undo.h | 6 |
5 files changed, 36 insertions, 6 deletions
diff --git a/fluid/Fl_Window_Type.cxx b/fluid/Fl_Window_Type.cxx index 2e77d386c..821f59cde 100644 --- a/fluid/Fl_Window_Type.cxx +++ b/fluid/Fl_Window_Type.cxx @@ -5,7 +5,7 @@ // for interacting with the overlay, which allows the user to // select, move, and resize the children widgets. // -// Copyright 1998-2023 by Bill Spitzak and others. +// Copyright 1998-2024 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 @@ -408,7 +408,12 @@ Fl_Window_Type Fl_Window_type; // Resize from window manager... void Overlay_Window::resize(int X,int Y,int W,int H) { - Fl_Widget* t = resizable(); resizable(0); + undo_checkpoint_once(kUndoWindowResize); + + Fl_Widget* t = resizable(); + if (Fl_Type::allow_layout == 0) { + resizable(0); + } // do not set the mod flag if the window was not resized. In FLUID, all // windows are opened without a given x/y position, so modifying x/y diff --git a/fluid/documentation/src/page_main_window.dox b/fluid/documentation/src/page_main_window.dox index 1a9e4ea6f..4cb7777e5 100644 --- a/fluid/documentation/src/page_main_window.dox +++ b/fluid/documentation/src/page_main_window.dox @@ -346,6 +346,11 @@ the first selected widget. __Layout > Center in Group > ...__: Center all selected widgets relative to their parent widget +__Layout > Synchronized Resize__: If unchecked, groups and windows can be +resized without resizing their children. If set, the layout of the children +is changed according to their `resize()` settings. Try __Live Resize__ to +verify the effects before permanently modifying the layout. + __Layout > Grid and Size Settings... (Ctrl+g)__: Display the grid settings panel. See \ref setting_layout . diff --git a/fluid/fluid.cxx b/fluid/fluid.cxx index 01f9a93a1..ffd2edfee 100644 --- a/fluid/fluid.cxx +++ b/fluid/fluid.cxx @@ -1637,7 +1637,8 @@ static void menu_file_new_from_template_cb(Fl_Widget *, void *) { new_project_fr static void menu_file_open_cb(Fl_Widget *, void *) { open_project_file(""); } static void menu_file_insert_cb(Fl_Widget *, void *) { merge_project_file(""); } static void menu_file_open_history_cb(Fl_Widget *, void *v) { open_project_file(Fl_String((const char*)v)); } - +static void menu_layout_sync_resize_cb(Fl_Menu_ *m, void*) { + if (m->mvalue()->value()) Fl_Type::allow_layout = 1; else Fl_Type::allow_layout = 0; } /** This is the main Fluid menu. @@ -1722,10 +1723,11 @@ Fl_Menu_Item Main_Menu[] = { {"&Height",0,(Fl_Callback *)align_widget_cb,(void*)31}, {"&Both",0,(Fl_Callback *)align_widget_cb,(void*)32}, {0}, - {"&Center In Group",0,0,0,FL_SUBMENU|FL_MENU_DIVIDER}, + {"&Center In Group",0,0,0,FL_SUBMENU}, {"&Horizontal",0,(Fl_Callback *)align_widget_cb,(void*)40}, {"&Vertical",0,(Fl_Callback *)align_widget_cb,(void*)41}, {0}, + {"Synchronized Resize", 0, (Fl_Callback*)menu_layout_sync_resize_cb, NULL, FL_MENU_TOGGLE|FL_MENU_DIVIDER }, {"&Grid and Size Settings...",FL_COMMAND+'g',show_grid_cb, NULL, FL_MENU_DIVIDER}, {"Presets", 0, layout_suite_marker, (void*)main_layout_submenu_, FL_SUBMENU_POINTER }, {"Application", 0, select_layout_preset_cb, (void*)0, FL_MENU_RADIO|FL_MENU_VALUE }, diff --git a/fluid/undo.cxx b/fluid/undo.cxx index 0d5cb4d9b..31b412878 100644 --- a/fluid/undo.cxx +++ b/fluid/undo.cxx @@ -1,7 +1,7 @@ // // FLUID undo support for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2021 by Bill Spitzak and others. +// Copyright 1998-2024 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 @@ -53,6 +53,7 @@ int undo_last = 0; // Last undo level in buffer int undo_max = 0; // Maximum undo level used int undo_save = -1; // Last undo level that was saved static int undo_paused = 0; // Undo checkpointing paused? +int undo_once_type = 0; // Suspend further undos of the same type // Return the undo filename. @@ -80,6 +81,7 @@ static char *undo_filename(int level) { void redo_cb(Fl_Widget *, void *) { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); + undo_once_type = 0; if (undo_current >= undo_last) { fl_beep(); @@ -120,6 +122,7 @@ void redo_cb(Fl_Widget *, void *) { void undo_cb(Fl_Widget *, void *) { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); + undo_once_type = 0; if (undo_current <= 0) { fl_beep(); @@ -165,6 +168,16 @@ void undo_cb(Fl_Widget *, void *) { undo_resume(); } +void undo_checkpoint_once(int type) { + if (undo_paused) return; + if (undo_once_type != type) { + undo_checkpoint(); + undo_once_type = type; + } else { + // do not add more checkpoints for the same undo typw + } +} + // Save current file to undo buffer void undo_checkpoint() { // printf("undo_checkpoint(): undo_current=%d, undo_paused=%d, modflag=%d\n", @@ -175,6 +188,7 @@ void undo_checkpoint() { // int undo_item = main_menubar->find_index(undo_cb); // int redo_item = main_menubar->find_index(redo_cb); + undo_once_type = 0; // Save the current UI to a checkpoint file... const char *filename = undo_filename(undo_current); diff --git a/fluid/undo.h b/fluid/undo.h index 171fe062f..c5fae3306 100644 --- a/fluid/undo.h +++ b/fluid/undo.h @@ -1,7 +1,7 @@ // // FLUID undo definitions for the Fast Light Tool Kit (FLTK). // -// Copyright 1998-2010 by Bill Spitzak and others. +// Copyright 1998-2024 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 @@ -19,13 +19,17 @@ class Fl_Widget; +#define kUndoWindowResize 1 + extern int undo_current; // Current undo level in buffer extern int undo_last; // Last undo level in buffer extern int undo_save; // Last undo level that was saved +extern int undo_once_type; // Suspend further undos of the same type 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 void undo_clear(); // Clear undo buffer void undo_resume(); // Resume undo checkpoints void undo_suspend(); // Suspend undo checkpoints |
