Пример #1
0
        public void SetSelectable()
        {
            capabilities |= Capabilities.Selectable | Capabilities.Droppable | Capabilities.Deletable;
            styleSheets.Add(VFXView.LoadStyleSheet("Selectable"));
            AddToClassList("selectable");
            hierarchy.Add(new VisualElement()
            {
                name = "selection-border", pickingMode = PickingMode.Ignore
            });

            //RegisterCallback<MouseDownEvent>(OnHeaderClicked);
            pickingMode = PickingMode.Position;

            this.AddManipulator(new SelectionDropper());

            m_NameField = new TextField()
            {
                name = "name-field"
            };
            m_Header.Add(m_NameField);
            m_Header.RegisterCallback <MouseDownEvent>(OnMouseDownEvent);
            m_NameField.Q("unity-text-input").RegisterCallback <FocusOutEvent>(e => { OnEditTextSucceded(); });
            m_NameField.Q("unity-text-input").RegisterCallback <KeyDownEvent>(OnTextFieldKeyPressed);
            m_Header.pickingMode      = PickingMode.Position;
            m_NameField.style.display = DisplayStyle.None;
        }
Пример #2
0
        public ResizableElement(string uiFile)
        {
            var tpl   = VFXView.LoadUXML(uiFile);
            var sheet = VFXView.LoadStyleSheet("Resizable");

            styleSheets.Add(sheet);

            tpl.CloneTree(this);

            foreach (Resizer value in System.Enum.GetValues(typeof(Resizer)))
            {
                VisualElement resizer = this.Q(value.ToString().ToLower() + "-resize");
                if (resizer != null)
                {
                    resizer.AddManipulator(new ElementResizer(this, value));
                }
                m_Resizers[value] = resizer;
            }

            foreach (Resizer vertical in new[] { Resizer.Top, Resizer.Bottom })
            {
                foreach (Resizer horizontal in new[] { Resizer.Left, Resizer.Right })
                {
                    VisualElement resizer = this.Q(vertical.ToString().ToLower() + "-" + horizontal.ToString().ToLower() + "-resize");
                    if (resizer != null)
                    {
                        resizer.AddManipulator(new ElementResizer(this, vertical | horizontal));
                    }
                    m_Resizers[vertical | horizontal] = resizer;
                }
            }
        }
Пример #3
0
        public static void AddStyleSheetPath(this VisualElement visualElement, string path)
        {
            var sheet = VFXView.LoadStyleSheet(path);

            if (sheet != null)
            {
                visualElement.styleSheets.Add(sheet);
            }
        }
Пример #4
0
        public VFXBlackboard(VFXView view)
        {
            m_View = view;
            editTextRequested = OnEditName;
            addItemRequested = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory() { title = "parameters"};
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback<MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback<DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback<DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback<DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback<KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q<Button>(name: "addButton");

            m_DragIndicator = new VisualElement();

            m_DragIndicator.name = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query<Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q<Label>("subTitleLabel");
            m_PathLabel.RegisterCallback<MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField { visible = false };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback<FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback<KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if(s_LayoutManual != null)
                s_LayoutManual.SetValue(this, false);

            m_AddButton.SetEnabled(false);
        }
Пример #5
0
        public VFXEdgeDragInfo(VFXView view)
        {
            m_View = view;
            var tpl = VFXView.LoadUXML("VFXEdgeDragInfo");

            tpl.CloneTree(this);

            this.styleSheets.Add(VFXView.LoadStyleSheet("VFXEdgeDragInfo"));

            m_Text = this.Q <Label>("title");

            pickingMode        = PickingMode.Ignore;
            m_Text.pickingMode = PickingMode.Ignore;
        }
Пример #6
0
        public VFXContextUI() : base("uxml/VFXContext")
        {
            capabilities |= Capabilities.Selectable | Capabilities.Movable | Capabilities.Deletable | Capabilities.Ascendable;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXContext"));
            styleSheets.Add(VFXView.LoadStyleSheet("Selectable"));

            AddToClassList("VFXContext");
            AddToClassList("selectable");

            this.mainContainer.style.overflow = Overflow.Visible;


            m_Divider = this.mainContainer.Q("divider");

            m_FlowInputConnectorContainer = this.Q("flow-inputs");

            m_FlowOutputConnectorContainer = this.Q("flow-outputs");

            m_HeaderIcon  = titleContainer.Q <Image>("icon");
            m_HeaderSpace = titleContainer.Q <Image>("header-space");
            m_HeaderSpace.AddManipulator(new Clickable(OnSpace));

            m_BlockContainer = this.Q("block-container");
            m_NoBlock        = m_BlockContainer.Q("no-blocks");

            m_Footer = this.Q("footer");

            m_FooterTitle = m_Footer.Q <Label>("title-label");
            m_FooterIcon  = m_Footer.Q <Image>("icon");


            m_DragDisplay = new VisualElement();
            m_DragDisplay.AddToClassList("dragdisplay");

            m_Label     = this.Q <Label>("user-label");
            m_TextField = this.Q <TextField>("user-title-textfield");
            m_TextField.style.display = DisplayStyle.None;

            m_Label.RegisterCallback <MouseDownEvent>(OnTitleMouseDown);
            m_TextField.RegisterCallback <ChangeEvent <string> >(OnTitleChange);
            m_TextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(OnTitleBlur);
            m_Label.RegisterCallback <GeometryChangedEvent>(OnTitleRelayout);

            RegisterCallback <DragUpdatedEvent>(OnDragUpdated);
            RegisterCallback <DragPerformEvent>(OnDragPerform);
            RegisterCallback <DragExitedEvent>(OnDragExited);
            RegisterCallback <DragLeaveEvent>(OnDragExited);
        }
Пример #7
0
        public VFXParameterUI() : base("uxml/VFXParameter")
        {
            RemoveFromClassList("VFXNodeUI");
            styleSheets.Add(VFXView.LoadStyleSheet("VFXParameter"));
            styleSheets.Add(EditorGUIUtility.Load("StyleSheets/GraphView/Node.uss") as StyleSheet);

            RegisterCallback <MouseEnterEvent>(OnMouseHover);
            RegisterCallback <MouseLeaveEvent>(OnMouseHover);

            m_ExposedIcon          = this.Q <Image>("exposed-icon");
            m_SuperCollapsedButton = this.Q("super-collapse-button");
            m_SuperCollapsedButton.AddManipulator(new Clickable(OnToggleSuperCollapse));

            this.AddManipulator(new SuperCollapser());

            m_Pill = this.Q("pill");
        }
Пример #8
0
        protected void CreateGUI()
        {
            rootVisualElement.styleSheets.Add(VFXView.LoadStyleSheet("VFXAttachPanel"));

            var tpl           = VFXView.LoadUXML("VFXAttachPanel");
            var mainContainer = tpl.CloneTree();

            m_AttachButton          = mainContainer.Q <Button>("AttachButton");
            m_AttachButton.clicked += OnAttach;
            var button = mainContainer.Q <Button>("PickButton");

            button.clicked                += OnPickObject;
            m_pickedObjectLabel            = mainContainer.Q <TextField>("PickLabel");
            m_pickedObjectLabel.isReadOnly = true;
            m_VFXIcon = mainContainer.Q <VisualElement>("VFXIcon");
            UpdateAttachedLabel();
            rootVisualElement.Add(mainContainer);
        }
        void SetupLabel()
        {
            if (typeof(IValueField <U>).IsAssignableFrom(typeof(T)))
            {
                m_Label.styleSheets.Add(VFXView.LoadStyleSheet("VFXLabeledField"));
                if (typeof(U) == typeof(float))
                {
                    var dragger = new VFXFieldMouseDragger <float>((IValueField <float>)m_Control, DragValueFinished, DragValueStarted);
                    dragger.SetDragZone(m_Label);
                    m_Label.AddToClassList("cursor-slide-arrow");
                }
                else if (typeof(U) == typeof(double))
                {
                    var dragger = new VFXFieldMouseDragger <double>((IValueField <double>)m_Control, DragValueFinished, DragValueStarted);
                    dragger.SetDragZone(m_Label);
                    m_Label.AddToClassList("cursor-slide-arrow");
                }
                else if (typeof(U) == typeof(long))
                {
                    var dragger = new VFXFieldMouseDragger <long>((IValueField <long>)m_Control, DragValueFinished, DragValueStarted);
                    dragger.SetDragZone(m_Label);
                    m_Label.AddToClassList("cursor-slide-arrow");
                }
                else if (typeof(U) == typeof(int))
                {
                    var dragger = new VFXFieldMouseDragger <int>((IValueField <int>)m_Control, DragValueFinished, DragValueStarted);
                    dragger.SetDragZone(m_Label);
                    m_Label.AddToClassList("cursor-slide-arrow");
                }
            }

            m_IndeterminateLabel = new Label()
            {
                name = "indeterminate",
                text = VFXControlConstants.indeterminateText
            };
            m_IndeterminateLabel.SetEnabled(false);
        }
Пример #10
0
 public StickyNote(Vector2 position) : this("StickyNote", position)
 {
     styleSheets.Add(VFXView.LoadStyleSheet("Selectable"));
     styleSheets.Add(VFXView.LoadStyleSheet("StickyNote"));
     RegisterCallback <AttachToPanelEvent>(OnAttachToPanel);
 }
Пример #11
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_ContentContainer = this.Q <VisualElement>("contentContainer");

            m_AddButton              = this.Q <Button>(name: "addButton");
            m_AddButton.style.width  = 27;
            m_AddButton.style.height = 27;

            m_DragIndicator = new VisualElement();


            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); }, TrickleDown.TrickleDown);
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed, TrickleDown.TrickleDown);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));

            // Workaround: output category is in a scrollview which can lead to get the Add button invisible (moved out of the visible viewport of the scrollviewer)
            var scrollView = this.Q <ScrollView>();

            if (scrollView != null)
            {
                scrollView.RegisterCallback <GeometryChangedEvent, ScrollView>(OnGeometryChanged, scrollView);
                scrollView.horizontalScroller.valueChanged += x => OnOutputCategoryScrollChanged(scrollView);
            }
        }
Пример #12
0
        public VFXBlackboard(VFXView view)
        {
            m_View            = view;
            editTextRequested = OnEditName;
            addItemRequested  = OnAddItem;

            this.scrollable = true;

            SetPosition(BoardPreferenceHelper.LoadPosition(BoardPreferenceHelper.Board.blackboard, defaultRect));

            m_DefaultCategory = new VFXBlackboardCategory()
            {
                title = "parameters"
            };
            Add(m_DefaultCategory);
            m_DefaultCategory.headerVisible = false;

            styleSheets.Add(VFXView.LoadStyleSheet("VFXBlackboard"));

            RegisterCallback <MouseDownEvent>(OnMouseClick, TrickleDown.TrickleDown);
            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);
            RegisterCallback <KeyDownEvent>(OnKeyDown);

            focusable = true;

            m_AddButton = this.Q <Button>(name: "addButton");

            m_DragIndicator = new VisualElement();


            m_DragIndicator.name           = "dragIndicator";
            m_DragIndicator.style.position = PositionType.Absolute;
            hierarchy.Add(m_DragIndicator);

            SetDragIndicatorVisible(false);

            Resizer resizer = this.Query <Resizer>();

            hierarchy.Add(new UnityEditor.Experimental.GraphView.ResizableElement());

            style.position = PositionType.Absolute;

            m_PathLabel = hierarchy.ElementAt(0).Q <Label>("subTitleLabel");
            m_PathLabel.RegisterCallback <MouseDownEvent>(OnMouseDownSubTitle);

            m_PathTextField = new TextField {
                visible = false
            };
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <FocusOutEvent>(e => { OnEditPathTextFinished(); });
            m_PathTextField.Q(TextField.textInputUssName).RegisterCallback <KeyDownEvent>(OnPathTextFieldKeyPressed);
            hierarchy.Add(m_PathTextField);

            resizer.RemoveFromHierarchy();

            if (s_LayoutManual != null)
            {
                s_LayoutManual.SetValue(this, false);
            }

            m_LockedElement                      = new Label("Asset is locked");
            m_LockedElement.style.color          = Color.white * 0.75f;
            m_LockedElement.style.position       = PositionType.Absolute;
            m_LockedElement.style.left           = 0f;
            m_LockedElement.style.right          = new StyleLength(0f);
            m_LockedElement.style.top            = new StyleLength(0f);
            m_LockedElement.style.bottom         = new StyleLength(0f);
            m_LockedElement.style.unityTextAlign = TextAnchor.MiddleCenter;
            var fontSize = 54f;

            m_LockedElement.style.fontSize      = new StyleLength(fontSize);
            m_LockedElement.style.paddingBottom = fontSize / 2f;
            m_LockedElement.style.paddingTop    = fontSize / 2f;
            m_LockedElement.style.display       = DisplayStyle.None;
            m_LockedElement.focusable           = true;
            m_LockedElement.RegisterCallback <KeyDownEvent>(e => e.StopPropagation());
            Add(m_LockedElement);

            m_AddButton.SetEnabled(false);

            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }