FLUID: Add Synchronized Resize. #1055

This commit is contained in:
Matthias Melcher 2024-08-31 20:36:34 +02:00
parent e01c9ff6a0
commit d51046cdea
5 changed files with 36 additions and 6 deletions

View File

@ -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

View File

@ -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 .

View File

@ -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 },

View File

@ -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);

View File

@ -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