Version/Branch of Dear ImGui:
Version 1.92.6, Branch: docking
Back-ends:
imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler, OS:
Windows 11 + VS 2022
Full config/build information:
No response
Details:
My Issue/Question:
It would be nice to be able to set popup menu position and pivot upon calling OpenPopup (not at BeginPopup). For example to implement drop down menu button I can calculate the popup menu position to be aligned with the button rect and then show it at that location. OpenPopupEx seems to be storing the mouse cursor position in ImGuiPopupData but it doesn't allow to override it or to specify pivot which is important (when f.e. drop down button is on the right side of the screen so the menu should be aligned with button's right edge).
Currently I am doing this to set the position:
ImGui::SetNextWindowPos(pos, ImGuiCond_Always, pivot);
if (ImGui::BeginPopup(str_id))
{
//no need to submit menu items here, just for setting the menu position
ImGui::GetCurrentWindow()->LastFrameActive = -1; //recalc window size in next invocation when items are submitted
ImGui::EndPopup();
}
But it feels hackish.
It would be even more helpful when ImGui calculates the menu position itself when certain flag in OpenPopup is set. We could have PopupPositionPolicy_ItemOverlap where the popup menu overlaps the drop down button as it is common in mobile apps and PopupPositionPolicy_ItemSide to align the popup menu similarly how the combo popup is aligned.
Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code:
Version/Branch of Dear ImGui:
Version 1.92.6, Branch: docking
Back-ends:
imgui_impl_opengl3.cpp + imgui_impl_glfw.cpp
Compiler, OS:
Windows 11 + VS 2022
Full config/build information:
No response
Details:
My Issue/Question:
It would be nice to be able to set popup menu position and pivot upon calling
OpenPopup(not atBeginPopup). For example to implement drop down menu button I can calculate the popup menu position to be aligned with the button rect and then show it at that location.OpenPopupExseems to be storing the mouse cursor position inImGuiPopupDatabut it doesn't allow to override it or to specify pivot which is important (when f.e. drop down button is on the right side of the screen so the menu should be aligned with button's right edge).Currently I am doing this to set the position:
But it feels hackish.
It would be even more helpful when ImGui calculates the menu position itself when certain flag in
OpenPopupis set. We could havePopupPositionPolicy_ItemOverlapwhere the popup menu overlaps the drop down button as it is common in mobile apps andPopupPositionPolicy_ItemSideto align the popup menu similarly how the combo popup is aligned.Screenshots/Video:
No response
Minimal, Complete and Verifiable Example code: