Skip to content

Commit

Permalink
Shrink operator if possible (when changing data type) (#6668)
Browse files Browse the repository at this point in the history
* Shrink operator if possible (when changing data type)

* Updated changelog

* Reset minwidth when the operator is expanded (so that it can shrink if possible)
  • Loading branch information
julienamsellem authored and julienf-unity committed Feb 3, 2022
1 parent ff04f21 commit 901a370
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- No more exception raised when selecting all nodes with CTRL+A and then deleting them
- Forbid pasting a subgraph in the same subgraph [Case 1364480](https://issuetracker.unity3d.com/product/unity/issues/guid/1364480/)
- Particle Strip without lifetime do not die when Alive is set to false. [Case 1376278](https://issuetracker.unity3d.com/product/unity/issues/guid/1376278/)
- Resize custom operator (multiply, add...) to the minimum size when changing input types

## [12.1.4] - 2021-12-07
### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void OnEdit()
if (m_EditContainer.parent != null)
{
m_EditContainer.RemoveFromHierarchy();
style.minWidth = 0;
}
else
{
Expand Down Expand Up @@ -212,20 +213,22 @@ public override void RefreshLayout()

ApplyWidths(labelWidth, controlWidth);

// Do not let the UI reduce in width so that collapse button does not move
var newMinWidth = resolvedStyle.width;
if (resolvedStyle.minWidth.value < newMinWidth)
// To prevent width to change between expanded and collapsed state
// we set the minwidth to actual width before collapse, and reset to zero when expand
// so that the expand/collapse button does not move
if (!expanded)
{
style.minWidth = newMinWidth;
}
}
else
{
if (resolvedStyle.minWidth != 0f)
{
style.minWidth = 0f;
var newMinWidth = resolvedStyle.width;
if (resolvedStyle.minWidth.value < newMinWidth)
{
style.minWidth = newMinWidth;
}

return;
}
}

style.minWidth = 0f;
}
}
}

0 comments on commit 901a370

Please sign in to comment.