From 636a6ae7750c72681819a97f6e97a01f6485331b Mon Sep 17 00:00:00 2001 From: goat Date: Thu, 26 Jan 2023 23:26:40 +0100 Subject: [PATCH] feat: add Window.BringToFront() --- Dalamud/Interface/Windowing/Window.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Dalamud/Interface/Windowing/Window.cs b/Dalamud/Interface/Windowing/Window.cs index 5b186439d..2a8beb639 100644 --- a/Dalamud/Interface/Windowing/Window.cs +++ b/Dalamud/Interface/Windowing/Window.cs @@ -15,6 +15,7 @@ public abstract class Window private bool internalLastIsOpen = false; private bool internalIsOpen = false; + private bool nextFrameBringToFront = false; /// /// Initializes a new instance of the class. @@ -126,6 +127,17 @@ public abstract class Window this.IsOpen ^= true; } + /// + /// Bring this window to the front. + /// + public void BringToFront() + { + if (!this.IsOpen) + return; + + this.nextFrameBringToFront = true; + } + /// /// Code to always be executed before the open-state of the window is checked. /// @@ -241,6 +253,12 @@ public abstract class Window ImGui.PushStyleColor(ImGuiCol.TitleBgCollapsed, focusedHeaderColor); } + if (this.nextFrameBringToFront) + { + ImGui.SetNextWindowFocus(); + this.nextFrameBringToFront = false; + } + if (this.ShowCloseButton ? ImGui.Begin(this.WindowName, ref this.internalIsOpen, this.Flags) : ImGui.Begin(this.WindowName, this.Flags)) { // Draw the actual window contents