feat: add popped-out tab opacity

This commit is contained in:
Anna 2022-02-19 16:09:32 -05:00
parent ab8bf471b5
commit e606581d40
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
6 changed files with 77 additions and 1 deletions

View File

@ -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,
};
}
}

View File

@ -807,6 +807,15 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Show title bar for popped-out tabs.
/// </summary>
internal static string Options_ShowPopOutTitleBar_Name {
get {
return ResourceManager.GetString("Options_ShowPopOutTitleBar_Name", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show title bar for chat.
/// </summary>
@ -915,6 +924,15 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Use different opacity than main window.
/// </summary>
internal static string Options_Tabs_IndependentOpacity {
get {
return ResourceManager.GetString("Options_Tabs_IndependentOpacity", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Input channel.
/// </summary>
@ -969,6 +987,24 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Opacity.
/// </summary>
internal static string Options_Tabs_Opacity {
get {
return ResourceManager.GetString("Options_Tabs_Opacity", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Display in separate window.
/// </summary>
internal static string Options_Tabs_PopOut {
get {
return ResourceManager.GetString("Options_Tabs_PopOut", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Preset: {0}.
/// </summary>

View File

@ -482,4 +482,16 @@
<data name="Options_HideSameTimestamps_Description" xml:space="preserve">
<value>Hide timestamps when previous messages have the same timestamp.</value>
</data>
<data name="Options_ShowPopOutTitleBar_Name" xml:space="preserve">
<value>Show title bar for popped-out tabs</value>
</data>
<data name="Options_Tabs_PopOut" xml:space="preserve">
<value>Display in separate window</value>
</data>
<data name="Options_Tabs_IndependentOpacity" xml:space="preserve">
<value>Use different opacity than main window</value>
</data>
<data name="Options_Tabs_Opacity" xml:space="preserve">
<value>Opacity</value>
</data>
</root>

View File

@ -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();

View File

@ -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();
}
}

View File

@ -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<UnreadMode>()) {