mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-06 04:58:47 +02:00
Internals: added temporary ImGuiItemStatusFlags_Visible (used internally - please do not use).
Used by BeginMenu() as I'm experimenting with blind menus honoring shortcuts. Extra comments about KeyMap and ImGuiKeys
This commit is contained in:
20
imgui.cpp
20
imgui.cpp
@ -393,7 +393,7 @@ CODE
|
||||
the ImGuiKey_ModXXX were introduced in 1.87 and mostly used by backends.
|
||||
the ImGuiModFlags_XXX have been exposed in imgui.h but not really used by any public api only by third-party extensions.
|
||||
exceptionally commenting out the older ImGuiKeyModFlags_XXX names ahead of obsolescence schedule to reduce confusion and because they were not meant to be used anyway.
|
||||
- 2022/09/12 (1.89) - removed the bizarre legacy default argument for 'TreePush(const void* ptr = NULL)', always pass a pointer value explicitly, NULL is ok.
|
||||
- 2022/09/12 (1.89) - removed the bizarre legacy default argument for 'TreePush(const void* ptr = NULL)', always pass a pointer value explicitly. NULL/nullptr is ok but require cast, e.g. TreePush((void*)nullptr);
|
||||
- 2022/09/05 (1.89) - commented out redirecting functions/enums names that were marked obsolete in 1.77 and 1.78 (June 2020):
|
||||
- DragScalar(), DragScalarN(), DragFloat(), DragFloat2(), DragFloat3(), DragFloat4(): For old signatures ending with (..., const char* format, float power = 1.0f) -> use (..., format ImGuiSliderFlags_Logarithmic) if power != 1.0f.
|
||||
- SliderScalar(), SliderScalarN(), SliderFloat(), SliderFloat2(), SliderFloat3(), SliderFloat4(): For old signatures ending with (..., const char* format, float power = 1.0f) -> use (..., format ImGuiSliderFlags_Logarithmic) if power != 1.0f.
|
||||
@ -3731,6 +3731,7 @@ bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: This is inlined/duplicated in ItemAdd()
|
||||
bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
@ -5342,7 +5343,7 @@ bool ImGui::IsAnyItemFocused()
|
||||
bool ImGui::IsItemVisible()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.CurrentWindow->ClipRect.Overlaps(g.LastItemData.Rect);
|
||||
return (g.LastItemData.StatusFlags & ImGuiItemStatusFlags_Visible) != 0;
|
||||
}
|
||||
|
||||
bool ImGui::IsItemEdited()
|
||||
@ -8664,12 +8665,21 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg, ImGu
|
||||
#endif
|
||||
|
||||
// Clipping test
|
||||
const bool is_clipped = IsClippedEx(bb, id);
|
||||
if (is_clipped)
|
||||
return false;
|
||||
// (FIXME: This is a modified copy of IsClippedEx() so we can reuse the is_rect_visible value)
|
||||
//const bool is_clipped = IsClippedEx(bb, id);
|
||||
//if (is_clipped)
|
||||
// return false;
|
||||
const bool is_rect_visible = bb.Overlaps(window->ClipRect);
|
||||
if (!is_rect_visible)
|
||||
if (id == 0 || (id != g.ActiveId && id != g.NavId))
|
||||
if (!g.LogEnabled)
|
||||
return false;
|
||||
|
||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
|
||||
|
||||
// We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
|
||||
if (is_rect_visible)
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_Visible;
|
||||
if (IsMouseHoveringRect(bb.Min, bb.Max))
|
||||
g.LastItemData.StatusFlags |= ImGuiItemStatusFlags_HoveredRect;
|
||||
return true;
|
||||
|
Reference in New Issue
Block a user