diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-07-17 20:20:54 +0200 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-07-17 20:21:04 +0200 |
| commit | 9bdc7139daef8d9dc7b7e06503cd810d44b6d69c (patch) | |
| tree | bd4fb30d1a2c539a3eb530eb14d1780a9e04db78 /fluid/Fd_Snap_Action.cxx | |
| parent | 9794d200b33b438feaf76c960e464b90dd911d58 (diff) | |
FLUID: better initial sizes for buttons and windows
Diffstat (limited to 'fluid/Fd_Snap_Action.cxx')
| -rw-r--r-- | fluid/Fd_Snap_Action.cxx | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/fluid/Fd_Snap_Action.cxx b/fluid/Fd_Snap_Action.cxx index 1334b0a05..6f7531007 100644 --- a/fluid/Fd_Snap_Action.cxx +++ b/fluid/Fd_Snap_Action.cxx @@ -1071,6 +1071,27 @@ void Fd_Snap_Action::get_move_stepsize(int &x_step, int &y_step) { } } +/** Fix the given size to the same or next bigger snap position. */ +void Fd_Snap_Action::better_size(int &w, int &h) { + int x_min = 1, y_min = 1, x_inc = 1, y_inc = 1; + get_resize_stepsize(x_inc, y_inc); + if (x_inc < 1) x_inc = 1; + if (y_inc < 1) y_inc = 1; + if ((layout->widget_min_w > 1) && (layout->widget_min_h > 1)) { + x_min = layout->widget_min_w; + y_min = layout->widget_min_h; + } else if ((layout->group_grid_x > 1) && (layout->group_grid_y > 1)) { + x_min = layout->group_grid_x; + y_min = layout->group_grid_y; + } else { + x_min = x_inc; + y_min = y_inc; + } + int ww = fd_max(w - x_min, 0); w = (w - ww + x_inc - 1) / x_inc; w = w * x_inc; w = w + ww; + int hh = fd_max(h - y_min, 0); h = (h - hh + y_inc - 1) / y_inc; h = h * y_inc; h = h + hh; +} + + // ---- snapping prototypes -------------------------------------------- MARK: - /** |
