Removed from the context proxy unused IsMouseHoveringAnyWindow property and moved code for WantsMouseCapture to be updated in the same scope as other context information.

This commit is contained in:
Sebastian 2020-04-16 14:49:54 +01:00
parent 5a7c81b4e3
commit 62a739ac9f
2 changed files with 7 additions and 12 deletions

View File

@ -134,14 +134,16 @@ void FImGuiContextProxy::Tick(float DeltaSeconds)
EndFrame(); EndFrame();
} }
// Update context information (some data, like mouse cursor, may be cleaned in new frame, so we should collect it // Update context information (some data need to be collected before starting a new frame while some other data
// beforehand). // may need to be collected after).
bHasActiveItem = ImGui::IsAnyItemActive(); bHasActiveItem = ImGui::IsAnyItemActive();
bIsMouseHoveringAnyWindow = ImGui::IsWindowHovered(ImGuiHoveredFlags_AnyWindow);
MouseCursor = ImGuiInterops::ToSlateMouseCursor(ImGui::GetMouseCursor()); MouseCursor = ImGuiInterops::ToSlateMouseCursor(ImGui::GetMouseCursor());
// Begin a new frame and set the context back to a state in which it allows to draw controls. // Begin a new frame and set the context back to a state in which it allows to draw controls.
BeginFrame(DeltaSeconds); BeginFrame(DeltaSeconds);
// Update remaining context information.
bWantsMouseCapture = ImGui::GetIO().WantCaptureMouse;
} }
} }
@ -173,8 +175,6 @@ void FImGuiContextProxy::BeginFrame(float DeltaTime)
ImGui::NewFrame(); ImGui::NewFrame();
bWantsMouseCapture = IO.WantCaptureMouse;
bIsFrameStarted = true; bIsFrameStarted = true;
bIsDrawEarlyDebugCalled = false; bIsDrawEarlyDebugCalled = false;
bIsDrawDebugCalled = false; bIsDrawDebugCalled = false;

View File

@ -50,10 +50,7 @@ public:
// Whether this context has an active item (read once per frame during context update). // Whether this context has an active item (read once per frame during context update).
bool HasActiveItem() const { return bHasActiveItem; } bool HasActiveItem() const { return bHasActiveItem; }
// Whether this context has mouse hovering any window (read once per frame during context update). // Whether ImGui will use the mouse inputs (read once per frame during context update).
bool IsMouseHoveringAnyWindow() const { return bIsMouseHoveringAnyWindow; }
// Whether ImGui will use the mouse inputs.
bool WantsMouseCapture() const { return bWantsMouseCapture; } bool WantsMouseCapture() const { return bWantsMouseCapture; }
// Cursor type desired by this context (updated once per frame during context update). // Cursor type desired by this context (updated once per frame during context update).
@ -93,14 +90,12 @@ private:
EMouseCursor::Type MouseCursor = EMouseCursor::None; EMouseCursor::Type MouseCursor = EMouseCursor::None;
bool bHasActiveItem = false; bool bHasActiveItem = false;
bool bIsMouseHoveringAnyWindow = false; bool bWantsMouseCapture = false;
bool bIsFrameStarted = false; bool bIsFrameStarted = false;
bool bIsDrawEarlyDebugCalled = false; bool bIsDrawEarlyDebugCalled = false;
bool bIsDrawDebugCalled = false; bool bIsDrawDebugCalled = false;
bool bWantsMouseCapture = false;
FImGuiInputState InputState; FImGuiInputState InputState;
TArray<FImGuiDrawList> DrawLists; TArray<FImGuiDrawList> DrawLists;