Skip to content

Commit

Permalink
Give columns more space when initially sized
Browse files Browse the repository at this point in the history
They just looked too cramped by default.
  • Loading branch information
edwardrowe committed Apr 1, 2020
1 parent 5e5a49b commit 878a3d9
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -986,21 +986,23 @@ public void ResizeForContents(Rect scrollRect, PreviewPanelContents previewConte
this.firstColumnContentWidth = previewContents.LongestOriginalNameWidth;
this.secondColumnContentWidth = previewContents.LongestNewNameWidth;

const float maxStartingWidth = 400.0f;
// Don't let columns be so big we can't see all of them.
float maxStartingWidth = scrollRect.width * 0.3f;
const float initialContentPadding = 10;

if (forceResizeToFitContents)
{
// Try to make column 25% of the window, unless that would be bigger than it needs to be to fit the content
var desiredWidth = Mathf.Min(scrollRect.width * 0.25f, previewContents.LongestOriginalNameWidth + 5);
// Use 20% of the window unless we need more to show the contents and can have more.
var desiredWidth = Mathf.Max(scrollRect.width * 0.20f, previewContents.LongestOriginalNameWidth + initialContentPadding);
this.FirstColumnWidth = Mathf.Clamp(desiredWidth, this.MinimumColumnWidth, maxStartingWidth);
}

if (!shouldShowThirdColumn || forceResizeToFitContents)
{
if (shouldShowThirdColumn)
{
// Try to make column 25% of the window, unless that would be bigger than it needs to be to fit the content
var desiredWidth = Mathf.Min(scrollRect.width * 0.25f, previewContents.LongestNewNameWidth + 5);
// Use 20% of the window unless we need more to show the contents and can have more.
var desiredWidth = Mathf.Max(scrollRect.width * 0.20f, previewContents.LongestNewNameWidth + initialContentPadding);
this.secondColumnWidth = Mathf.Clamp(desiredWidth, this.MinimumColumnWidth, maxStartingWidth);
}
else
Expand Down

0 comments on commit 878a3d9

Please sign in to comment.