Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep original lastRect to fix some drawing glitches (e.g. in ErrorRow) #34

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion YAFCui/ImGui/ImGuiBuilding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private void BuildGui(float width)
rebuildRequested = false;
ClearDrawCommandList();
DoGui(ImGuiAction.Build);
contentSize = new Vector2(lastRect.Right, lastRect.Bottom);
contentSize = new Vector2(lastContentRect.Width, lastContentRect.Height);
if (boxColor != SchemeColor.None)
{
var rect = new Rect(default, contentSize);
Expand Down
5 changes: 3 additions & 2 deletions YAFCui/ImGui/ImGuiLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public partial class ImGui
{
private CopyableState state;
public Rect lastRect { get; set; }
public Rect lastContentRect { get; set; }
public float width => state.right - state.left;
public Rect statePosition => new Rect(state.left, state.top, width, 0f);
public ref RectAllocator allocator => ref state.allocator;
Expand Down Expand Up @@ -242,8 +243,8 @@ public void Dispose()
rect.Height += padding.top + padding.bottom;
if (hasContent)
{
gui.state.EncapsulateRect(rect);
gui.lastRect = rect;
gui.lastRect = gui.state.EncapsulateRect(rect);
gui.lastContentRect = rect;
}
else gui.lastRect = default;
}
Expand Down
8 changes: 4 additions & 4 deletions YAFCui/ImGui/ScrollArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ public ScrollArea(float height, GuiBuilder builder, Padding padding = default, b
}

protected override void BuildContents(ImGui gui) => builder(gui);
public void Rebuild() => contents.Rebuild();
public void Rebuild() => RebuildContents();
}

public class VirtualScrollList<TData> : ScrollAreaBase
Expand All @@ -240,7 +240,7 @@ public float spacing
set
{
_spacing = value;
contents.Rebuild();
RebuildContents();
}
}

Expand All @@ -252,7 +252,7 @@ public IReadOnlyList<TData> data
set
{
_data = value ?? Array.Empty<TData>();
contents.Rebuild();
RebuildContents();
}
}

Expand All @@ -275,7 +275,7 @@ public override Vector2 scroll2d
base.scroll2d = value;
var row = CalcFirstBlock();
if (row != firstVisibleBlock)
contents.Rebuild();
RebuildContents();
}
}

Expand Down