| 957 | } |
| 958 | |
| 959 | bool WindowSetResize(WindowBase& w, ScreenSize minSize, ScreenSize maxSize) |
| 960 | { |
| 961 | w.minWidth = std::min(minSize.width, maxSize.width); |
| 962 | w.minHeight = std::min(minSize.height, maxSize.height); |
| 963 | w.maxWidth = std::max(minSize.width, maxSize.width); |
| 964 | w.maxHeight = std::max(minSize.height, maxSize.height); |
| 965 | |
| 966 | if (Config::Get().interface.enlargedUi) |
| 967 | { |
| 968 | // Not sure why plugin windows have to be treated differently, |
| 969 | // but they currently show a deviation if we don't. |
| 970 | if (w.classification == WindowClass::custom) |
| 971 | { |
| 972 | w.minHeight += w.getTitleBarDiffTarget(); |
| 973 | w.maxHeight += w.getTitleBarDiffTarget(); |
| 974 | } |
| 975 | else |
| 976 | { |
| 977 | w.minHeight += w.getTitleBarDiffNormal(); |
| 978 | w.maxHeight += w.getTitleBarDiffNormal(); |
| 979 | } |
| 980 | } |
| 981 | |
| 982 | // Clamp width and height to minimum and maximum |
| 983 | int16_t width = std::clamp<int16_t>(w.width, w.minWidth, w.maxWidth); |
| 984 | int16_t height = std::clamp<int16_t>(w.height, w.minHeight, w.maxHeight); |
| 985 | |
| 986 | // Resize window if size has changed |
| 987 | if (w.width != width || w.height != height) |
| 988 | { |
| 989 | w.invalidate(); |
| 990 | w.width = width; |
| 991 | w.height = height; |
| 992 | w.resizeFrame(); |
| 993 | w.invalidate(); |
| 994 | return true; |
| 995 | } |
| 996 | |
| 997 | return false; |
| 998 | } |
| 999 | |
| 1000 | /** |
| 1001 | * |