Fix issues arise through shared height
This commit is contained in:
@@ -201,6 +201,9 @@ internal class Tab
|
||||
[NonSerialized]
|
||||
public InputChannel? PreviousChannel;
|
||||
|
||||
[NonSerialized]
|
||||
public Guid Identifier = Guid.NewGuid();
|
||||
|
||||
~Tab() { MessagesMutex.Dispose(); }
|
||||
|
||||
internal bool Contains(Message message) {
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ internal class Message {
|
||||
|
||||
// Not stored in the database:
|
||||
internal int Hash { get; }
|
||||
internal float? Height { get; set; }
|
||||
internal bool IsVisible { get; set; }
|
||||
internal Dictionary<Guid, float?> Height { get; } = new();
|
||||
internal Dictionary<Guid, bool> IsVisible { get; } = new();
|
||||
|
||||
internal Message(ulong receiver, ChatCode code, List<Chunk> sender, List<Chunk> content, SeString senderSource, SeString contentSource) {
|
||||
Receiver = receiver;
|
||||
|
||||
@@ -895,8 +895,8 @@ public sealed class ChatLogWindow : Window
|
||||
var message = tab.Messages[i];
|
||||
if (reset)
|
||||
{
|
||||
message.Height = null;
|
||||
message.IsVisible = false;
|
||||
message.Height[tab.Identifier] = null;
|
||||
message.IsVisible[tab.Identifier] = false;
|
||||
}
|
||||
|
||||
if (Plugin.Config.CollapseDuplicateMessages)
|
||||
@@ -933,7 +933,9 @@ public sealed class ChatLogWindow : Window
|
||||
|
||||
// message has rendered once
|
||||
// message isn't visible, so render dummy
|
||||
if (message is { Height: not null, IsVisible: false })
|
||||
message.Height.TryGetValue(tab.Identifier, out var height);
|
||||
message.IsVisible.TryGetValue(tab.Identifier, out var visible);
|
||||
if (height != null && !visible)
|
||||
{
|
||||
var beforeDummy = ImGui.GetCursorPos();
|
||||
|
||||
@@ -941,10 +943,10 @@ public sealed class ChatLogWindow : Window
|
||||
if (isTable)
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
ImGui.Dummy(new Vector2(10f, message.Height.Value));
|
||||
message.IsVisible = ImGui.IsItemVisible();
|
||||
ImGui.Dummy(new Vector2(10f, height.Value));
|
||||
message.IsVisible[tab.Identifier] = ImGui.IsItemVisible();
|
||||
|
||||
if (message.IsVisible)
|
||||
if (message.IsVisible[tab.Identifier])
|
||||
{
|
||||
if (isTable)
|
||||
ImGui.TableSetColumnIndex(0);
|
||||
@@ -993,16 +995,16 @@ public sealed class ChatLogWindow : Window
|
||||
DrawChunks(message.Content, true, handler, lineWidth);
|
||||
|
||||
var afterDraw = ImGui.GetCursorScreenPos();
|
||||
message.Height = ImGui.GetCursorPosY() - lastPos;
|
||||
message.Height[tab.Identifier] = ImGui.GetCursorPosY() - lastPos;
|
||||
if (isTable && !moreCompact)
|
||||
{
|
||||
message.Height -= oldCellPaddingY * 2;
|
||||
message.Height[tab.Identifier] -= oldCellPaddingY * 2;
|
||||
beforeDraw.Y += oldCellPaddingY;
|
||||
afterDraw.Y -= oldCellPaddingY;
|
||||
}
|
||||
|
||||
lastPos = ImGui.GetCursorPosY();
|
||||
message.IsVisible = ImGui.IsRectVisible(beforeDraw, afterDraw);
|
||||
message.IsVisible[tab.Identifier] = ImGui.IsRectVisible(beforeDraw, afterDraw);
|
||||
}
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user