From 39b5ae9e6e957582eddf16c86829d01473458e5d Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Mon, 6 Dec 2021 19:49:16 +0100 Subject: Fix Fl_Window::size_range() documentation (STR 3352) "Tiny window problem if child group larger than window" See Greg's comment 4: "something is wrong here: either the logic or the docs are incorrect, not sure which." It turned out that both were incorrect. Since we fixed the code this commit completes the STR by fixing the docs as well so they match the behavior. --- FL/Fl_Group.H | 4 ++++ src/Fl_Window.cxx | 58 +++++++++++++++++++++++++++++-------------------------- 2 files changed, 35 insertions(+), 27 deletions(-) diff --git a/FL/Fl_Group.H b/FL/Fl_Group.H index 2271962b3..2d4cef152 100644 --- a/FL/Fl_Group.H +++ b/FL/Fl_Group.H @@ -162,6 +162,10 @@ public: See the \ref resize chapter for more examples and detailed explanation. + \note The resizable() widget of a window can also affect the window's + resizing behavior if Fl_Window::size_range() is not called. + + \see Fl_Window::size_range() */ void resizable(Fl_Widget* o) {resizable_ = o;} /** diff --git a/src/Fl_Window.cxx b/src/Fl_Window.cxx index 0ca39a5ff..721ff1236 100644 --- a/src/Fl_Window.cxx +++ b/src/Fl_Window.cxx @@ -594,39 +594,43 @@ int Fl_Window::handle(int ev) } /** - Sets the allowable range the user can resize this window to. - This only works for top-level windows. - - If this function is not called, FLTK tries to figure out the range - from the setting of resizable(): - - - It is undefined what happens if the current size does not fit in the - constraints passed to size_range(). - - \param[in] minWidth, minHeight The smallest the window can be. + Sets the allowable range the user can resize this window to. + This only works for top-level windows. + + It is undefined what happens if the current window size does not fit + in the constraints passed to size_range(). + + If this function is \b not called, FLTK tries to figure out the range + from the setting of the window's resizable() widget: + + - If resizable() is NULL (this is the default) then the window cannot + be resized and the resize border and max-size control will not be + displayed for the window. + + - If either dimension of resizable() is zero, then the minimum size is + also the maximum size (so the window cannot resize in that direction). + + - Otherwise the size of the resizable is irrelevant and the window's + minimum size is the current size and the maximum size is unlimited + like if size_range(w(), h(), 0, 0) was called. + + \param[in] minWidth, minHeight The smallest the window can be. Either value must be greater than 0. - \param[in] maxWidth, maxHeight The largest the window can be. If either is - equal to the minimum then you cannot resize in that direction. + + \param[in] maxWidth, maxHeight The largest the window can be. If either + is equal to the minimum then you cannot resize in that direction. If either is zero then FLTK picks a maximum size in that direction such that the window will fill the screen. - \param[in] deltaX, deltaY These are size increments. The window will be + + \param[in] deltaX, deltaY These are size increments. The window will be constrained to widths of minWidth + N * deltaX, where N is any - non-negative integer. If these are less or equal to 1 they are ignored. - (this is ignored on Windows) - \param[in] aspectRatio A flag that indicates that the window should preserve + non-negative integer. If these are less or equal to 1 they are ignored + (this is ignored on Windows). + + \param[in] aspectRatio A flag that indicates that the window should preserve its aspect ratio. This only works if both the maximum and minimum have the same aspect ratio (ignored on Windows and by many X window managers). - */ +*/ void Fl_Window::size_range(int minWidth, int minHeight, int maxWidth, int maxHeight, int deltaX, int deltaY, int aspectRatio) { -- cgit v1.2.3