Example #1
0
        static void ListenToSearcherSize(GraphToolState graphToolState, string usage, EditorWindow existingWindow = null)
        {
            // This is a retro engineering of the searcher to get changes in the window size and splitter position
            var searcherWindow  = existingWindow != null ? existingWindow : EditorWindow.GetWindow <Searcher.SearcherWindow>();
            var searcherResizer = searcherWindow.rootVisualElement.Q("windowResizer");
            var rightPanel      = searcherWindow.rootVisualElement.Q("windowDetailsVisualContainer");
            var leftPanel       = searcherWindow.rootVisualElement.Q("searcherVisualContainer");

            if (searcherResizer != null)
            {
                EventCallback <GeometryChangedEvent> callback = evt =>
                {
                    float ratio = 1.0f;
                    if (rightPanel != null && leftPanel != null)
                    {
                        ratio = rightPanel.resolvedStyle.flexGrow / leftPanel.resolvedStyle.flexGrow;
                    }

                    // PF FIXME Use command?
                    graphToolState.SetSearcherSize(usage ?? "", searcherWindow.position.size, ratio);
                };

                searcherWindow.rootVisualElement.RegisterCallback(callback);
                leftPanel?.RegisterCallback(callback);
            }
        }