From 58a6567f5a72d812d841d0326ebc161ef663475a Mon Sep 17 00:00:00 2001 From: Infi Date: Sat, 13 Jul 2024 09:18:40 +0200 Subject: [PATCH] dynamic fix for #85 --- ChatTwo/ChatTwo.csproj | 2 +- ChatTwo/Ui/ChatLogWindow.cs | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ChatTwo/ChatTwo.csproj b/ChatTwo/ChatTwo.csproj index fa88e52..a208d4e 100755 --- a/ChatTwo/ChatTwo.csproj +++ b/ChatTwo/ChatTwo.csproj @@ -1,6 +1,6 @@ - 1.27.5 + 1.27.6 net8.0-windows enable enable diff --git a/ChatTwo/Ui/ChatLogWindow.cs b/ChatTwo/Ui/ChatLogWindow.cs index 74ac4dd..3a26655 100644 --- a/ChatTwo/Ui/ChatLogWindow.cs +++ b/ChatTwo/Ui/ChatLogWindow.cs @@ -902,11 +902,12 @@ public sealed class ChatLogWindow : Window private void DrawLogTableStyle(Tab tab, PayloadHandler handler, bool switchedTab) { + var compact = Plugin.Config.MoreCompactPretty; var oldItemSpacing = ImGui.GetStyle().ItemSpacing; var oldCellPadding = ImGui.GetStyle().CellPadding; using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, Vector2.Zero)) - using (ImRaii.PushStyle(ImGuiStyleVar.CellPadding, oldCellPadding with { Y = 0 }, Plugin.Config.MoreCompactPretty)) + using (ImRaii.PushStyle(ImGuiStyleVar.CellPadding, oldCellPadding with { Y = 0 }, compact)) { using var table = ImRaii.Table("timestamp-table", 2, ImGuiTableFlags.PreciseWidths); if (!table.Success) @@ -915,12 +916,14 @@ public sealed class ChatLogWindow : Window ImGui.TableSetupColumn("timestamps", ImGuiTableColumnFlags.WidthFixed); ImGui.TableSetupColumn("messages", ImGuiTableColumnFlags.WidthStretch); - DrawMessages(tab, handler, true, Plugin.Config.MoreCompactPretty, oldCellPadding.Y); + DrawMessages(tab, handler, true, compact, oldCellPadding.Y); using (ImRaii.PushStyle(ImGuiStyleVar.ItemSpacing, oldItemSpacing)) using (ImRaii.PushStyle(ImGuiStyleVar.CellPadding, oldCellPadding)) { - if (switchedTab || ImGui.GetScrollY() >= ImGui.GetScrollMaxY()) + // Custom styles can have cellPadding that go above 4, which GetScrollY isn't respecting + var cellPaddingOffset = !compact && oldCellPadding.Y > 4f ? oldCellPadding.Y - 4f : 0f; + if (switchedTab || ImGui.GetScrollY() + cellPaddingOffset >= ImGui.GetScrollMaxY()) ImGui.SetScrollHereY(1f); handler.Draw();