()
| 1603 | |
| 1604 | /// <inheritdoc /> |
| 1605 | public override void UpdateKeyframes() |
| 1606 | { |
| 1607 | if (_points.Count == 0) |
| 1608 | { |
| 1609 | // No keyframes |
| 1610 | _contents.Bounds = Rectangle.Empty; |
| 1611 | return; |
| 1612 | } |
| 1613 | |
| 1614 | var wasLocked = _mainPanel.IsLayoutLocked; |
| 1615 | _mainPanel.IsLayoutLocked = true; |
| 1616 | |
| 1617 | // Place keyframes |
| 1618 | Rectangle curveContentAreaBounds = _mainPanel.GetClientArea(); |
| 1619 | var viewScale = ViewScale; |
| 1620 | for (int i = 0; i < _points.Count; i++) |
| 1621 | { |
| 1622 | var p = _points[i]; |
| 1623 | var k = _keyframes[p.Index]; |
| 1624 | |
| 1625 | var location = GetKeyframePoint(ref k, p.Component); |
| 1626 | var point = new Float2 |
| 1627 | ( |
| 1628 | location.X * UnitsPerSecond - p.Width * 0.5f, |
| 1629 | location.Y * -UnitsPerSecond - p.Height * 0.5f + curveContentAreaBounds.Height |
| 1630 | ); |
| 1631 | |
| 1632 | if (_showCollapsed) |
| 1633 | { |
| 1634 | point.Y = 1.0f; |
| 1635 | p.Size = new Float2(KeyframesSize.X / viewScale.X, Height - 2.0f); |
| 1636 | p.Visible = p.Component == 0; |
| 1637 | } |
| 1638 | else |
| 1639 | { |
| 1640 | p.Size = KeyframesSize / viewScale; |
| 1641 | p.Visible = true; |
| 1642 | } |
| 1643 | p.Location = point; |
| 1644 | } |
| 1645 | |
| 1646 | // Calculate bounds |
| 1647 | var bounds = _points[0].Bounds; |
| 1648 | for (var i = 1; i < _points.Count; i++) |
| 1649 | bounds = Rectangle.Union(bounds, _points[i].Bounds); |
| 1650 | |
| 1651 | // Adjust contents bounds to fill the curve area |
| 1652 | if (EnablePanning != UseMode.Off || !ShowCollapsed) |
| 1653 | { |
| 1654 | bounds.Width = Mathf.Max(bounds.Width, 1.0f); |
| 1655 | bounds.Height = Mathf.Max(bounds.Height, 1.0f); |
| 1656 | bounds.Location = ApplyUseModeMask(EnablePanning, bounds.Location, _contents.Location); |
| 1657 | bounds.Size = ApplyUseModeMask(EnablePanning, bounds.Size, _contents.Size); |
| 1658 | if (!_contents._isMovingSelection) |
| 1659 | _contents.Bounds = bounds; |
| 1660 | } |
| 1661 | else if (_contents.Bounds == Rectangle.Empty) |
| 1662 | { |
no test coverage detected