protected GraphView() { selection = new List <ISelectable>(); clippingOptions = ClippingOptions.ClipContents; contentViewContainer = new ContentViewContainer { name = "contentViewContainer", clippingOptions = ClippingOptions.NoClipping, pickingMode = PickingMode.Ignore }; // make it absolute and 0 sized so it acts as a transform to move children to and fro Add(contentViewContainer); AddStyleSheetPath("StyleSheets/GraphView/GraphView.uss"); graphElements = contentViewContainer.Query <GraphElement>().Where(e => !(e is Port)).Build(); nodes = contentViewContainer.Query <Node>().Build(); edges = this.Query <Layer>().Children <Edge>().Build(); ports = contentViewContainer.Query().Children <Layer>().Descendents <Port>().Build(); m_ElementsToRemove = new List <GraphElement>(); m_GraphViewChange.elementsToRemove = m_ElementsToRemove; isReframable = true; focusIndex = 0; RegisterCallback <ValidateCommandEvent>(OnValidateCommand); RegisterCallback <ExecuteCommandEvent>(OnExecuteCommand); RegisterCallback <AttachToPanelEvent>(OnEnterPanel); RegisterCallback <DetachFromPanelEvent>(OnLeavePanel); RegisterCallback <ContextualMenuPopulateEvent>(OnContextualMenu); // We override the font for all GraphElements here so we can use the fallback system. // We load the dummy font first and then we overwrite the fontNames, just like we do // with the Editor's default font asset. Loading system fonts directly via // Font.CreateDynamicFontFromOSFont() caused TextMesh to generate the wrong bounds. // // TODO: Add font fallback specifications and use of system fonts to USS. if (!m_FontsOverridden && (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)) { Font graphViewFont = EditorGUIUtility.LoadRequired("GraphView/DummyFont(LucidaGrande).ttf") as Font; if (Application.platform == RuntimePlatform.WindowsEditor) { graphViewFont.fontNames = new string[] { "Segoe UI", "Helvetica Neue", "Helvetica", "Arial", "Verdana" } } ; else if (Application.platform == RuntimePlatform.OSXEditor) { graphViewFont.fontNames = new string[] { "Helvetica Neue", "Lucida Grande" } } ; m_FontsOverridden = true; } }
protected GraphView(IStore store) { m_Store = store; AddToClassList("graphView"); this.SetRenderHintsForGraphView(); selection = new List <ISelectable>(); style.overflow = Overflow.Hidden; style.flexDirection = FlexDirection.Column; graphViewContainer = new VisualElement(); graphViewContainer.style.flexGrow = 1f; graphViewContainer.style.flexBasis = 0f; graphViewContainer.pickingMode = PickingMode.Ignore; hierarchy.Add(graphViewContainer); contentViewContainer = new ContentViewContainer { name = "contentViewContainer", pickingMode = PickingMode.Ignore, usageHints = UsageHints.GroupTransform }; // make it absolute and 0 sized so it acts as a transform to move children to and fro graphViewContainer.Add(contentViewContainer); this.AddStylesheet("GraphView.uss"); graphElements = contentViewContainer.Query <GraphElement>().Build(); allGraphElements = this.Query <GraphElement>().Build(); nodes = contentViewContainer.Query <Node>().Build(); edges = this.Query <Layer>().Children <Edge>().Build(); ports = contentViewContainer.Query().Children <Layer>().Descendents <Port>().Build(); m_ElementsToRemove = new List <GraphElement>(); m_GraphViewChange.elementsToRemove = m_ElementsToRemove; isReframable = true; focusable = true; RegisterCallback <ValidateCommandEvent>(OnValidateCommand); RegisterCallback <ExecuteCommandEvent>(OnExecuteCommand); RegisterCallback <AttachToPanelEvent>(OnEnterPanel); RegisterCallback <DetachFromPanelEvent>(OnLeavePanel); RegisterCallback <ContextualMenuPopulateEvent>(OnContextualMenu); }