Ejemplo n.º 1
0
        public static void AddManipulators <T>(T instance, VisualElement element)
        {
            IOnMouse mouseHandler = instance as IOnMouse;

            if (mouseHandler != null)
            {
                //Debug.LogFormat("Adding 'MouseManipulator' to '{0}'", instance.GetType().Name);
                element.AddManipulator(new RedOwlMouseManipulator(mouseHandler.IsContentDragger, mouseHandler.MouseFilters.ToArray()));
            }

            IOnContextMenu contextMenuHandler = instance as IOnContextMenu;

            if (contextMenuHandler != null)
            {
                //Debug.LogFormat("Adding 'ContextualMenuManipulator' to '{0}'", instance.GetType().Name);
                element.AddManipulator(new ContextualMenuManipulator(contextMenuHandler.OnContextMenu));
            }

            IOnKeyboard keyboardHandler = instance as IOnKeyboard;

            if (keyboardHandler != null)
            {
                //Debug.LogFormat("Adding 'KeyboardManipulator' to '{0}'", instance.GetType().Name);
                element.AddManipulator(new RedOwlKeyboardManipulator(keyboardHandler.KeyboardFilters.ToArray()));
            }

            IOnWheel wheelHandler = instance as IOnWheel;
            IOnZoom  zoomHandler  = instance as IOnZoom;

            if (wheelHandler != null || zoomHandler != null)
            {
                //Debug.LogFormat("Adding 'WheelManipulator' to '{0}'", instance.GetType().Name);
                element.AddManipulator(new RedOwlWheelManipulator());
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Add an item to the reorderable list
        /// </summary>
        public void AddItem(VisualElement item)
        {
            _itemsContainer.Add(item);

            item.AddManipulator(new PAItemSelector(this, item));
            item.AddManipulator(new PAItemDragger(this, item));

            Select(_itemsContainer.childCount - 1);
        }
Ejemplo n.º 3
0
    private void CreateContextMenu(VisualElement visualElement)
    {
        ContextualMenuManipulator menuManipulator = new ContextualMenuManipulator(PopulateContextMenu);

        visualElement.focusable   = true;
        visualElement.pickingMode = PickingMode.Position;
        visualElement.AddManipulator(menuManipulator);

        visualElement.AddManipulator(menuManipulator);
    }
        void SetupManipulators(VisualElement element)
        {
            element.AddManipulator(new MarkerManipulator(this));
            var contextManipulator = new ContextualMenuManipulator((obj) =>
            {
                SelectMarkerMenu(obj);
                obj.menu.AppendSeparator();
            });

            element.AddManipulator(contextManipulator);
        }
Ejemplo n.º 5
0
        public WorkbenchSplitter(float initialWorkbenchWidth = 200)
        {
            style.flexGrow      = 1;
            style.flexDirection = FlexDirection.Row;

            LeftPane      = new VisualElement();
            LeftPane.name = "splitterLeftPane";

            LeftPane.style.width = initialWorkbenchWidth;
            Add(LeftPane);

            var dragLineAnchor = new VisualElement();

            dragLineAnchor.name = "splitterDraglineAnchor";
            Add(dragLineAnchor);

            m_DragLine      = new VisualElement();
            m_DragLine.name = "splitterDragline";
            var resizer = new SquareResizer(LeftPane);

            m_DragLine.AddManipulator(resizer);
            resizer.LeftPaneWidthChanged += (f) => LeftPaneWidthChanged(f);

            dragLineAnchor.Add(m_DragLine);

            RightPane = new VisualElement();
            RightPane.style.flexGrow = 1;
            Add(RightPane);
        }
Ejemplo n.º 6
0
 void CreateBreadcrumbMenu()
 {
     m_BreadcrumbButton         = this.MandatoryQ("breadcrumbButton");
     m_BreadcrumbButton.tooltip = "Click to navigate to other scripts";
     m_BreadcrumbButton.AddManipulator(new Clickable(OnBreadcrumbButtonClicked));
     m_Breadcrumb = this.MandatoryQ <ToolbarBreadcrumbs>("breadcrumb");
 }
        void Setup()
        {
            m_NameContainer      = new Label();
            m_NameContainer.name = "name";

            m_IconContainer      = new VisualElement();
            m_IconContainer.name = "icon";


            m_SelectContainer      = new VisualElement();
            m_SelectContainer.name = "select";
            Add(m_IconContainer);
            Add(m_NameContainer);
            Add(m_SelectContainer);

            m_SelectContainer.AddManipulator(new Clickable(OnShowObjects));
            this.AddManipulator(new Clickable(OnSelect));
            this.AddManipulator(new ShortcutHandler(new Dictionary <Event, ShortcutDelegate>
            {
                { Event.KeyboardEvent("delete"), SetToNull },
                { Event.KeyboardEvent("backspace"), SetToNull }
            }));


            this.AddManipulator(new ObjectDropper());

            m_Reciever               = Receiver.CreateInstance <Receiver>();
            m_Reciever.hideFlags     = HideFlags.HideAndDontSave;
            m_Reciever.m_ObjectField = this;

            focusIndex = 0;
        }
Ejemplo n.º 8
0
        void UpdateExpandable()
        {
            if (m_Provider.expandable)
            {
                if (m_IconStates == null)
                {
                    m_IconStates = new Texture2D[]
                    {
                        Resources.Load <Texture2D>("VFX/plus"),
                        Resources.Load <Texture2D>("VFX/minus")
                    };
                }
                if (!m_IconClickableAdded)
                {
                    m_Icon.AddManipulator(m_IconClickable);
                    m_IconClickableAdded = false;
                }

                m_Icon.style.backgroundImage = m_IconStates[m_Provider.expanded ? 1 : 0];
            }
            else
            {
                if (m_IconClickableAdded)
                {
                    m_Icon.RemoveManipulator(m_IconClickable);
                    m_IconClickableAdded = false;
                }

                m_Icon.style.backgroundImage = null;
            }
        }
Ejemplo n.º 9
0
        public override TreeElement GetElement()
        {
            if (Element.VisualElement != null)
            {
                return(Element);
            }

            var element = new VisualElement();

            element.AddToClassList("node");

            element.Add(new Label(cell.DisplayName));
            var costField = NodeUtil.CreateCostField(cell.Cost, OnCostUpdated);

            element.Add(costField);

            element.AddToClassList(cell is UnitCell ? "node-unit" : "node-building");

            element.style.top  = position.y;
            element.style.left = position.x;

            element.AddManipulator(this);

            Element.VisualElement = element;
            Element.SortOrder     = SortOrder;

            return(Element);
        }
Ejemplo n.º 10
0
        public TagElement(AssetResult result, string value, SerializableHashSet <string> values)
        {
            _assetResult = result;
            _value       = value;
            _values      = values;

            var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Packages/org.visualpinball.engine.unity/VisualPinball.Unity/VisualPinball.Unity.Editor/AssetBrowser/TagElement.uxml");
            var ui         = visualTree.CloneTree();
            var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Packages/org.visualpinball.engine.unity/VisualPinball.Unity/VisualPinball.Unity.Editor/AssetBrowser/TagElement.uss");

            ui.styleSheets.Add(styleSheet);
            Add(ui);

            _displayElement  = ui.Q <VisualElement>("display");
            _editElement     = ui.Q <VisualElement>("edit");
            _nameElement     = ui.Q <Label>("attribute-name");
            _nameEditElement = ui.Q <SearchSuggest>("attribute-name-edit");

            ui.Q <Button>("okButton").RegisterCallback <MouseUpEvent>(_ => CompleteEdit(true, _nameEditElement.Value));
            ui.Q <Button>("cancelButton").RegisterCallback <MouseUpEvent>(_ => ToggleEdit());

            _displayElement.RegisterCallback <MouseDownEvent>(OnNameClicked);

            if (!_assetResult.Library.IsLocked)
            {
                _nameEditElement.RegisterKeyDownCallback(evt => OnKeyDown(evt, _nameEditElement));

                // right-click menu
                _displayElement.AddManipulator(new ContextualMenuManipulator(AddContextMenu));
            }

            Update();
            RegisterCallback <AttachToPanelEvent>(OnAttached);
        }
Ejemplo n.º 11
0
        void UpdateExpandable()
        {
            if (m_Provider.expandable && (m_Provider.expandableIfShowsEverything || !showsEverything))
            {
                if (!m_IconClickableAdded)
                {
                    m_Icon.AddManipulator(m_IconClickable);
                    m_IconClickableAdded = false;
                }
                if (m_Provider.expanded)
                {
                    AddToClassList("icon-expanded");
                }
                else
                {
                    RemoveFromClassList("icon-expanded");
                }
                AddToClassList("icon-expandable");
            }
            else
            {
                if (m_IconClickableAdded)
                {
                    m_Icon.RemoveManipulator(m_IconClickable);
                    m_IconClickableAdded = false;
                }

                m_Icon.style.backgroundImage = null;
            }
        }
        public MasterPreviewView(string assetName, PreviewManager previewManager, AbstractMaterialGraph graph)
        {
            this.clippingOptions = ClippingOptions.ClipAndCacheContents;
            m_PreviewManager = previewManager;
            m_Graph = graph;

            AddStyleSheetPath("Styles/MasterPreviewView");

            m_PreviewRenderHandle = previewManager.masterRenderData;

            var topContainer = new VisualElement() { name = "top" };
            {
                var title = new Label(assetName.Split('/').Last()) { name = "title" };
                topContainer.Add(title);
            }
            Add(topContainer);

            var middleContainer = new VisualElement {name = "middle"};
            {
                m_PreviewTextureView = CreatePreview(Texture2D.blackTexture);
                m_PreviewScrollPosition = new Vector2(0f, 0f);
                middleContainer.Add(m_PreviewTextureView);
                middleContainer.AddManipulator(new Scrollable(OnScroll));
            }
            m_PreviewRenderHandle.onPreviewChanged += OnPreviewChanged;
            Add(middleContainer);
        }
Ejemplo n.º 13
0
        VisualElement CreateParameterVariantView(ExposedParameter param, SerializedObject serializedInspector)
        {
            VisualElement prop = new VisualElement();

            prop.AddToClassList("Indent");
            prop.style.display = DisplayStyle.Flex;
            var parameterView = overrideParameterView.CloneTree();

            prop.Add(parameterView);

            var parameterValueField = exposedParameterFactory.GetParameterValueField(param, (newValue) => {
                param.value = newValue;
                UpdateOverrideParameter(param, newValue);
            });

            prop.AddManipulator(new ContextualMenuManipulator(e => {
                e.menu.AppendAction("Reset", _ => RemoveOverride(param));
            }));

            parameterValueField.Bind(serializedInspector);
            var paramContainer = parameterView.Q("Parameter");

            paramContainer.Add(parameterValueField);

            parameterViews[param] = parameterView;

            if (variant.overrideParameters.Contains(param))
            {
                AddOverrideClass(parameterView);
            }

            return(prop);
        }
Ejemplo n.º 14
0
        void SetupCrashDiag()
        {
            var crashDiagContainer = rootVisualElement.Q(className: k_CloudDiagCrashContainerClassName);

            if (crashDiagContainer == null)
            {
                return;
            }

            var generalTemplate = EditorGUIUtility.Load(k_CloudDiagCrashCommonUxmlPath) as VisualTreeAsset;

            if (generalTemplate != null)
            {
                var newVisual = generalTemplate.CloneTree().contentContainer;
                ServicesUtils.TranslateStringsInTree(newVisual);
                crashDiagContainer.Clear();
                crashDiagContainer.Add(newVisual);
                crashDiagContainer.Add(ServicesUtils.SetupSupportedPlatformsBlock(ServicesUtils.GetCloudDiagCrashSupportedPlatforms()));

                m_CrashServiceGoToDashboard = rootVisualElement.Q(k_CloudDiagCrashGoToDashboardName);
                if (m_CrashServiceGoToDashboard != null)
                {
                    var clickable = new Clickable(() =>
                    {
                        ServicesConfiguration.instance.RequestBaseCloudDiagCrashesDashboardUrl(OpenDashboardOrgAndProjectIds);
                    });
                    m_CrashServiceGoToDashboard.AddManipulator(clickable);
                }

                m_CrashServiceToggle = rootVisualElement.Q <Toggle>(className: k_ServiceToggleClassName);
                SetupServiceToggle();
                RegisterEvent();
            }
        }
Ejemplo n.º 15
0
        void CreateSettingButton()
        {
            settingButton = new VisualElement {
                name = "settings-button"
            };
            settingButton.Add(new VisualElement {
                name = "icon"
            });
            settings = new VisualElement();

            // Add Node type specific settings
            settings.Add(CreateSettingsView());

            // Add manipulators
            settingButton.AddManipulator(new Clickable(ToggleSettings));

            var buttonContainer = new VisualElement {
                name = "button-container"
            };

            buttonContainer.style.flexDirection = FlexDirection.Row;
            buttonContainer.Add(settingButton);
            titleContainer.Add(buttonContainer);

            // Check and reorder if has a output port in the title
            var outPutPort = titleContainer.Q <PortView>(className: "output");

            if (outPutPort != null)
            {
                buttonContainer.PlaceBehind(outPutPort);
            }
        }
Ejemplo n.º 16
0
        private void Setup()
        {
            TextField = new TextField();
            TextField.AddToClassList(TextUssClassName);
            TextField.RegisterValueChangedCallback(evt => Value = evt.newValue);

            var enabled = Options.Count > 0;

            _dropdownButton = new VisualElement {
                tooltip = enabled ? "Show the combo box options" : "No preset options available"
            };
            _dropdownButton.AddToClassList(BasePopupField <string, string> .inputUssClassName);
            _dropdownButton.AddToClassList(ButtonUssClassName);
            _dropdownButton.AddManipulator(new Clickable(OpenDropdown));
            _dropdownButton.SetEnabled(enabled);

            _menu = new GenericMenu();

            foreach (var option in Options)
            {
                _menu.AddItem(new GUIContent(option), false, () => SelectItem(option));
            }

            Add(TextField);
            Add(_dropdownButton);
        }
Ejemplo n.º 17
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;
                }
            }
        }
Ejemplo n.º 18
0
        public ResizableElement(string uiFile)
        {
            var tpl = Resources.Load <VisualTreeAsset>(uiFile);

            AddStyleSheetPath("Resizable");

            tpl.CloneTree(this, new Dictionary <string, VisualElement>());

            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;
                }
            }
        }
Ejemplo n.º 19
0
        public ResizableElement(string uiFile)
        {
            var tpl = Resources.Load <VisualTreeAsset>(uiFile);

            if (tpl == null)
            {
                tpl = GraphElementsHelper.LoadUXML(uiFile);
            }

            this.AddStylesheet("Resizable.uss");

            tpl.CloneTree(this);

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

            foreach (ResizerDirection vertical in new[] { ResizerDirection.Top, ResizerDirection.Bottom })
            {
                foreach (ResizerDirection horizontal in new[] { ResizerDirection.Left, ResizerDirection.Right })
                {
                    VisualElement resizer = this.Q(vertical.ToString().ToLower() + "-" + horizontal.ToString().ToLower() + "-resize");
                    if (resizer != null)
                    {
                        resizer.AddManipulator(new ElementResizer(this, vertical | horizontal));
                    }
                }
            }
        }
        protected override void ActivateAction(string searchContext)
        {
            // Must reset properties every time this is activated
            var mainTemplate = EditorGUIUtility.Load(k_PurchasingServicesTemplatePath) as VisualTreeAsset;

            rootVisualElement.Add(mainTemplate.CloneTree().contentContainer);

            if (!PurchasingService.instance.IsServiceEnabled())
            {
                m_StateMachine.Initialize(m_DisabledState);
            }
            else
            {
                m_StateMachine.Initialize(m_EnabledState);
            }

            // Moved the Go to dashboard link to the header title section.
            m_GoToDashboard = rootVisualElement.Q(k_GoToDashboardLink);
            if (m_GoToDashboard != null)
            {
                var clickable = new Clickable(() =>
                {
                    ServicesConfiguration.instance.RequestBasePurchasingDashboardUrl(OpenDashboardForProjectGuid);
                });
                m_GoToDashboard.AddManipulator(clickable);
            }

            m_MainServiceToggle = rootVisualElement.Q <Toggle>(className: k_ServiceToggleClassName);
            SetupServiceToggle(PurchasingService.instance);

            InitializeServiceCallbacks();
        }
Ejemplo n.º 21
0
        VisualElement CreateHandle(TagManipulator.Mode m)
        {
            var handle = new VisualElement();

            handle.AddManipulator(new TagManipulator(this, m));
            handle.AddToClassList("clipTagDragHandle");
            return(handle);
        }
        public PackageItem(Package package)
        {
            root = Resources.GetTemplate("PackageItem.uxml");
            Add(root);

            root.AddManipulator(new Clickable(Select));
            SetItem(package);
        }
Ejemplo n.º 23
0
        public override void SelfChange(int change)
        {
            base.SelfChange(change);

            if (controller.depth != 0 && m_Lines == null)
            {
                m_Lines = new VisualElement[controller.depth + 1];

                for (int i = 0; i < controller.depth; ++i)
                {
                    var line = new VisualElement();
                    line.style.width       = 1;
                    line.name              = "line";
                    line.style.marginLeft  = PropertyRM.depthOffset - 2;
                    line.style.marginRight = 0;

                    Insert(3, line);
                    m_Lines[i] = line;
                }
            }


            if (controller.expandable)
            {
                if (controller.expandedSelf)
                {
                    AddToClassList("icon-expanded");
                }
                else
                {
                    RemoveFromClassList("icon-expanded");
                }
                AddToClassList("icon-expandable");

                if (m_ExpandClickable == null)
                {
                    m_ExpandClickable = new Clickable(OnToggleExpanded);
                    m_Icon.AddManipulator(m_ExpandClickable);
                }
            }
            else
            {
                m_Icon.style.backgroundImage = null;
                if (m_ExpandClickable != null)
                {
                    m_Icon.RemoveManipulator(m_ExpandClickable);
                    m_ExpandClickable = null;
                }
            }


            string text    = "";
            string tooltip = null;

            VFXPropertyAttribute.ApplyToGUI(controller.attributes, ref text, ref tooltip);

            this.tooltip = tooltip;
        }
        protected override void ActivateAction(string searchContext)
        {
            // Must reset properties every time this is activated
            var mainTemplate = EditorGUIUtility.Load(k_CloudBuildCommonUxmlPath) as VisualTreeAsset;

            // To allow the save using the view data, we must provide a key on the root element
            rootVisualElement.viewDataKey = "cloud-build-root-data-key";

            var mainTemplateContainer = mainTemplate.CloneTree().contentContainer;

            ServicesUtils.TranslateStringsInTree(mainTemplateContainer);
            rootVisualElement.Add(mainTemplateContainer);

            // Make sure to reset the state machine
            m_StateMachine.ClearCurrentState();

            // Make sure to activate the state machine to the current state...

            if (BuildService.instance.IsServiceEnabled())
            {
                m_StateMachine.Initialize(m_EnabledState);
            }
            else
            {
                m_StateMachine.Initialize(m_DisabledState);
            }

            // Register the events for enabling / disabling the service only once.
            RegisterEvent();
            // Moved the Go to dashboard link to the header title section.
            m_GoToDashboard = rootVisualElement.Q(k_GoToDashboardLink);
            if (m_GoToDashboard != null)
            {
                var clickable = new Clickable(() =>
                {
                    ServicesConfiguration.instance.RequestBaseCloudBuildDashboardUrl(baseCloudBuildDashboardUrl =>
                    {
                        OpenDashboardOrgAndProjectIds(baseCloudBuildDashboardUrl);
                    });
                });
                m_GoToDashboard.AddManipulator(clickable);
            }

            m_MainServiceToggle = rootVisualElement.Q <Toggle>(className: k_ServiceToggleClassName);
            SetupServiceToggle(BuildService.instance);

            var learnMore = rootVisualElement.Q(k_LearnMoreLink);

            if (learnMore != null)
            {
                var clickable = new Clickable(() =>
                {
                    Application.OpenURL(ServicesConfiguration.instance.GetUnityTeamInfoUrl());
                });
                learnMore.AddManipulator(clickable);
            }
        }
Ejemplo n.º 25
0
        public VisualSplitter(VisualElement fixedPane, VisualElement flexedPane, FlexDirection direction, float size = 0f)
        {
            this.fixedPane  = fixedPane;
            this.flexedPane = flexedPane;
            m_Resizer       = new Resizer(this, 1, direction);

            flexedPane.style.flexGrow = 1;

            m_Dragger = new VisualElement();
            m_Dragger.style.position = Position.Absolute;
            m_Dragger.AddManipulator(m_Resizer);

            var splitter = new VisualElement()
            {
                name = "Splitter"
            };

            if (direction == FlexDirection.Column)
            {
                m_Dragger.style.height = k_SplitterSize;
                m_Dragger.style.top    = -Mathf.RoundToInt(k_SplitterSize / 2f);
                m_Dragger.style.left   = 0f;
                m_Dragger.style.right  = 0f;
                m_Dragger.style.cursor = LoadCursor(MouseCursor.ResizeVertical);
                //m_Dragger.style.backgroundColor = Color.green;

                if (size != 0)
                {
                    splitter.style.height = size;
                }
            }
            else if (direction == FlexDirection.Row)
            {
                m_Dragger.style.width  = k_SplitterSize;
                m_Dragger.style.left   = -Mathf.RoundToInt(k_SplitterSize / 2f);
                m_Dragger.style.top    = 0f;
                m_Dragger.style.bottom = 0f;
                m_Dragger.style.cursor = LoadCursor(MouseCursor.ResizeHorizontal);
                //m_Dragger.style.backgroundColor = Color.red;

                if (size != 0)
                {
                    splitter.style.width = size;
                }
            }

            Add(fixedPane);
            Add(splitter);
            Add(flexedPane);
            Add(m_Dragger);

            RegisterCallback <GeometryChangedEvent>(OnSizeChange);
            fixedPane.RegisterCallback <GeometryChangedEvent>(OnSizeChange);

            style.flexGrow      = 1;
            style.flexDirection = direction;
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="node">Node that needs view</param>
        /// <param name="edgeConnectorListener">Edge connector listener for this view</param>
        public BaseNodeView(SNode node, IEdgeConnectorListener edgeConnectorListener)
        {
            styleSheets.Add(Resources.Load <StyleSheet>("Styles/BaseNodeView"));

            Node = node;
            EdgeConnectorListener = edgeConnectorListener;

            title = ObjectNames.NicifyVariableName(node.NodeType.Name);
            base.SetPosition(new Rect(node.Position, Vector2.zero));

            foreach (var port in Node.Ports)
            {
                AddPort(port);
            }

            var contents = this.Q("contents");

            if (Node.PropertyBlock.GetType() != typeof(PropertyBlock))
            {
                _propertiesExpander = new VisualElement()
                {
                    name = "properties-expander"
                };
                {
                    var divider = new VisualElement()
                    {
                        name = "divider"
                    };
                    {
                        divider.AddToClassList("horizontal");
                    }
                    _propertiesExpander.Add(divider);

                    _propertiesToggle = new VisualElement()
                    {
                        name = "properties-toggle"
                    };
                    {
                        _propertiesToggle.AddManipulator(new Clickable(TogglePropertiesView));

                        var icon = new VisualElement()
                        {
                            name = "icon"
                        };
                        _propertiesToggle.Add(icon);
                    }
                    _propertiesExpander.Add(_propertiesToggle);
                }
                contents.Add(_propertiesExpander);
            }

            Node.PortsChanged += NodeOnPortsChanged;

            RefreshPorts();
            RefreshExpandedState();
        }
Ejemplo n.º 27
0
    public void OnEnable()
    {
        VisualElement root = rootVisualElement;

        root.AddManipulator(new MouseEventLogger());
        root.Add(new Label()
        {
            style = { backgroundColor = Color.yellow }, text = "output console log!"
        });
    }
Ejemplo n.º 28
0
 public SpaceablePropertyRM(IPropertyRMProvider controller, float labelWidth) : base(controller, labelWidth)
 {
     m_Button = new VisualElement()
     {
         name = "spacebutton"
     };
     m_Button.AddManipulator(new Clickable(OnButtonClick));
     Add(m_Button);
     AddToClassList("spaceablepropertyrm");
 }
Ejemplo n.º 29
0
        public override TreeElement GetElement()
        {
            if (Element.VisualElement != null)
            {
                return(Element);
            }

            var element = new VisualElement();

            element.AddToClassList("node-group");

            var linkChildrenButton = new Button();

            linkChildrenButton.AddToClassList("node-group-link-trigger");
            SetupChildLinkVisuals(element, linkChildrenButton);
            linkChildrenButton.clicked += () =>
            {
                ToggleChildrenLinked();
                SetupChildLinkVisuals(element, linkChildrenButton);
            };

            element.Add(new Label(action.name));
            element.AddToClassList("node-upgrade");

            element.style.top  = position.y;
            element.style.left = position.x;

            element.AddManipulator(this);
            element.Add(linkChildrenButton);

            Element.VisualElement = element;
            Element.SortOrder     = SortOrder;

            Element.Children = new List <TreeElement>();
            foreach (var subNode in subNodes)
            {
                var subElement = subNode.GetElement();
                Element.Children.Add(new TreeElement()
                {
                    Parent        = element,
                    VisualElement = subElement.VisualElement,
                    SortOrder     = subElement.SortOrder,
                });
                subNode.SetMoveWithParent(isChildrenLinked);

                var ce = new ConnectionElement(this, subNode, new Color(1f, 0f, 1f, 0.29f), 5f, true);
                ce.style.visibility = new StyleEnum <Visibility>(Visibility.Hidden);
                Element.Children.Add(new TreeElement()
                {
                    Parent = element, SortOrder = 1, VisualElement = ce
                });
            }

            return(Element);
        }
Ejemplo n.º 30
0
        public PreviewSelector()
        {
            UIElementsUtils.ApplyStyleSheet("PreviewSelector.uss", this);
            AddToClassList("previewSelector");

            // Target Selection
            {
                var selectorContainer = new VisualElement();
                selectorContainer.AddToClassList("selectorContainer");
                var selectorClick = new Clickable(OnSelectorClicked);
                selectorContainer.AddManipulator(selectorClick);

                Label label = new Label {
                    text = "Target"
                };
                var labelClick = new Clickable(OnSelectorClicked);
                label.AddManipulator(labelClick);

                m_SelectorDropdown = new Image();
                m_SelectorDropdown.AddToClassList("selectorDropdown");
                m_SelectorDropdown.RegisterCallback <DragUpdatedEvent>(OnDragUpdate);
                m_SelectorDropdown.RegisterCallback <DragPerformEvent>(OnDragPerform);

                selectorContainer.Add(label);
                selectorContainer.Add(m_SelectorDropdown);
                Add(selectorContainer);
            }

            //Target label
            {
                m_TargetContainer = new VisualElement();
                m_TargetContainer.AddToClassList("targetContainer");
                var containerClick = new Clickable(OnTargetClicked);
                m_TargetContainer.AddManipulator(containerClick);

                Image gameObjectIcon = new Image();
                gameObjectIcon.AddToClassList("gameObjectIcon");
                gameObjectIcon.RegisterCallback <DragUpdatedEvent>(OnDragUpdate);
                gameObjectIcon.RegisterCallback <DragPerformEvent>(OnDragPerform);

                m_TargetLabel = new Label {
                    text = k_DefaultLabelText
                };
                m_TargetLabel.AddToClassList("previewLabel");
                m_TargetLabel.RegisterCallback <DragUpdatedEvent>(OnDragUpdate);
                m_TargetLabel.RegisterCallback <DragPerformEvent>(OnDragPerform);

                m_TargetContainer.Add(gameObjectIcon);
                m_TargetContainer.Add(m_TargetLabel);
                Add(m_TargetContainer);
            }

            RegisterCallback <DragUpdatedEvent>(OnDragUpdate);
            RegisterCallback <DragPerformEvent>(OnDragPerform);
        }