From d485f5ea1fad1f952cff6797d3f7308d3fed3e98 Mon Sep 17 00:00:00 2001 From: JonKazama-Hellion Date: Tue, 5 May 2026 19:44:37 +0200 Subject: [PATCH] feat(messages): card-row default render with compact-density opt-out --- HellionChat/Ui/ChatLogWindow.cs | 64 ++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/HellionChat/Ui/ChatLogWindow.cs b/HellionChat/Ui/ChatLogWindow.cs index 1c826cf..9a83e00 100644 --- a/HellionChat/Ui/ChatLogWindow.cs +++ b/HellionChat/Ui/ChatLogWindow.cs @@ -1323,17 +1323,63 @@ public sealed class ChatLogWindow : Window ImGui.TableNextColumn(); var lineWidth = ImGui.GetContentRegionAvail().X; - if (message.Sender.Count > 0) - { - DrawChunks(message.Sender, true, handler, lineWidth); - ImGui.SameLine(); - } - // We need to draw something otherwise the item visibility check below won't work. - if (message.Content.Count == 0) - DrawChunks([new TextChunk(ChunkSource.Content, null, " ")], true, handler, lineWidth); + // v1.2.0 — Card-Rows als Default, Compact-Density als Opt-Out. + // Card-Mode: Sender-Header in Channel-Color auf eigener Zeile, + // dann Body, dann subtile Border-Bottom als Card-Trenner. + // Compact-Mode: bisheriges Verhalten — Sender + Space + Content + // auf einer Zeile via SameLine. + var useCard = !Plugin.Config.UseCompactDensity; + if (useCard) + { + if (message.Sender.Count > 0) + { + var theme = Plugin.ThemeRegistry.Active; + var senderColor = Plugin.Functions.Chat.GetChannelColor(message.Code.Type) + ?? theme.Colors.TextPrimary; + using (ImRaii.PushColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(senderColor))) + { + DrawChunks(message.Sender, true, handler, lineWidth); + } + // KEIN SameLine — Body landet auf eigener Zeile. + } + + // We need to draw something otherwise the item visibility check below won't work. + if (message.Content.Count == 0) + DrawChunks([new TextChunk(ChunkSource.Content, null, " ")], true, handler, lineWidth); + else + DrawChunks(message.Content, true, handler, lineWidth); + + // Subtile Border-Bottom als Card-Trenner. Border-Farbe mit + // reduzierter Alpha (RGBA → 0x33) für dezente Trennung. + { + var theme = Plugin.ThemeRegistry.Active; + var rowEndY = ImGui.GetCursorScreenPos().Y; + var winLeft = ImGui.GetWindowPos().X; + var winRight = winLeft + ImGui.GetWindowSize().X; + var borderRgba = (theme.Colors.Border & 0xFFFFFF00u) | 0x33u; + ImGui.GetWindowDrawList().AddLine( + new Vector2(winLeft + 4, rowEndY - 1), + new Vector2(winRight - 4, rowEndY - 1), + ColourUtil.RgbaToAbgr(borderRgba), + 1f); + ImGui.Dummy(new Vector2(0, 2)); + } + } else - DrawChunks(message.Content, true, handler, lineWidth); + { + if (message.Sender.Count > 0) + { + DrawChunks(message.Sender, true, handler, lineWidth); + ImGui.SameLine(); + } + + // We need to draw something otherwise the item visibility check below won't work. + if (message.Content.Count == 0) + DrawChunks([new TextChunk(ChunkSource.Content, null, " ")], true, handler, lineWidth); + else + DrawChunks(message.Content, true, handler, lineWidth); + } message.IsVisible[tab.Identifier] = ImGui.IsItemVisible(); }