-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom callback constraints in Constrained Resize example do not work #6210
Comments
See attached video 2023-03-01.15-08-31.mp4 |
Noticed that too, it broke in 2569c64 and it can be restored with this patch (s/CurrentSize/DesiredSize/): diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index 19c4051f4..60608fcb1 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -7389,9 +7389,9 @@ static void ShowExampleAppConstrainedResize(bool* p_open)
{
// Helper functions to demonstrate programmatic constraints
// FIXME: This doesn't take account of decoration size (e.g. title bar), library should make this easier.
- static void AspectRatio(ImGuiSizeCallbackData* data) { float aspect_ratio = *(float*)data->UserData; data->DesiredSize.x = IM_MAX(data->CurrentSize.x, data->CurrentSize.y); data->DesiredSize.y = (float)(int)(data->DesiredSize.x / aspect_ratio); }
- static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->CurrentSize.x, data->CurrentSize.y); }
- static void Step(ImGuiSizeCallbackData* data) { float step = *(float*)data->UserData; data->DesiredSize = ImVec2((int)(data->CurrentSize.x / step + 0.5f) * step, (int)(data->CurrentSize.y / step + 0.5f) * step); }
+ static void AspectRatio(ImGuiSizeCallbackData* data) { float aspect_ratio = *(float*)data->UserData; data->DesiredSize.x = IM_MAX(data->DesiredSize.x, data->DesiredSize.y); data->DesiredSize.y = (float)(int)(data->DesiredSize.x / aspect_ratio); }
+ static void Square(ImGuiSizeCallbackData* data) { data->DesiredSize.x = data->DesiredSize.y = IM_MAX(data->DesiredSize.x, data->DesiredSize.y); }
+ static void Step(ImGuiSizeCallbackData* data) { float step = *(float*)data->UserData; data->DesiredSize = ImVec2((int)(data->DesiredSize.x / step + 0.5f) * step, (int)(data->DesiredSize.y / step + 0.5f) * step); }
};
const char* test_desc[] = However even the old behavior doesn't seem fully right as the 16:9 example can't resize with an horizontal edge and the square example can't be resized down with neither horizontal nor vertical edges. I haven't looked into it further. |
@cfillion Thanks for that snippet above, worked alright on This part alone is what worked for me on Still shares a similar issue to yours above though -- can't resize from the top and bottom edges. |
Apologies for my late answer on this. There are two sides to this:
|
Version: e25e452
Branch:
docking
Back-end/Renderer/Compiler/OS
GLFW + GLAD on Linux compiled with GCC 12
Expectation
The Constrained Resize example with the
Custom: Aspect Ratio 16:9
should resize and be constrained to16:9
Observed
Attempting to resize does not resize at all. None of the custom restrains allow resizing at all.
On the
docking
branch, with viewports disabled. Docking itself being enabled/disabled makes no difference.Tested breifly on
master
at bfce775, also seems to occur.The text was updated successfully, but these errors were encountered: