Skip to content

Commit

Permalink
Ensure framebuffer resizes one dimension at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed May 29, 2022
1 parent 363e4c5 commit f4f8d53
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
24 changes: 24 additions & 0 deletions Bonsai.Vision.Design/VisualizerCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public partial class VisualizerCanvas : UserControl
{
bool loaded;
bool disposed;
bool resizing;
bool resizeWidth;
static readonly object syncRoot = string.Intern("A1105A50-BBB0-4EC6-B8B2-B5EF38A9CC3E");

/// <summary>
Expand Down Expand Up @@ -81,10 +83,32 @@ private void canvas_Paint(object sender, PaintEventArgs e)
lock (syncRoot)
{
canvas.SwapBuffers();
if (resizing)
{
resizing = false;
resizeWidth = !resizeWidth;
if (canvas.Size != Size)
{
OnResize(EventArgs.Empty);
}
}
}
OnSwapBuffers(e);
}

protected override void OnResize(EventArgs e)
{
var partialResize = canvas.Width == Width || canvas.Height == Height;
if (!loaded || partialResize) canvas.Size = Size;
else
{
if (resizeWidth) canvas.Size = new Size(Width, canvas.Height);
else canvas.Size = new Size(canvas.Width, Height);
resizing = true;
}
base.OnResize(e);
}

/// <summary>
/// Raises the <see cref="RenderFrame"/> event.
/// </summary>
Expand Down
1 change: 0 additions & 1 deletion Bonsai.Vision.Design/VisualizerCanvas.designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f4f8d53

Please sign in to comment.