mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
BeginMenu: Shuffling braces around to clarify flow
This commit is contained in:
parent
3b85a8b6a0
commit
fba9353c60
18
imgui.cpp
18
imgui.cpp
@ -9100,14 +9100,18 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
|||||||
want_close = (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
|
want_close = (menu_is_open && !hovered && g.HoveredWindow == window && g.HoveredIdPreviousFrame != 0 && g.HoveredIdPreviousFrame != id && !moving_within_opened_triangle);
|
||||||
want_open = (!menu_is_open && hovered && !moving_within_opened_triangle) || (!menu_is_open && hovered && pressed);
|
want_open = (!menu_is_open && hovered && !moving_within_opened_triangle) || (!menu_is_open && hovered && pressed);
|
||||||
}
|
}
|
||||||
else if (menu_is_open && pressed && menuset_is_open) // Menu bar: click an open menu again to close it
|
else
|
||||||
{
|
{
|
||||||
want_close = true;
|
// Menu bar
|
||||||
want_open = menu_is_open = false;
|
if (menu_is_open && pressed && menuset_is_open) // Click an open menu again to close it
|
||||||
}
|
{
|
||||||
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // menu-bar: first click to open, then hover to open others
|
want_close = true;
|
||||||
{
|
want_open = menu_is_open = false;
|
||||||
want_open = true;
|
}
|
||||||
|
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // First click to open, then hover to open others
|
||||||
|
{
|
||||||
|
want_open = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
|
if (!enabled) // explicitly close if an open menu becomes disabled, facilitate users code a lot in pattern such as 'if (BeginMenu("options", has_object)) { ..use object.. }'
|
||||||
|
Loading…
Reference in New Issue
Block a user