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");
        }
예제 #2
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);
            }
        }
예제 #3
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);
        }
예제 #4
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;
        }
예제 #5
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);
        }