Add new preview position: tooltip

This commit is contained in:
Infi
2024-05-19 17:16:36 +02:00
parent 51db04a5f5
commit a18861ea87
4 changed files with 24 additions and 3 deletions
+2
View File
@@ -247,6 +247,7 @@ internal enum PreviewPosition
Inside,
Top,
Bottom,
Tooltip,
}
internal static class PreviewPositionExt
@@ -257,6 +258,7 @@ internal static class PreviewPositionExt
PreviewPosition.Inside => Language.Options_Preview_Inside,
PreviewPosition.Top => Language.Options_Preview_Top,
PreviewPosition.Bottom => Language.Options_Preview_Bottom,
PreviewPosition.Tooltip => Language.Options_Preview_Tooltip,
_ => throw new ArgumentOutOfRangeException(nameof(position), position, null),
};
}
+9
View File
@@ -2444,6 +2444,15 @@ namespace ChatTwo.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Tooltip.
/// </summary>
internal static string Options_Preview_Tooltip {
get {
return ResourceManager.GetString("Options_Preview_Tooltip", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Top.
/// </summary>
+3
View File
@@ -1072,4 +1072,7 @@
<data name="Options_Preview_Header" xml:space="preserve">
<value>Text Preview:</value>
</data>
<data name="Options_Preview_Tooltip" xml:space="preserve">
<value>Tooltip</value>
</data>
</root>
+10 -3
View File
@@ -517,8 +517,7 @@ public sealed class ChatLogWindow : Window
LastViewport = ImGui.GetWindowViewport().NativePtr;
WasDocked = ImGui.IsWindowDocked();
var drawPreview = Plugin.Config.PreviewPosition is PreviewPosition.Inside;
if (drawPreview)
if (Plugin.Config.PreviewPosition is PreviewPosition.Inside or PreviewPosition.Tooltip)
Plugin.InputPreview.CalculatePreview();
var currentTab = Plugin.Config.SidebarTabView ? DrawTabSidebar() : DrawTabBar();
@@ -527,7 +526,7 @@ public sealed class ChatLogWindow : Window
if (currentTab > -1 && currentTab < Plugin.Config.Tabs.Count)
activeTab = Plugin.Config.Tabs[currentTab];
if (drawPreview)
if (Plugin.Config.PreviewPosition is PreviewPosition.Inside)
Plugin.InputPreview.DrawPreview();
using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero))
@@ -702,6 +701,14 @@ public sealed class ChatLogWindow : Window
ImGui.InputTextWithHint("##chat2-input", isChatEnabled ? "": Language.ChatLog_DisabledInput, ref Chat, 500, flags, Callback);
}
if (Plugin.Config.PreviewPosition is PreviewPosition.Tooltip && !string.IsNullOrEmpty(Chat) && ImGui.IsItemHovered())
{
ImGui.SetNextWindowSize(new Vector2(500 * ImGuiHelpers.GlobalScale, -1));
using var tooltip = ImRaii.Tooltip();
if (tooltip)
Plugin.InputPreview.DrawPreview();
}
if (ImGui.IsItemDeactivated())
{
if (ImGui.IsKeyDown(ImGuiKey.Escape))