public override void ExecuteTransaction() { var nodes = Document.Current?.SelectedNodes().Editable().ToList(); if (nodes.Count != 1) { AlertDialog.Show("Please, select a single node"); return; } if (!(nodes[0] is Widget w && NodeCompositionValidator.CanHaveChildren(w.GetType()))) { AlertDialog.Show($"Can't export {nodes[0].GetType()}"); return; } Export(w); }
public static bool Perform(Node container, bool selectFirstNode = true) { if (!NodeCompositionValidator.CanHaveChildren(container.GetType())) { return(false); } if (!string.IsNullOrEmpty(container.ContentsPath) && Project.Current.DocumentExists(container.ContentsPath)) { OpenExternalScene(container.ContentsPath); } else { ChangeContainer(container, selectFirstNode); SetProperty.Perform(container, nameof(Node.TangerineFlags), container.TangerineFlags | TangerineFlags.DisplayContent, isChangingDocument: false); } return(true); }
public static bool Perform(Node container, bool selectFirstNode = true) { if (!NodeCompositionValidator.CanHaveChildren(container.GetType())) { return(false); } if (!string.IsNullOrEmpty(container.ContentsPath)) { OpenExternalScene(container.ContentsPath); } else { ChangeContainer(container, selectFirstNode); } container.SetTangerineFlag(TangerineFlags.DisplayContent, true); return(true); }
public override void ExecuteTransaction() { var nodes = Document.Current?.SelectedNodes().Editable().ToList(); if (nodes.Count != 1) { AlertDialog.Show("Please, select a single node"); return; } if (!(nodes[0] is Widget w && NodeCompositionValidator.CanHaveChildren(w.GetType()) && Document.Current != null)) { AlertDialog.Show($"Can't inline {nodes[0].GetType()}"); return; } var node = nodes[0]; var clone = node.Clone(); clone.ContentsPath = null; var location = Document.Current.Container.RootFolder().Find(node); UnlinkFolderItem.Perform(Document.Current.Container, node); InsertFolderItem.Perform(Document.Current.Container, location, clone); }
public RollNodeView(Row row) { this.row = row; nodeData = row.Components.Get <NodeRow>(); label = new ThemedSimpleText { ForceUncutText = false, VAlignment = VAlignment.Center, OverflowMode = TextOverflowMode.Ellipsis, LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; editBoxContainer = new Widget { Visible = false, Layout = new HBoxLayout(), LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue), }; nodeIcon = new Image(NodeIconPool.GetTexture(nodeData.Node.GetType())) { HitTestTarget = true, MinMaxSize = new Vector2(21, 16), Padding = new Thickness { Left = 5 } }; expandButton = CreateExpandButton(); var expandButtonContainer = new Widget { Layout = new StackLayout { IgnoreHidden = false }, LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0), Nodes = { expandButton } }; expandButtonContainer.CompoundPresenter.Add(new SyncDelegatePresenter <Widget>(widget => { widget.PrepareRendererState(); var a = new Vector2(0, -4); var b = widget.Size + new Vector2(0, 3); int colorIndex = nodeData.Node.EditorState().ColorIndex; Renderer.DrawRect(a, b, ColorMarks[colorIndex]); if (colorIndex != 0) { Renderer.DrawRectOutline(a, b, ColorTheme.Current.TimelineRoll.Lines); } })); expandButtonContainer.Updating += delta => { bool visible = false; foreach (var a in nodeData.Node.Animators) { if (!a.IsZombie && a.AnimationId == Document.Current.AnimationId) { visible = true; break; } } expandButton.Visible = visible; }; enterButton = NodeCompositionValidator.CanHaveChildren(nodeData.Node.GetType()) ? CreateEnterButton() : null; eyeButton = CreateEyeButton(); lockButton = CreateLockButton(); lockAnimationButton = CreateLockAnimationButton(); widget = new Widget { HitTestTarget = true, Padding = new Thickness { Right = 2 }, MinHeight = TimelineMetrics.DefaultRowHeight, Layout = new HBoxLayout { DefaultCell = new DefaultLayoutCell(Alignment.Center) }, Nodes = { expandButtonContainer, (indentSpacer = new Widget()), nodeIcon, Spacer.HSpacer(3), label, editBoxContainer, linkIndicatorButtonContainer, (Widget)enterButton ?? (Widget)Spacer.HSpacer(Theme.Metrics.DefaultToolbarButtonSize.X), lockAnimationButton, eyeButton, lockButton, }, }; widget.Components.Add(new AwakeBehavior()); label.AddChangeWatcher(() => nodeData.Node.Id, s => RefreshLabel()); label.AddChangeWatcher(() => IsGrayedLabel(nodeData.Node), s => RefreshLabel()); label.AddChangeWatcher(() => nodeData.Node.ContentsPath, s => RefreshLabel()); widget.CompoundPresenter.Push(new SyncDelegatePresenter <Widget>(RenderBackground)); nodeIdEditor = new ObjectIdInplaceEditor(row, nodeData.Node, label, editBoxContainer); label.HitTestTarget = true; label.Gestures.Add(new DoubleClickGesture(() => { Document.Current.History.DoTransaction(() => { if (NodeData.Node.EditorState().Locked) { return; } var labelExtent = label.MeasureUncutText(); if (label.LocalMousePosition().X < labelExtent.X) { nodeIdEditor.Rename(); } else { EnterNode.Perform(nodeData.Node); } }); })); widget.Gestures.Add(new ClickGesture(1, ShowContextMenu)); }
static bool AllowChildren(PropertyEditorParams context) { return(context.Objects.All(o => NodeCompositionValidator.CanHaveChildren(o.GetType()))); }
public RollNodeView(Row row) { this.row = row; nodeData = row.Components.Get <NodeRow>(); label = new ThemedSimpleText { ForceUncutText = false, VAlignment = VAlignment.Center, LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; editBox = new ThemedEditBox { LayoutCell = new LayoutCell(Alignment.LeftCenter, float.MaxValue) }; nodeIcon = new Image(NodeIconPool.GetTexture(nodeData.Node.GetType())) { HitTestTarget = true, MinMaxSize = new Vector2(21, 16), Padding = new Thickness { Left = 5 } }; expandButton = CreateExpandButton(); var expandButtonContainer = new Widget { Layout = new StackLayout { IgnoreHidden = false }, LayoutCell = new LayoutCell(Alignment.Center, stretchX: 0), Nodes = { expandButton } }; expandButtonContainer.CompoundPresenter.Add(new DelegatePresenter <Widget>(widget => { widget.PrepareRendererState(); var a = new Vector2(0, -4); var b = widget.Size + new Vector2(0, 3); Renderer.DrawRect(a, b, nodeData.Node.GetColor()); if (nodeData.Node.GetColorIndex() != 0) { Renderer.DrawRectOutline(a, b, ColorTheme.Current.TimelineRoll.Lines); } })); expandButtonContainer.Updating += delta => expandButton.Visible = nodeData.Node.Animators.Count > 0; enterButton = NodeCompositionValidator.CanHaveChildren(nodeData.Node.GetType()) ? CreateEnterButton() : null; eyeButton = CreateEyeButton(); lockButton = CreateLockButton(); lockAnimationButton = CreateLockAnimationButton(); widget = new Widget { Padding = new Thickness { Right = 2 }, MinHeight = TimelineMetrics.DefaultRowHeight, Layout = new HBoxLayout { CellDefaults = new LayoutCell(Alignment.Center) }, HitTestTarget = true, Nodes = { expandButtonContainer, (indentSpacer = new Widget()), nodeIcon, new HSpacer(3), label, editBox, new Widget(), (Widget)enterButton ?? (Widget) new HSpacer(Theme.Metrics.DefaultToolbarButtonSize.X), lockAnimationButton, eyeButton, lockButton, } }; label.AddChangeWatcher(() => nodeData.Node.Id, s => RefreshLabel()); label.AddChangeWatcher(() => IsGrayedLabel(nodeData.Node), s => RefreshLabel()); label.AddChangeWatcher(() => nodeData.Node.ContentsPath, s => RefreshLabel()); widget.CompoundPresenter.Push(new DelegatePresenter <Widget>(RenderBackground)); editBox.Visible = false; widget.Gestures.Add(new ClickGesture(1, ShowPropertyContextMenu)); widget.Gestures.Add(new DoubleClickGesture(() => { var labelExtent = label.MeasureUncutText(); if (label.LocalMousePosition().X < labelExtent.X) { Rename(); } else { Core.Operations.EnterNode.Perform(nodeData.Node); } })); nodeIcon.Gestures.Add(new DoubleClickGesture(() => { Core.Operations.ClearRowSelection.Perform(); Core.Operations.SelectRow.Perform(row); Rename(); })); }