From e59a7a247936145ad9840866021ee57208f6606c Mon Sep 17 00:00:00 2001 From: Anna Date: Sun, 12 Jun 2022 10:49:09 -0400 Subject: [PATCH] fix: handle opacity for popped-out windows --- ChatTwo/Ui/ChatLog.cs | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index f405ff3..ab086cd 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -915,21 +915,37 @@ internal sealed class ChatLog : IUiComponent { ImGui.EndPopup(); } + private readonly List _popOutDocked = new(); + private void DrawPopOuts() { this.HandlerLender.ResetCounter(); - foreach (var tab in this.Ui.Plugin.Config.Tabs.Where(tab => tab.PopOut)) { - this.DrawPopOut(tab); + + if (this._popOutDocked.Count != this.Ui.Plugin.Config.Tabs.Count) { + this._popOutDocked.Clear(); + this._popOutDocked.AddRange(Enumerable.Repeat(false, this.Ui.Plugin.Config.Tabs.Count)); + } + + for (var i = 0; i < this.Ui.Plugin.Config.Tabs.Count; i++) { + var tab = this.Ui.Plugin.Config.Tabs[i]; + if (!tab.PopOut) { + continue; + } + + this.DrawPopOut(tab, i); } } - private void DrawPopOut(Tab tab) { + private void DrawPopOut(Tab tab, int idx) { var flags = ImGuiWindowFlags.None; if (!this.Ui.Plugin.Config.ShowPopOutTitleBar) { flags |= ImGuiWindowFlags.NoTitleBar; } - var alpha = tab.IndependentOpacity ? tab.Opacity : this.Ui.Plugin.Config.WindowAlpha; - ImGui.SetNextWindowBgAlpha(alpha / 100f); + if (!this._popOutDocked[idx]) { + var alpha = tab.IndependentOpacity ? tab.Opacity : this.Ui.Plugin.Config.WindowAlpha; + ImGui.SetNextWindowBgAlpha(alpha / 100f); + } + ImGui.SetNextWindowSize(new Vector2(350, 350) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver); if (!ImGui.Begin($"{tab.Name}##popout", ref tab.PopOut, flags)) { goto End; @@ -948,6 +964,7 @@ internal sealed class ChatLog : IUiComponent { ImGui.PopID(); End: + this._popOutDocked[idx] = ImGui.IsWindowDocked(); ImGui.End(); if (!tab.PopOut) {