mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-04 20:18:47 +02:00
Viewport, Platform: Using Platform_GetWindowFocus to provide a much stronger heuristic of platform z-order, in replacement for when the back-end cannot provide io.MouseHoveredViewport. The pressure for it to work well increased with the use of viewports by popups/menus. (#1542)
This commit is contained in:
@ -511,8 +511,8 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
{
|
||||
int Idx;
|
||||
int LastFrameActive; // Last frame number this viewport was activated by a window
|
||||
int LastFrameAsRefViewport; // Last frame number this viewport was io.MouseViewportRef
|
||||
int LastFrameOverlayDrawList;
|
||||
int LastFrontMostStampCount; // Last stamp number from when a window hosted by this viewport was made front-most (by comparing this value between two viewport we have an implicit viewport z-order
|
||||
ImGuiID LastNameHash;
|
||||
ImVec2 LastPos;
|
||||
float Alpha; // Window opacity (when dragging dockable windows/viewports we make them transparent)
|
||||
@ -524,7 +524,7 @@ struct ImGuiViewportP : public ImGuiViewport
|
||||
ImDrawDataBuilder DrawDataBuilder;
|
||||
ImVec2 RendererLastSize;
|
||||
|
||||
ImGuiViewportP() { Idx = 1; LastFrameActive = LastFrameAsRefViewport = LastFrameOverlayDrawList = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = INT_MIN; Window = NULL; OverlayDrawList = NULL; RendererLastSize = ImVec2(-1.0f,-1.0f); }
|
||||
ImGuiViewportP() { Idx = 1; LastFrameActive = LastFrameOverlayDrawList = LastFrontMostStampCount = -1; LastNameHash = 0; Alpha = LastAlpha = 1.0f; PlatformMonitor = INT_MIN; Window = NULL; OverlayDrawList = NULL; RendererLastSize = ImVec2(-1.0f,-1.0f); }
|
||||
~ImGuiViewportP() { if (OverlayDrawList) IM_DELETE(OverlayDrawList); }
|
||||
ImRect GetRect() const { return ImRect(Pos.x, Pos.y, Pos.x + Size.x, Pos.y + Size.y); }
|
||||
ImVec2 GetCenter() const{ return ImVec2(Pos.x + Size.x * 0.5f, Pos.y + Size.y * 0.5f); }
|
||||
@ -610,6 +610,7 @@ struct ImGuiContext
|
||||
ImVector<ImGuiWindow*> CurrentWindowStack;
|
||||
ImGuiStorage WindowsById;
|
||||
int WindowsActiveCount;
|
||||
int WindowsFrontMostStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter
|
||||
ImGuiWindow* CurrentWindow; // Being drawn into
|
||||
ImGuiWindow* HoveredWindow; // Will catch mouse inputs
|
||||
ImGuiWindow* HoveredRootWindow; // Will catch mouse inputs (for focus/move only)
|
||||
@ -644,6 +645,7 @@ struct ImGuiContext
|
||||
ImGuiViewportP* MouseRefPrevViewport;
|
||||
ImGuiViewportP* MouseHoveredLastViewport; // Last viewport that was hovered by mouse (even if we are not hovering any viewport any more)
|
||||
ImGuiID MouseClickedPosViewportId[5]; // For rarely used fields we only compare to, store viewport ID only so we don't have to clean dangling pointers
|
||||
ImGuiID PlatformLastFocusedViewport; // Record of last focused platform window/viewport, when this changes we stamp the viewport as front-most
|
||||
|
||||
// Navigation data (for gamepad/keyboard)
|
||||
ImGuiWindow* NavWindow; // Focused window for navigation. Could be called 'FocusWindow'
|
||||
@ -751,6 +753,7 @@ struct ImGuiContext
|
||||
FrameCount = 0;
|
||||
FrameCountEnded = FrameCountPlatformEnded = FrameCountRendered = -1;
|
||||
WindowsActiveCount = 0;
|
||||
WindowsFrontMostStampCount = 0;
|
||||
CurrentWindow = NULL;
|
||||
HoveredWindow = NULL;
|
||||
HoveredRootWindow = NULL;
|
||||
@ -776,6 +779,7 @@ struct ImGuiContext
|
||||
MouseRefViewport = NULL;
|
||||
MouseRefPrevViewport = MouseHoveredLastViewport = NULL;
|
||||
memset(MouseClickedPosViewportId, 0, sizeof(MouseClickedPosViewportId));
|
||||
PlatformLastFocusedViewport = 0;
|
||||
|
||||
NavWindow = NULL;
|
||||
NavId = NavActivateId = NavActivateDownId = NavActivatePressedId = NavInputId = 0;
|
||||
|
Reference in New Issue
Block a user