mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
BeginMenu: a menu that becomes disabled when open gets closed down, facilitate user's code (#126)
This commit is contained in:
parent
65b1ae6ecc
commit
213025f3cd
@ -8778,7 +8778,7 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
ImVec2 tc = (window->Pos.x < next_window->Pos.x) ? next_window_rect.GetBL() : next_window_rect.GetBR();
|
||||
float extra = ImClamp(fabsf(ta.x - tb.x) * 0.30f, 5.0f, 30.0f); // add a bit of extra slack.
|
||||
ta.x += (window->Pos.x < next_window->Pos.x) ? -0.5f : +0.5f; // to avoid numerical issues
|
||||
tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus
|
||||
tb.y = ta.y + ImMax((tb.y - extra) - ta.y, -100.0f); // triangle is maximum 200 high to limit the slope and the bias toward large sub-menus // FIXME: Multiply by fb_scale?
|
||||
tc.y = ta.y + ImMin((tc.y + extra) - ta.y, +100.0f);
|
||||
moving_within_opened_triangle = ImIsPointInTriangle(g.IO.MousePos, ta, tb, tc);
|
||||
//window->DrawList->PushClipRectFullScreen(); window->DrawList->AddTriangleFilled(ta, tb, tc, moving_within_opened_triangle ? 0x80008000 : 0x80000080); window->DrawList->PopClipRect(); // Debug
|
||||
@ -8795,7 +8795,8 @@ bool ImGui::BeginMenu(const char* label, bool enabled)
|
||||
}
|
||||
else if (pressed || (hovered && menuset_is_open && !menu_is_open)) // menu-bar: 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.. }'
|
||||
want_close = true;
|
||||
if (want_close && IsPopupOpen(id))
|
||||
ClosePopupToLevel(GImGui->CurrentPopupStack.Size);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user