Skip to content

Commit

Permalink
Ensure webview resizes with container width
Browse files Browse the repository at this point in the history
  • Loading branch information
glopesdev committed May 16, 2023
1 parent 896f255 commit 7f5c4d4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Bonsai.Editor/GraphView/WorkflowEditorControl.Designer.cs

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

22 changes: 22 additions & 0 deletions Bonsai.Editor/GraphView/WorkflowEditorControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public void ExpandWebView(string label)
{
browserLabel.Text = label;
splitContainer.Panel1Collapsed = false;
EnsureWebViewSize();
}

public void CollapseWebView()
Expand Down Expand Up @@ -264,6 +265,12 @@ protected override void OnLoad(EventArgs e)
base.OnLoad(e);
}

protected override void OnSizeChanged(EventArgs e)
{
EnsureWebViewSize();
base.OnSizeChanged(e);
}

protected override void OnKeyDown(KeyEventArgs e)
{
editorService.OnKeyDown(e);
Expand Down Expand Up @@ -437,6 +444,21 @@ protected override void ScaleControl(SizeF factor, BoundsSpecified specified)
var adjustV = displayX - marginTop - displayX / 2 - 1;
adjustMargin = new Padding(adjustH, adjustV, adjustH, adjustH);
}
splitContainer.SplitterDistance = (int)Math.Round(splitContainer.SplitterDistance * factor.Width);
splitContainer.Panel1MinSize = splitContainer.SplitterDistance / 2;
splitContainer.FixedPanel = FixedPanel.Panel1;
}

private void EnsureWebViewSize()
{
if (splitContainer.FixedPanel != FixedPanel.None)
{
if (Width < 4 * splitContainer.Panel1MinSize)
{
splitContainer.SplitterDistance = Width / 2;
}
else splitContainer.SplitterDistance = 2 * splitContainer.Panel1MinSize - splitContainer.SplitterWidth;
}
}

private void InitializeTheme(TabPage tabPage)
Expand Down

0 comments on commit 7f5c4d4

Please sign in to comment.