Esempio n. 1
0
 internal void FireEnterNode(ExecutionEnterEventArgs args)
 {
     if (IsAborting)
     {
         throw new ExecutionAbortException(Properties.Language.ExecutionAborted);
     }
     EnterNode?.Invoke(this, args);
     if (_parent != null)
     {
         _parent.FireEnterNode(args);
     }
 }
Esempio n. 2
0
        public static void Bind()
        {
            Action enter = () => {
                var node = Document.Current.SelectedNodes().FirstOrDefault();
                if (node != null)
                {
                    EnterNode.Perform(node);
                }
            };

            ConnectCommand(TimelineCommands.EnterNode, enter, Document.HasCurrent);
            ConnectCommand(TimelineCommands.EnterNodeAlias, enter, Document.HasCurrent);
            ConnectCommand(TimelineCommands.EnterNodeMouse, enter, Document.HasCurrent);
            ConnectCommand(TimelineCommands.Expand, Expand, Document.HasCurrent);
            ConnectCommand(TimelineCommands.ExpandRecursively, ExpandRecursively, Document.HasCurrent);
            ConnectCommand(TimelineCommands.RenameRow, RenameCurrentRow);
            ConnectCommand(TimelineCommands.ExitNode, LeaveNode.Perform);
            ConnectCommand(TimelineCommands.ExitNodeAlias, LeaveNode.Perform);
            ConnectCommand(TimelineCommands.ExitNodeMouse, LeaveNode.Perform);
            ConnectCommand(TimelineCommands.ScrollUp, () => SelectRow(-1, false));
            ConnectCommand(TimelineCommands.ScrollDown, () => SelectRow(1, false));
            ConnectCommand(TimelineCommands.SelectNodeUp, () => SelectRow(-1, true));
            ConnectCommand(TimelineCommands.SelectNodeDown, () => SelectRow(1, true));
            ConnectCommand(TimelineCommands.ScrollLeft, () => AdvanceCurrentColumn(-1));
            ConnectCommand(TimelineCommands.ScrollRight, () => AdvanceCurrentColumn(1));
            ConnectCommand(TimelineCommands.FastScrollLeft, () => AdvanceCurrentColumn(-10));
            ConnectCommand(TimelineCommands.FastScrollRight, () => AdvanceCurrentColumn(10));
            ConnectCommand(TimelineCommands.DeleteKeyframes, RemoveKeyframes);
            ConnectCommand(TimelineCommands.CreateMarkerPlay, () => CreateMarker(MarkerAction.Play));
            ConnectCommand(TimelineCommands.CreateMarkerStop, () => CreateMarker(MarkerAction.Stop));
            ConnectCommand(TimelineCommands.CreateMarkerJump, () => CreateMarker(MarkerAction.Jump));
            ConnectCommand(TimelineCommands.DeleteMarker, DeleteMarker);
            ConnectCommand(TimelineCommands.CopyMarkers, Rulerbar.CopyMarkers);
            ConnectCommand(TimelineCommands.PasteMarkers, Rulerbar.PasteMarkers);
            ConnectCommand(TimelineCommands.DeleteMarkers, Rulerbar.DeleteMarkers);
            ConnectCommand(TimelineCommands.DeleteMarkersInRange, Rulerbar.DeleteMarkersInRange);
            ConnectCommand(TimelineCommands.MoveDown, MoveNodesDown.Perform);
            ConnectCommand(TimelineCommands.MoveUp, MoveNodesUp.Perform);
            ConnectCommand(TimelineCommands.SelectAllRowKeyframes, SelectAllRowKeyframes);
            ConnectCommand(TimelineCommands.SelectAllKeyframes, SelectAllKeyframes);
        }
Esempio n. 3
0
        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));
        }
Esempio n. 4
0
 protected override void OnEnable()
 {
     base.OnEnable();
     m_enterNode = (EnterNode)target;
     m_infoMessageNotConnected = new InfoMessage(InfoMessage.MessageType.Error, UILabels.NotConnectedTitle, UILabels.NotConnectedMessage);
 }
Esempio n. 5
0
        /// <summary>
        // Walks a Node in a depth-first/pre-order manner without recursion.
        // It returns a series of "events" that indicate one of three things:
        // - whether it has enters into a node
        // - whether it has exited from a node (i.e. it is finished with that container and its children)
        /// </summary>
        /// <param name="node"></param>
        /// <param name="enum_children"></param>
        /// <param name="enter_node"></param>
        /// <returns></returns>
        public static IEnumerable <WalkEvent <T> > Walk <T>(T node, Traversal.EnumerateChildren <T> enum_children, EnterNode <T> enter_node)
        {
            var stack = new Stack <WalkState <T> >();

            // put the first item on the stack
            stack.Push(new WalkState <T>(node));

            // As long as something is on the stack, we are not done
            while (stack.Count > 0)
            {
                var cur_item = stack.Pop();

                if (cur_item.Entered == false)
                {
                    var walkevent = new WalkEvent <T>(cur_item.Node, WalkEventType.Enter);
                    yield return(walkevent);

                    cur_item.Entered = true;
                    stack.Push(cur_item);

                    if (enter_node(cur_item.Node))
                    {
                        foreach (var child in Traversal.efficient_reverse(enum_children(cur_item.Node)))
                        {
                            stack.Push(new WalkState <T>(child));
                        }
                    }
                }
                else
                {
                    var walkevent = new WalkEvent <T>(cur_item.Node, WalkEventType.Exit);
                    yield return(walkevent);
                }
            }
        }