Esempio n. 1
0
        protected virtual void BuildUI()
        {
            AddToClassList(k_UssClassName);
            this.AddStylesheet("Port.uss");

            if (PortModel is IHasTitle)
            {
                List <string> additionalStylesheets = new List <string>();
                additionalStylesheets.Add("PortContent/Connector");
                GraphElementsHelper.LoadTemplateAndStylesheet(this, "PortContent/LabeledConnector", "ge-port-content", additionalStylesheets);
                ConnectorLabel  = this.Q <Label>("label");
                ConnectorBox    = this.Q(name: "connector");
                ConnectorBoxCap = this.Q(name: "cap");
            }
            else
            {
                GraphElementsHelper.LoadTemplateAndStylesheet(this, "PortContent/Connector", "ge-port-content");
                ConnectorBox    = this.Q(name: "connector");
                ConnectorBoxCap = this.Q(name: "cap");
            }

            if (ConnectorBox != null)
            {
                m_EdgeConnector = new EdgeConnector(Store, GraphView, new EdgeConnectorListener());
                ConnectorBox.AddManipulator(m_EdgeConnector);

                ConnectorBox.RegisterCallback <MouseEnterEvent>(OnMouseEnter);
                ConnectorBox.RegisterCallback <MouseLeaveEvent>(OnMouseLeave);
            }
        }
        protected override void BuildUI()
        {
            base.BuildUI();

            GraphElementsHelper.LoadTemplateAndStylesheet(this, "StickyNote", "ge-sticky-note");
            this.AddStylesheet("Selectable.uss");

            usageHints = UsageHints.DynamicTransform;

            m_Title        = this.MandatoryQ <Label>(name: "title");
            m_TitleField   = this.MandatoryQ <TextField>(name: "title-field");
            m_Content      = this.MandatoryQ <Label>(name: "contents");
            m_ContentField = this.MandatoryQ <TextField>(name: "contents-field");

            m_Title?.RegisterCallback <MouseDownEvent>(OnTitleMouseDown);

            m_TitleField.style.display = DisplayStyle.None;
            m_TitleField.Q("unity-text-input").RegisterCallback <BlurEvent>(OnTitleBlur);
            m_TitleField.multiline = true;
            m_TitleField.isDelayed = true;
            m_TitleField.RegisterCallback <ChangeEvent <string> >(OnContentChange);

            m_Content.RegisterCallback <MouseDownEvent>(OnContentsMouseDown);

            m_ContentField.style.display = DisplayStyle.None;
            m_ContentField.multiline     = true;
            m_ContentField.isDelayed     = true;
            m_ContentField.Q("unity-text-input").RegisterCallback <BlurEvent>(OnContentsBlur);
            m_ContentField.RegisterCallback <ChangeEvent <string> >(OnContentChange);

            AddToClassList("selectable");
        }
        public ResizableElement(string uiFile)
        {
            var 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));
                    }
                }
            }
        }
Esempio n. 4
0
        public BlackboardRow(VisualElement item, VisualElement propertyView)
        {
            var tpl = GraphElementsHelper.LoadUXML("BlackboardRow.uxml");

            this.AddStylesheet(Blackboard.StyleSheetPath);

            VisualElement mainContainer = tpl.Instantiate();

            mainContainer.AddToClassList("mainContainer");

            m_Root                  = mainContainer.Q("root");
            m_ItemContainer         = mainContainer.Q("itemContainer");
            m_PropertyViewContainer = mainContainer.Q("propertyViewContainer");

            m_ExpandButton = mainContainer.Q <Button>("expandButton");
            m_ExpandButton.clickable.clicked += () => expanded = !expanded;

            Add(mainContainer);

            ClearClassList();
            AddToClassList("blackboardRow");

            m_ItemContainer.Add(item);
            m_PropertyViewContainer.Add(propertyView);

            expanded = false;
        }
Esempio n. 5
0
        public BlackboardSection()
        {
            var tpl = GraphElementsHelper.LoadUXML("BlackboardSection.uxml");

            this.AddStylesheet(Blackboard.StyleSheetPath);
            m_MainContainer = tpl.Instantiate();
            m_MainContainer.AddToClassList("mainContainer");

            m_Header        = m_MainContainer.Q("sectionHeader");
            m_TitleLabel    = m_MainContainer.Q <Label>("sectionTitleLabel");
            m_RowsContainer = m_MainContainer.Q("rowsContainer");

            hierarchy.Add(m_MainContainer);

            m_DragIndicator = new VisualElement();

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

            ClearClassList();
            AddToClassList("blackboardSection");

            RegisterCallback <DragUpdatedEvent>(OnDragUpdatedEvent);
            RegisterCallback <DragPerformEvent>(OnDragPerformEvent);
            RegisterCallback <DragLeaveEvent>(OnDragLeaveEvent);

            m_InsertIndex = -1;
        }
        public IconBadge()
        {
            m_IsAttached = false;
            m_Distance   = kDefaultDistanceValue;
            var tpl = GraphElementsHelper.LoadUXML("IconBadge.uxml");

            LoadTemplate(tpl);

            RegisterCallback <CustomStyleResolvedEvent>(OnCustomStyleResolved);
            visualStyle = "error";
        }
Esempio n. 7
0
        public Edge()
        {
            GraphElementsHelper.LoadTemplateAndStylesheet(this, "Edge", "ge-edge");

            Container = this.Q("container");
            Debug.Assert(Container != null);

            this.AddManipulator(new EdgeManipulator());

            m_ContextualMenuManipulator = new ContextualMenuManipulator(BuildContextualMenu);
            this.AddManipulator(m_ContextualMenuManipulator);

            RegisterCallback <AttachToPanelEvent>(OnEdgeAttach);
            RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
        }
Esempio n. 8
0
        public EditableLabel()
        {
            SetIsCompositeRoot();
            focusable = true;

            GraphElementsHelper.LoadTemplateAndStylesheet(this, "EditableLabel", "ge-editable-label");

            m_Label     = this.Q <Label>(name: "label");
            m_TextField = this.Q <TextField>(name: "text-field");

            m_Label.RegisterCallback <MouseDownEvent>(OnLabelMouseDown);

            m_TextField.style.display = DisplayStyle.None;
            m_TextField.RegisterCallback <KeyDownEvent>(OnKeyDown);
            m_TextField.RegisterCallback <BlurEvent>(OnFieldBlur);
            m_TextField.RegisterCallback <ChangeEvent <string> >(OnChange);
            m_TextField.isDelayed = true;
        }
Esempio n. 9
0
        public Pill()
        {
            this.AddStylesheet("Pill.uss");

            var           tpl           = GraphElementsHelper.LoadUXML("Pill.uxml");
            VisualElement mainContainer = tpl.Instantiate();

            m_TitleLabel     = mainContainer.Q <Label>("title-label");
            m_Icon           = mainContainer.Q <Image>("icon");
            m_LeftContainer  = mainContainer.Q("input");
            m_RightContainer = mainContainer.Q("output");

            Add(mainContainer);

            AddToClassList("pill");

            UpdateVisibility();
            UpdateIconVisibility();
        }
        public BlackboardField(Texture icon, string text, string typeText)
        {
            var           tpl           = GraphElementsHelper.LoadUXML("BlackboardField.uxml");
            VisualElement mainContainer = tpl.Instantiate();

            this.AddStylesheet(Blackboard.StyleSheetPath);
            mainContainer.AddToClassList("mainContainer");
            mainContainer.pickingMode = PickingMode.Ignore;

            m_ContentItem = mainContainer.Q("contentItem");
            Assert.IsTrue(m_ContentItem != null);

            m_Pill = mainContainer.Q <Pill>("pill");
            Assert.IsTrue(m_Pill != null);

            m_TypeLabel = mainContainer.Q <Label>("typeLabel");
            Assert.IsTrue(m_TypeLabel != null);

            m_TextField = mainContainer.Q <TextField>("textField");
            Assert.IsTrue(m_TextField != null);

            m_TextField.style.display = DisplayStyle.None;

            var textinput = m_TextField.Q(TextField.textInputUssName);

            textinput.RegisterCallback <FocusOutEvent>(e => { OnEditTextFinished(); });

            Add(mainContainer);

            RegisterCallback <MouseDownEvent>(OnMouseDownEvent);

            ClearClassList();
            AddToClassList("blackboardField");

            this.text     = text;
            this.icon     = icon;
            this.typeText = typeText;

            this.AddManipulator(new SelectionDropper());
            this.AddManipulator(new ContextualMenuManipulator(BuildContextualMenu));
        }
Esempio n. 11
0
        protected override void BuildUI()
        {
            base.BuildUI();

            GraphElementsHelper.LoadTemplateAndStylesheet(this, "PlacematElement", "ge-placemat");

            AddToClassList("placemat");
            AddToClassList("selectable");

            m_TitleField           = this.Q <TextField>();
            m_TitleField.isDelayed = true;

            m_CollapseButton          = this.Q <Button>();
            m_CollapseButton.clicked += () => Collapsed = !Collapsed;
            m_CollapseButton.AddToClassList("placematCollapse");

            m_Resizer = this.Q <ResizableElement>();

            // PF: Fix this: Placemats are automatically added whereas other elements need to be added manually
            // with GraphView.AddElement. Furthermore, calling GraphView.AddElement(placemat) will remove it
            // from the placemat container and add it to the layer 0.
            GraphView.placematContainer.AddPlacemat(this);
        }
Esempio n. 12
0
        public StackNode()
        {
            // PF: Dirty hack
            Clear();
            var tpl = GraphElementsHelper.LoadUXML("StackNode.uxml");

            tpl.CloneTree(this);

            VisualElement stackNodeContentContainerPlaceholder = this.Q("stackNodeContentContainerPlaceholder");

            headerContainer        = this.Q("stackNodeHeaderContainer");
            m_SeparatorContainer   = this.Q("stackSeparatorContainer");
            m_PlaceholderContainer = this.Q("stackPlaceholderContainer");
            m_PlaceholderContainer.Add(m_Placeholder = new StackNodePlaceholder("Spacebar to Add Node"));

            m_ContentContainer      = new StackNodeContentContainer();
            m_ContentContainer.name = "stackNodeContentContainer";

            stackNodeContentContainerPlaceholder.Add(m_ContentContainer);

            ClearClassList();
            AddToClassList("stack-node");
            this.AddStylesheet("StackNode.uss");
        }