Пример #1
0
        public void SetOperatorWidget(OperatorWidget opWidget)
        {
            if (opWidget == null || opWidget == _shownOperatorWidget)
            {
                return;
            }

            var op = opWidget.Operator;

            if (op == null)
            {
                return;
            }

            if (XStickyCheckbox.IsChecked == true)
            {
                return;
            }

            // Remove handler from old op?
            if (_shownOperatorWidget != null)
            {
                _shownOperatorWidget.Operator.Parent.OperatorRemovedEvent -= Parent_OperatorRemovedEventHandler;
            }

            _shownOperatorWidget            = opWidget;
            op.Parent.OperatorRemovedEvent += Parent_OperatorRemovedEventHandler;

            XSelectedOperatorName.Text = op.Definition.Name + "   " + op.Name;

            _shownOutputIndex = 0;

            UpdateShowControls();
        }
Пример #2
0
 internal static void SelectAndCenter(OperatorWidget widget)
 {
     if (widget != null)
     {
         App.Current.MainWindow.CompositionView.CompositionGraphView.SelectedElements.Clear();
         var list = new List <ISelectable> {
             widget
         };
         App.Current.MainWindow.CompositionView.CompositionGraphView.SelectedElements = list;
         App.Current.MainWindow.CompositionView.CompositionGraphView.CenterSelectedElements();
         App.Current.MainWindow.CompositionView.XCompositionToolBar.XBreadCrumbs.Clear();
         App.Current.MainWindow.CompositionView.XCompositionToolBar.XBreadCrumbs.Push(GetHierachy(widget.Operator));
     }
 }
Пример #3
0
        /** Tries to select operator widget if view isn't locked.
         * Returns true if successful. */
        public bool SetOperatorWidget(OperatorWidget opWidget, bool forHoverOnly = false)
        {
            if (XLockedButton.IsChecked == true)
            {
                return(false);
            }

            if (!forHoverOnly)
            {
                _isShowingHover = false;
            }


            var hasOpWidgetChanged = opWidget != _shownOperatorWidget ||
                                     _hoverTimeScrubbingOffset != _lastRenderedHoverTime;

            _lastRenderedHoverTime = _hoverTimeScrubbingOffset;

            if (opWidget == null || !hasOpWidgetChanged)
            {
                return(false);
            }

            var op = opWidget.Operator;

            // Remove handler from old op?  Why do we need this?
            if (_shownOperatorWidget != null)
            {
                _shownOperatorWidget.Operator.Parent.OperatorRemovedEvent -= Parent_OperatorRemovedEventHandler;
            }

            _shownOperatorWidget            = opWidget;
            op.Parent.OperatorRemovedEvent += Parent_OperatorRemovedEventHandler;

            XSelectedOperatorName.Text = op.Definition.Name + "   " + op.Name;

            _shownOutputIndex = 0;

            UpdateShowControls();
            return(true);
        }
        private static List <OperatorWidgetInputZone> ComputeInputZonesForOperatorWidget(OperatorWidget opWidget)
        {
            var zones = new List <OperatorWidgetInputZone>();

            // First collect inputs that are relevant or connected
            var relevantOrConnectedInputs = new List <OperatorPart>();

            foreach (var input in opWidget.Inputs)
            {
                var metaInput = input.Parent.GetMetaInput(input);
                if (metaInput == null)
                {
                    throw new Exception("Invalid OperatorPart references in InputZone");
                }

                if (metaInput.Relevance == MetaInput.RelevanceType.Required ||
                    metaInput.Relevance == MetaInput.RelevanceType.Relevant)
                {
                    relevantOrConnectedInputs.Add(input);
                }
                else
                {
                    if (input.Connections.Count() > 0)
                    {
                        var animationConnection = Animation.GetRegardingAnimationOpPart(input.Connections[0]);
                        if (animationConnection == null)
                        {
                            // Add non-animated connections
                            relevantOrConnectedInputs.Add(input);
                        }
                    }
                }
            }

            const double WIDTH_OF_MULTIINPUT_ZONES = 1.0 / 3.0;

            /* Roll out zones multi-inputs and the slots for prepending
             * a connection at the first field or inserting connections
             * between existing connections.
             *
             */
            foreach (var input in relevantOrConnectedInputs)
            {
                var metaInput = input.Parent.GetMetaInput(input);
                if (metaInput.IsMultiInput)
                {
                    if (!input.Connections.Any())
                    {
                        // empty multi-input
                        zones.Add(new OperatorWidgetInputZone()
                        {
                            Input     = input,
                            MetaInput = metaInput,
                            InsertAtMultiInputIndex = true,
                        });
                    }
                    else
                    {
                        zones.Add(new OperatorWidgetInputZone()
                        {
                            Input     = input,
                            MetaInput = metaInput,
                            InsertAtMultiInputIndex = true,
                            Width           = WIDTH_OF_MULTIINPUT_ZONES,
                            MultiInputIndex = 0,
                        });

                        for (var multiInputIndex = 0; multiInputIndex < input.Connections.Count; ++multiInputIndex)
                        {
                            var connectedTo = input.Connections[multiInputIndex];

                            // multi-input connection
                            zones.Add(new OperatorWidgetInputZone()
                            {
                                Input           = input,
                                MetaInput       = metaInput,
                                Width           = WIDTH_OF_MULTIINPUT_ZONES,
                                MultiInputIndex = multiInputIndex,
                            });
                            zones.Add(new OperatorWidgetInputZone()
                            {
                                Input                   = input,
                                MetaInput               = metaInput,
                                Width                   = WIDTH_OF_MULTIINPUT_ZONES,
                                MultiInputIndex         = multiInputIndex + 1,
                                InsertAtMultiInputIndex = true
                            });
                        }
                    }
                }
                else
                {
                    // Normal input
                    zones.Add(new OperatorWidgetInputZone()
                    {
                        Input     = input,
                        MetaInput = metaInput
                    });
                }
            }

            // Now distibute the width to the width of the operator
            double widthSum = 0;

            foreach (var zone in zones)
            {
                widthSum += zone.Width;
            }

            double posX = 0;

            for (var i = 0; i < zones.Count; ++i)
            {
                var widthInsideOp = zones[i].Width / widthSum * opWidget.Width;
                zones[i].Width        = widthInsideOp - 1; // requires zones to be a class
                zones[i].LeftPosition = posX;
                posX += widthInsideOp;
            }

            return(zones);
        }