From e55bfcfb49dce6429c404b8221f74ac8990d0e2f Mon Sep 17 00:00:00 2001 From: Anna Date: Sat, 19 Feb 2022 16:09:32 -0500 Subject: [PATCH] feat: add popped-out tab opacity --- ChatTwo/Configuration.cs | 6 +++++ ChatTwo/Resources/Language.Designer.cs | 36 ++++++++++++++++++++++++++ ChatTwo/Resources/Language.resx | 12 +++++++++ ChatTwo/Ui/ChatLog.cs | 14 +++++++++- ChatTwo/Ui/SettingsTabs/Display.cs | 3 +++ ChatTwo/Ui/SettingsTabs/Tabs.cs | 7 +++++ 6 files changed, 77 insertions(+), 1 deletion(-) diff --git a/ChatTwo/Configuration.cs b/ChatTwo/Configuration.cs index 419d590..1a51b0f 100755 --- a/ChatTwo/Configuration.cs +++ b/ChatTwo/Configuration.cs @@ -28,6 +28,7 @@ internal class Configuration : IPluginConfiguration { public bool CanMove = true; public bool CanResize = true; public bool ShowTitleBar; + public bool ShowPopOutTitleBar = true; public bool DatabaseBattleMessages; public bool LoadPreviousSession; public bool FilterIncludePreviousSessions; @@ -60,6 +61,7 @@ internal class Configuration : IPluginConfiguration { this.CanMove = other.CanMove; this.CanResize = other.CanResize; this.ShowTitleBar = other.ShowTitleBar; + this.ShowPopOutTitleBar = other.ShowPopOutTitleBar; this.DatabaseBattleMessages = other.DatabaseBattleMessages; this.LoadPreviousSession = other.LoadPreviousSession; this.FilterIncludePreviousSessions = other.FilterIncludePreviousSessions; @@ -139,6 +141,8 @@ internal class Tab { public bool DisplayTimestamp = true; public InputChannel? Channel; public bool PopOut; + public bool IndependentOpacity; + public float Opacity = 100f; [NonSerialized] public uint Unread; @@ -188,6 +192,8 @@ internal class Tab { DisplayTimestamp = this.DisplayTimestamp, Channel = this.Channel, PopOut = this.PopOut, + IndependentOpacity = this.IndependentOpacity, + Opacity = this.Opacity, }; } } diff --git a/ChatTwo/Resources/Language.Designer.cs b/ChatTwo/Resources/Language.Designer.cs index a63be69..14c1a17 100755 --- a/ChatTwo/Resources/Language.Designer.cs +++ b/ChatTwo/Resources/Language.Designer.cs @@ -807,6 +807,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Show title bar for popped-out tabs. + /// + internal static string Options_ShowPopOutTitleBar_Name { + get { + return ResourceManager.GetString("Options_ShowPopOutTitleBar_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to Show title bar for chat. /// @@ -915,6 +924,15 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Use different opacity than main window. + /// + internal static string Options_Tabs_IndependentOpacity { + get { + return ResourceManager.GetString("Options_Tabs_IndependentOpacity", resourceCulture); + } + } + /// /// Looks up a localized string similar to Input channel. /// @@ -969,6 +987,24 @@ namespace ChatTwo.Resources { } } + /// + /// Looks up a localized string similar to Opacity. + /// + internal static string Options_Tabs_Opacity { + get { + return ResourceManager.GetString("Options_Tabs_Opacity", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Display in separate window. + /// + internal static string Options_Tabs_PopOut { + get { + return ResourceManager.GetString("Options_Tabs_PopOut", resourceCulture); + } + } + /// /// Looks up a localized string similar to Preset: {0}. /// diff --git a/ChatTwo/Resources/Language.resx b/ChatTwo/Resources/Language.resx index 6807516..2696338 100755 --- a/ChatTwo/Resources/Language.resx +++ b/ChatTwo/Resources/Language.resx @@ -482,4 +482,16 @@ Hide timestamps when previous messages have the same timestamp. + + Show title bar for popped-out tabs + + + Display in separate window + + + Use different opacity than main window + + + Opacity + diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index d7e95bf..356e637 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -875,13 +875,25 @@ internal sealed class ChatLog : IUiComponent { } private void DrawPopOut(Tab tab) { + var flags = ImGuiWindowFlags.None; + if (!this.Ui.Plugin.Config.ShowPopOutTitleBar) { + flags |= ImGuiWindowFlags.NoTitleBar; + } + + var alpha = tab.IndependentOpacity ? tab.Opacity / 100f : this.Ui.Plugin.Config.WindowAlpha; + ImGui.SetNextWindowBgAlpha(alpha); ImGui.SetNextWindowSize(new Vector2(350, 350) * ImGuiHelpers.GlobalScale, ImGuiCond.FirstUseEver); - if (!ImGui.Begin($"{tab.Name}##popout", ref tab.PopOut)) { + if (!ImGui.Begin($"{tab.Name}##popout", ref tab.PopOut, flags)) { goto End; } ImGui.PushID($"popout-{tab.Name}"); + if (!this.Ui.Plugin.Config.ShowPopOutTitleBar) { + ImGui.TextUnformatted(tab.Name); + ImGui.Separator(); + } + this.DrawMessageLog(tab, ImGui.GetContentRegionAvail().Y, false); ImGui.PopID(); diff --git a/ChatTwo/Ui/SettingsTabs/Display.cs b/ChatTwo/Ui/SettingsTabs/Display.cs index f246f17..8fc6327 100755 --- a/ChatTwo/Ui/SettingsTabs/Display.cs +++ b/ChatTwo/Ui/SettingsTabs/Display.cs @@ -88,6 +88,9 @@ internal sealed class Display : ISettingsTab { ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowTitleBar, Language.Options_ShowTitleBar_Name); ImGui.Spacing(); + ImGuiUtil.OptionCheckbox(ref this.Mutable.ShowPopOutTitleBar, Language.Options_ShowPopOutTitleBar_Name); + ImGui.Spacing(); + ImGui.PopTextWrapPos(); } } diff --git a/ChatTwo/Ui/SettingsTabs/Tabs.cs b/ChatTwo/Ui/SettingsTabs/Tabs.cs index e3a2734..e60e2e9 100755 --- a/ChatTwo/Ui/SettingsTabs/Tabs.cs +++ b/ChatTwo/Ui/SettingsTabs/Tabs.cs @@ -75,6 +75,13 @@ internal sealed class Tabs : ISettingsTab { ImGui.InputText(Language.Options_Tabs_Name, ref tab.Name, 512, ImGuiInputTextFlags.EnterReturnsTrue); ImGui.Checkbox(Language.Options_Tabs_ShowTimestamps, ref tab.DisplayTimestamp); + ImGui.Checkbox(Language.Options_Tabs_PopOut, ref tab.PopOut); + if (tab.PopOut) { + ImGui.Checkbox(Language.Options_Tabs_IndependentOpacity, ref tab.IndependentOpacity); + if (tab.IndependentOpacity) { + ImGuiUtil.DragFloatVertical(Language.Options_Tabs_Opacity, ref tab.Opacity, 0.1f, 0f, 100f); + } + } if (ImGuiUtil.BeginComboVertical(Language.Options_Tabs_UnreadMode, tab.UnreadMode.Name())) { foreach (var mode in Enum.GetValues()) {