mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 03:58:47 +02:00
Backport from docking branch: minor stuff.
Fixed software mouse cursor being rendered multiple times if Render() is called more than once.
This commit is contained in:
29
imgui.cpp
29
imgui.cpp
@ -3386,6 +3386,17 @@ bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id)
|
||||
return false;
|
||||
}
|
||||
|
||||
// This is also inlined in ItemAdd()
|
||||
// Note: if ImGuiItemStatusFlags_HasDisplayRect is set, user needs to set window->DC.LastItemDisplayRect!
|
||||
void ImGui::SetLastItemData(ImGuiID item_id, ImGuiItemFlags in_flags, ImGuiItemStatusFlags item_flags, const ImRect& item_rect)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
g.LastItemData.ID = item_id;
|
||||
g.LastItemData.InFlags = in_flags;
|
||||
g.LastItemData.StatusFlags = item_flags;
|
||||
g.LastItemData.Rect = item_rect;
|
||||
}
|
||||
|
||||
float ImGui::CalcWrapWidthForPos(const ImVec2& pos, float wrap_pos_x)
|
||||
{
|
||||
if (wrap_pos_x < 0.0f)
|
||||
@ -4533,6 +4544,7 @@ void ImGui::Render()
|
||||
|
||||
if (g.FrameCountEnded != g.FrameCount)
|
||||
EndFrame();
|
||||
const bool first_render_of_frame = (g.FrameCountRendered != g.FrameCount);
|
||||
g.FrameCountRendered = g.FrameCount;
|
||||
g.IO.MetricsRenderWindows = 0;
|
||||
|
||||
@ -4570,7 +4582,7 @@ void ImGui::Render()
|
||||
viewport->DrawDataBuilder.FlattenIntoSingleLayer();
|
||||
|
||||
// Draw software mouse cursor if requested by io.MouseDrawCursor flag
|
||||
if (g.IO.MouseDrawCursor)
|
||||
if (g.IO.MouseDrawCursor && first_render_of_frame)
|
||||
RenderMouseCursor(GetForegroundDrawList(viewport), g.IO.MousePos, g.Style.MouseCursorScale, g.MouseCursor, IM_COL32_WHITE, IM_COL32_BLACK, IM_COL32(0, 0, 0, 48));
|
||||
|
||||
// Add foreground ImDrawList (for each active viewport)
|
||||
@ -5351,11 +5363,11 @@ ImVec2 ImGui::CalcWindowNextAutoFitSize(ImGuiWindow* window)
|
||||
return size_final;
|
||||
}
|
||||
|
||||
static ImGuiCol GetWindowBgColorIdxFromFlags(ImGuiWindowFlags flags)
|
||||
static ImGuiCol GetWindowBgColorIdx(ImGuiWindow* window)
|
||||
{
|
||||
if (flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
|
||||
if (window->Flags & (ImGuiWindowFlags_Tooltip | ImGuiWindowFlags_Popup))
|
||||
return ImGuiCol_PopupBg;
|
||||
if (flags & ImGuiWindowFlags_ChildWindow)
|
||||
if (window->Flags & ImGuiWindowFlags_ChildWindow)
|
||||
return ImGuiCol_ChildBg;
|
||||
return ImGuiCol_WindowBg;
|
||||
}
|
||||
@ -5633,7 +5645,7 @@ void ImGui::RenderWindowDecorations(ImGuiWindow* window, const ImRect& title_bar
|
||||
// Window background
|
||||
if (!(flags & ImGuiWindowFlags_NoBackground))
|
||||
{
|
||||
ImU32 bg_col = GetColorU32(GetWindowBgColorIdxFromFlags(flags));
|
||||
ImU32 bg_col = GetColorU32(GetWindowBgColorIdx(window));
|
||||
bool override_alpha = false;
|
||||
float alpha = 1.0f;
|
||||
if (g.NextWindowData.Flags & ImGuiNextWindowDataFlags_HasBgAlpha)
|
||||
@ -6386,10 +6398,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
|
||||
// We fill last item data based on Title Bar/Tab, in order for IsItemHovered() and IsItemActive() to be usable after Begin().
|
||||
// This is useful to allow creating context menus on title bar only, etc.
|
||||
g.LastItemData.ID = window->MoveId;
|
||||
g.LastItemData.InFlags = g.CurrentItemFlags;
|
||||
g.LastItemData.StatusFlags = IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0;
|
||||
g.LastItemData.Rect = title_bar_rect;
|
||||
SetLastItemData(window->MoveId, g.CurrentItemFlags, IsMouseHoveringRect(title_bar_rect.Min, title_bar_rect.Max, false) ? ImGuiItemStatusFlags_HoveredRect : 0, title_bar_rect);
|
||||
|
||||
#ifdef IMGUI_ENABLE_TEST_ENGINE
|
||||
if (!(window->Flags & ImGuiWindowFlags_NoTitleBar))
|
||||
@ -6837,8 +6846,8 @@ bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
|
||||
return false;
|
||||
if (flags & ImGuiFocusedFlags_AnyWindow)
|
||||
return true;
|
||||
IM_ASSERT(cur_window); // Not inside a Begin()/End()
|
||||
|
||||
IM_ASSERT(cur_window); // Not inside a Begin()/End()
|
||||
const bool popup_hierarchy = (flags & ImGuiFocusedFlags_NoPopupHierarchy) == 0;
|
||||
if (flags & ImGuiHoveredFlags_RootWindow)
|
||||
cur_window = GetCombinedRootWindow(cur_window, popup_hierarchy);
|
||||
|
Reference in New Issue
Block a user