private void Render(Widget widget) { widget.PrepareRendererState(); Renderer.DrawRect(Vector2.Zero, widget.ContentSize, ColorTheme.Current.TimelineGrid.PropertyRowBackground); var colorIndex = PropertyAttributes <TangerineKeyframeColorAttribute> .Get(animator.Animable.GetType(), animator.TargetPropertyPath)?.ColorIndex ?? 0; var color = KeyframePalette.Colors[colorIndex]; for (int i = 0; i < animator.ReadonlyKeys.Count; i++) { var key = animator.ReadonlyKeys[i]; var a = new Vector2(key.Frame * TimelineMetrics.ColWidth + 1, 0); var b = a + new Vector2(TimelineMetrics.ColWidth - 1, widget.Height); KeyframeFigure.Render(a, b, color, key.Function); } }
public void RenderCells(Widget widget) { widget.PrepareRendererState(); foreach (var kv in cells) { int column = kv.Key; var cell = kv.Value; var a = new Vector2(column * TimelineMetrics.ColWidth + 1, 0); var stripHeight = widget.Height / cell.StripCount; if (cell.StripCount <= 2) { int color1 = -1; int color2 = -1; for (int j = 0; j < cell.Strips.Count; j++) { if (cell.Strips[j]) { if (color1 == -1) { color1 = j; } else { color2 = j; } } } if (color2 == -1) { color2 = color1; } var b = a + new Vector2(TimelineMetrics.ColWidth - 1, stripHeight); KeyframeFigure.Render(a, b, KeyframePalette.Colors[color1], cell.Func1); if (cell.StripCount == 2) { a.Y += stripHeight; b.Y += stripHeight; KeyframeFigure.Render(a, b, KeyframePalette.Colors[color2], cell.Func2); } } else { // Draw strips var drawnStripCount = 0; for (var colorIndex = 0; colorIndex < cell.Strips.Count; colorIndex++) { if (cell.Strips[colorIndex]) { var b = a + new Vector2(TimelineMetrics.ColWidth - 1, stripHeight); Renderer.DrawRect(a, b, KeyframePalette.Colors[colorIndex]); drawnStripCount++; if (drawnStripCount == cell.StripCount) { break; } a.Y += stripHeight; } } // Strips of the same color if (drawnStripCount < cell.StripCount) { int colorIndex; for (colorIndex = 0; colorIndex < cell.Strips.Count; colorIndex++) { if (cell.Strips[colorIndex]) { break; } } for (var j = drawnStripCount; j != cell.StripCount; j++) { var b = a + new Vector2(TimelineMetrics.ColWidth - 1, stripHeight); Renderer.DrawRect(a, b, KeyframePalette.Colors[colorIndex]); a.Y += stripHeight; } } } } }