public IEnumerator <object> Task() { while (true) { if (Document.Current.Animation.IsCompound && Timeline.Instance.Grid.RootWidget.Input.WasMouseReleased(1) && Timeline.Instance.Grid.IsMouseOverRow()) { var c = Timeline.Instance.Grid.CellUnderMouse(); Document.Current.History.DoTransaction(() => { Operations.SetCurrentColumn.Perform(c.X); Core.Operations.ClearRowSelection.Perform(); Core.Operations.SelectRow.Perform(Document.Current.Rows[c.Y]); }); var menu = new Menu { new Command("Add", () => AddAnimationClip.Perform(c)) { Enabled = AddAnimationClip.IsEnabled() }, new Command("Delete", () => DeleteSelectedAnimationClips.Perform()) { Enabled = DeleteSelectedAnimationClips.IsEnabled() }, new Command("Split", () => SplitAnimationClip.Perform(c)) { Enabled = SplitAnimationClip.IsEnabled(c) }, }; menu.Popup(); } yield return(null); } }
public void Handle(List <string> files) { var grid = Timeline.Instance.Grid; var rowLocationUnderMouseOnFilesDrop = SelectAndDragRowsProcessor.MouseToRowLocation(grid.RootWidget.Input.MousePosition); var handled = new List <string>(); var cellUnderMouseOnFilesDrop = grid.CellUnderMouse(); var animateTextureCellOffset = 0; using (Document.Current.History.BeginTransaction()) { foreach (var file in files.ToList()) { if (Document.Current.Animation.IsCompound) { try { // Dirty hack: using a file drag&drop mechanics for dropping animation clips on the grid. var decodedAnimationId = Encoding.UTF8.GetString(Convert.FromBase64String(file)); AddAnimationClip.Perform( new IntVector2( cellUnderMouseOnFilesDrop.X + animateTextureCellOffset, cellUnderMouseOnFilesDrop.Y), decodedAnimationId); return; } catch { } } if (!Utils.ExtractAssetPathOrShowAlert(file, out var assetPath, out var assetType)) { continue; } switch (assetType) { case ".png": { if (Document.Current.Rows.Count == 0) { continue; } var widget = Document.Current.Rows[cellUnderMouseOnFilesDrop.Y].Components.Get <NodeRow>()?.Node as Widget; if (widget == null) { continue; } var key = new Keyframe <ITexture> { Frame = cellUnderMouseOnFilesDrop.X + animateTextureCellOffset, Value = new SerializableTexture(assetPath), Function = KeyFunction.Steep, }; SetKeyframe.Perform(widget, nameof(Widget.Texture), Document.Current.AnimationId, key); animateTextureCellOffset++; break; } case ".ogg": { var node = CreateNode.Perform(typeof(Audio)); if (rowLocationUnderMouseOnFilesDrop.HasValue) { var location = rowLocationUnderMouseOnFilesDrop.Value; var row = Document.Current.Rows.FirstOrDefault(r => r.Components.Get <Core.Components.NodeRow>()?.Node == node); if (row != null) { if (location.Index >= row.Index) { location.Index++; } SelectAndDragRowsProcessor.Probers.Any(p => p.Probe(row, location)); } } var sample = new SerializableSample(assetPath); SetProperty.Perform(node, nameof(Audio.Sample), sample); SetProperty.Perform(node, nameof(Node.Id), assetPath); SetProperty.Perform(node, nameof(Audio.Volume), 1); var key = new Keyframe <AudioAction> { Frame = cellUnderMouseOnFilesDrop.X, Value = AudioAction.Play }; SetKeyframe.Perform(node, nameof(Audio.Action), Document.Current.AnimationId, key); break; } } files.Remove(file); } Document.Current.History.CommitTransaction(); } }