public bool ReorderTagElement(ITimelineElement element, int direction) { if (direction == 0 || element == null) { return(false); } TagAnnotation tag = element.Object as TagAnnotation; if (tag == null) { return(false); } int currentIndex = m_TaggedClip.Tags.IndexOf(tag); int newIndex = currentIndex + direction; if (newIndex < 0 || newIndex > m_TaggedClip.Tags.Count - 1) { return(false); } Undo.RecordObject(m_TaggedClip.Asset, "Reorder Tag"); m_TaggedClip.Tags.Remove(tag); m_TaggedClip.Tags.Insert(newIndex, tag); Insert(newIndex, (element as VisualElement)); return(true); }
protected void AddElement(ITimelineElement timelineElement) { if (timelineElement is VisualElement element) { Add(element); } }
public bool ReorderTimelineElements(ITimelineElement element, int direction) { if (m_AnnotationsTrack.ReorderTagElement(element, direction)) { SendTagModified(); return(true); } return(false); }
public void Select(ITimelineElement selection, bool multi) { if (!multi) { ClearSelection(); SelectionContainer.Clear(); } SelectionContainer.Select(selection, TaggedClip); Selection.activeObject = SelectionContainer; }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); e.Graphics.Clear(this.BackColor); int w = this.Width; int h = this.Height; if (w < h) { e.Graphics.FillRectangle(backgroundBrush, new Rectangle(backgroundCursorHeight, leftMargin, h, effectiveWidth)); w = this.Height; h = this.Width; } else { e.Graphics.FillRectangle(backgroundBrush, new Rectangle(leftMargin, backgroundCursorHeight, effectiveWidth, h)); } w = (int)Math.Round(w * zoom); foreach (KeyValuePair <float, object> evts in events) { float f = evts.Key; object ev = evts.Value; string n; if (ev is ITimelineElement) { ITimelineElement t = ev as ITimelineElement; n = t.Name; if (t.Length > 0) { SolidBrush evb = selected.Value == ev ? selectedBrush : eventBrush; Color org = evb.Color; evb.Color = Color.FromArgb(30, evb.Color); e.Graphics.FillRectangle(evb, new RectangleF( MakePoint((int)Math.Round(f * effectiveWidth + leftMargin), h - smallMeasureHeight), new SizeF(MakePoint(t.Length / Timespan * effectiveWidth, h)) )); evb.Color = org; } } else { n = ev.ToString(); } Pen evp = selected.Value == ev ? selectedPen : eventPen; e.Graphics.DrawLine(evp, MakePoint((int)Math.Round(f * effectiveWidth + leftMargin), h), MakePoint((int)Math.Round(f * effectiveWidth + leftMargin), eventCursorHeight)); e.Graphics.DrawString(n, font, selected.Value == ev ? selectedBrush : eventBrush, MakePoint(f * effectiveWidth + leftMargin, eventCursorHeight)); } for (int a = leftMargin; a <= effectiveWidth + leftMargin; a += measureDistance) { bool bigline = (a - leftMargin) % (measureDistance * 10) == 0; bool medline = (a - leftMargin) % (measureDistance * 2) == 0; Point pt = MakePoint(a, bigline ? largeMeasureHeight : (medline ? medMeasureHeight : smallMeasureHeight)); PointF ptxt = MakePoint((float)a, 3 + (bigline ? largeMeasureHeight : (medline ? medMeasureHeight : smallMeasureHeight))); e.Graphics.DrawLine(bigline ? primaryPen : secondaryPen, MakePoint(a, 0), pt); if (bigline) { e.Graphics.DrawString((((float)a - leftMargin) / effectiveWidth).ToString("0.###"), font, primaryBrush, ptxt, drawFormat); } else if (medline) { e.Graphics.DrawString((((float)a - leftMargin) / effectiveWidth * 100 % 10).ToString("#"), fontSmall, primaryBrush, ptxt, drawFormat); } } if (cursor && mouseLoc != Int32.MinValue) { e.Graphics.DrawLine(highlightPen, MakePoint(mouseLoc, 0), MakePoint(mouseLoc, h)); } if (playback.Enabled) { e.Graphics.DrawLine(playPen, MakePoint((int)Math.Round(PlaybackTime / 1000.0f / timespan * effectiveWidth) + leftMargin, 0), MakePoint((int)Math.Round(PlaybackTime / 1000.0f / timespan * effectiveWidth) + leftMargin, h)); } }