mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-22 11:57:00 +00:00
BeginMenu(): Menus: Fixed a one-frame issue where SetNextWindowXXX data are not consumed by a BeginMenu().
+ Shallow tweaks to reduce diff of future branches. Removing early return also facilitate some changes.
This commit is contained in:
parent
5ac94ad898
commit
e3fa56ae05
@ -154,6 +154,8 @@ Other Changes:
|
|||||||
- Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (#5730)
|
- Menus, Nav: Fixed not being able to close a menu with Left arrow when parent is not a popup. (#5730)
|
||||||
- Menus, Nav: Fixed using left/right navigation when appending to an existing menu (multiple
|
- Menus, Nav: Fixed using left/right navigation when appending to an existing menu (multiple
|
||||||
BeginMenu() call with same names). (#1207)
|
BeginMenu() call with same names). (#1207)
|
||||||
|
- Menus: Fixed a one-frame issue where SetNextWindowXXX data are not consumed by a BeginMenu()
|
||||||
|
returning false (specifically )
|
||||||
- Nav: Fixed moving/resizing window with gamepad or keyboard when running at very high framerate.
|
- Nav: Fixed moving/resizing window with gamepad or keyboard when running at very high framerate.
|
||||||
- Nav: Pressing Space/GamepadFaceDown on a repeating button uses the same repeating rate as a mouse hold.
|
- Nav: Pressing Space/GamepadFaceDown on a repeating button uses the same repeating rate as a mouse hold.
|
||||||
- Nav: Fixed an issue opening a menu with Right key from a non-menu window.
|
- Nav: Fixed an issue opening a menu with Right key from a non-menu window.
|
||||||
|
2
imgui.h
2
imgui.h
@ -511,7 +511,7 @@ namespace ImGui
|
|||||||
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1), const ImVec4& border_col = ImVec4(0, 0, 0, 0));
|
IMGUI_API void Image(ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& tint_col = ImVec4(1, 1, 1, 1), const ImVec4& border_col = ImVec4(0, 0, 0, 0));
|
||||||
IMGUI_API bool ImageButton(const char* str_id, ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
IMGUI_API bool ImageButton(const char* str_id, ImTextureID user_texture_id, const ImVec2& size, const ImVec2& uv0 = ImVec2(0, 0), const ImVec2& uv1 = ImVec2(1, 1), const ImVec4& bg_col = ImVec4(0, 0, 0, 0), const ImVec4& tint_col = ImVec4(1, 1, 1, 1));
|
||||||
|
|
||||||
// Widgets: Combo Box
|
// Widgets: Combo Box (Dropdown)
|
||||||
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
// - The BeginCombo()/EndCombo() api allows you to manage your contents and selection state however you want it, by creating e.g. Selectable() items.
|
||||||
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created.
|
// - The old Combo() api are helpers over BeginCombo()/EndCombo() which are kept available for convenience purpose. This is analogous to how ListBox are created.
|
||||||
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
|
IMGUI_API bool BeginCombo(const char* label, const char* preview_value, ImGuiComboFlags flags = 0);
|
||||||
|
@ -1084,6 +1084,7 @@ static void ShowDemoWindowWidgets()
|
|||||||
IMGUI_DEMO_MARKER("Widgets/Combo");
|
IMGUI_DEMO_MARKER("Widgets/Combo");
|
||||||
if (ImGui::TreeNode("Combo"))
|
if (ImGui::TreeNode("Combo"))
|
||||||
{
|
{
|
||||||
|
// Combo Boxes are also called "Dropdown" in other systems
|
||||||
// Expose flags as checkbox for the demo
|
// Expose flags as checkbox for the demo
|
||||||
static ImGuiComboFlags flags = 0;
|
static ImGuiComboFlags flags = 0;
|
||||||
ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft);
|
ImGui::CheckboxFlags("ImGuiComboFlags_PopupAlignLeft", &flags, ImGuiComboFlags_PopupAlignLeft);
|
||||||
|
@ -6965,9 +6965,9 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
|
|
||||||
// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
|
// Sub-menus are ChildWindow so that mouse can be hovering across them (otherwise top-most popup menu would steal focus and not allow hovering on parent menu)
|
||||||
// The first menu in a hierarchy isn't so hovering doesn't get across (otherwise e.g. resizing borders with ImGuiButtonFlags_FlattenChildren would react), but top-most BeginMenu() will bypass that limitation.
|
// The first menu in a hierarchy isn't so hovering doesn't get across (otherwise e.g. resizing borders with ImGuiButtonFlags_FlattenChildren would react), but top-most BeginMenu() will bypass that limitation.
|
||||||
ImGuiWindowFlags flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
|
ImGuiWindowFlags window_flags = ImGuiWindowFlags_ChildMenu | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoNavFocus;
|
||||||
if (window->Flags & ImGuiWindowFlags_ChildMenu)
|
if (window->Flags & ImGuiWindowFlags_ChildMenu)
|
||||||
flags |= ImGuiWindowFlags_ChildWindow;
|
window_flags |= ImGuiWindowFlags_ChildWindow;
|
||||||
|
|
||||||
// If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin().
|
// If a menu with same the ID was already submitted, we will append to it, matching the behavior of Begin().
|
||||||
// We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame.
|
// We are relying on a O(N) search - so O(N log N) over the frame - which seems like the most efficient for the expected small amount of BeginMenu() calls per frame.
|
||||||
@ -6975,7 +6975,7 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
if (g.MenusIdSubmittedThisFrame.contains(id))
|
if (g.MenusIdSubmittedThisFrame.contains(id))
|
||||||
{
|
{
|
||||||
if (menu_is_open)
|
if (menu_is_open)
|
||||||
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
menu_is_open = BeginPopupEx(id, window_flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||||
else
|
else
|
||||||
g.NextWindowData.ClearFlags(); // we behave like Begin() and need to consume those values
|
g.NextWindowData.ClearFlags(); // we behave like Begin() and need to consume those values
|
||||||
return menu_is_open;
|
return menu_is_open;
|
||||||
@ -7112,23 +7112,23 @@ bool ImGui::BeginMenuEx(const char* label, const char* icon, bool enabled)
|
|||||||
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0));
|
IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Openable | (menu_is_open ? ImGuiItemStatusFlags_Opened : 0));
|
||||||
PopID();
|
PopID();
|
||||||
|
|
||||||
if (!menu_is_open && want_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size)
|
if (want_open && !menu_is_open && g.OpenPopupStack.Size > g.BeginPopupStack.Size)
|
||||||
{
|
{
|
||||||
// Don't recycle same menu level in the same frame, first close the other menu and yield for a frame.
|
// Don't reopen/recycle same menu level in the same frame, first close the other menu and yield for a frame.
|
||||||
OpenPopup(label);
|
OpenPopup(label);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
else if (want_open)
|
||||||
menu_is_open |= want_open;
|
{
|
||||||
if (want_open)
|
menu_is_open = true;
|
||||||
OpenPopup(label);
|
OpenPopup(label);
|
||||||
|
}
|
||||||
|
|
||||||
if (menu_is_open)
|
if (menu_is_open)
|
||||||
{
|
{
|
||||||
ImGuiLastItemData last_item_in_parent = g.LastItemData;
|
ImGuiLastItemData last_item_in_parent = g.LastItemData;
|
||||||
SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos.
|
SetNextWindowPos(popup_pos, ImGuiCond_Always); // Note: misleading: the value will serve as reference for FindBestWindowPosForPopup(), not actual pos.
|
||||||
PushStyleVar(ImGuiStyleVar_ChildRounding, style.PopupRounding); // First level will use _PopupRounding, subsequent will use _ChildRounding
|
PushStyleVar(ImGuiStyleVar_ChildRounding, style.PopupRounding); // First level will use _PopupRounding, subsequent will use _ChildRounding
|
||||||
menu_is_open = BeginPopupEx(id, flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
menu_is_open = BeginPopupEx(id, window_flags); // menu_is_open can be 'false' when the popup is completely clipped (e.g. zero size display)
|
||||||
PopStyleVar();
|
PopStyleVar();
|
||||||
if (menu_is_open)
|
if (menu_is_open)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user