예제 #1
0
        private static void MVMenuItem()
        {
            var mainView = FullscreenUtility.GetMainView();

            if (FullscreenUtility.IsLinux)
            {
                if (wmctrl.IsInstalled)
                {
                    wmctrl.ToggleNativeFullscreen(mainView);
                }
                else
                {
                    Logger.Warning("wmctrl not installed, cannot fullscreen main view. Install it using 'sudo apt-get install wmctrl'");
                }
                return;
            }

            if (!mainView)
            {
                Logger.Error("No Main View found, this should not happen");
                return;
            }

            Fullscreen.ToggleFullscreen(mainView);
        }
예제 #2
0
 private static void CloseAll()
 {
     foreach (var fs in Fullscreen.GetAllFullscreen())
     {
         fs.Close();
     }
 }
예제 #3
0
        private static EditorWindow FindCandidateForFullscreen(Type type, EditorWindow mainCandidate = null)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (!type.IsOfType(typeof(EditorWindow)))
            {
                throw new ArgumentException("Invalid type, type must inherit from UnityEditor.EditorWindow", "type");
            }

            if (mainCandidate && !mainCandidate.IsOfType(type))
            {
                throw new ArgumentException("Main candidate type must match the type argument or be null", "mainCandidate");
            }

            // if (mainCandidate && !Fullscreen.GetFullscreenFromView(mainCandidate))
            if (mainCandidate)
            {
                return(mainCandidate); // Our candidate is not null and is not fullscreened either
            }
            return(Resources           // Returns the first window of our type that is not in fullscreen
                   .FindObjectsOfTypeAll(type)
                   .Cast <EditorWindow>()
                   .FirstOrDefault(window => !Fullscreen.GetFullscreenFromView(window)));
        }
예제 #4
0
        internal void OpenView(Rect rect, ScriptableObject view)
        {
            if (!view)
            {
                throw new ArgumentNullException("view");
            }

            view.EnsureOfType(Types.View);

            if (FullscreenUtility.IsLinux)
            {
                throw new PlatformNotSupportedException("Linux does not support fullscreen from View class");
            }

            if (Fullscreen.GetFullscreenFromView(view))
            {
                Logger.Debug("Tried to fullscreen a view already in fullscreen");
                return;
            }

            BeforeOpening();

            var placeholder = CreateInstance <PlaceholderWindow>();

            m_src = new ViewPyramid(view);
            m_dst = CreateFullscreenViewPyramid(rect, placeholder);

            SwapViews(m_src.View, m_dst.View);
            Rect = rect;

            AfterOpening();
        }
예제 #5
0
        private static void MVMenuItem()
        {
            var mainView = FullscreenUtility.GetMainView();

            if (!mainView)
            {
                return; // This should never happen
            }
            Fullscreen.ToggleFullscreen(mainView);
        }
예제 #6
0
        internal void OpenWindow(Rect rect, Type type, EditorWindow window = null, bool disposableWindow = false)
        {
            if (type == null)
            {
                throw new ArgumentNullException("type");
            }

            if (!type.IsOfType(typeof(EditorWindow)))
            {
                throw new ArgumentException("Type must be inherited from UnityEditor.EditorWindow", "type");
            }

            if (window is PlaceholderWindow)
            {
                FullscreenUtility.ShowFullscreenNotification(window, "Wanna fullscreen the placeholder?\nSorry, not possible");
                Logger.Debug("Tried to fullscreen a placeholder window");
                return;
            }

            if (Fullscreen.GetFullscreenFromView(window))
            {
                FullscreenUtility.ShowFullscreenNotification(window, "You can't fullscreen a window already in fullscreen");
                Logger.Debug("Tried to fullscreen a view already in fullscreen");
                return;
            }

            BeforeOpening();

            if (window)
            {
                m_src = new ViewPyramid(window);
            }

            var childWindow = window ?
                              (EditorWindow)CreateInstance <PlaceholderWindow>() :
                              (EditorWindow)CreateInstance(type); // Instantiate a new window for this fullscreen

            m_dst = CreateFullscreenViewPyramid(rect, childWindow);

            if (window) // We can't swap the src window if we didn't create a placeholder window
            {
                SwapWindows(m_src.Window, m_dst.Window);
            }

            Rect = rect;

            if (disposableWindow && childWindow is PlaceholderWindow)
            {
                childWindow.Close(); // Close the pyramid we created because disposable views are not restore later
                m_dst.Window = m_src.Window;
            }

            AfterOpening();
        }
예제 #7
0
        /// <summary>Returns the parent <see cref="FullscreenContainer"/> for a given view or window, or null if it's not in fullscreen.</summary>
        /// <param name="rootView">Compare by the root view, otherwise compare by the container.</param>
        public static FullscreenContainer GetFullscreenFromView(ScriptableObject viewOrWindow, bool rootView = true)
        {
            if (!viewOrWindow)
            {
                return(null);
            }

            var pyramid = new ViewPyramid(viewOrWindow);

            return(Fullscreen
                   .GetAllFullscreen()
                   .FirstOrDefault(fullscreen => rootView ?
                                   fullscreen.ActualViewPyramid.View == pyramid.View :
                                   fullscreen.ActualViewPyramid.Container == pyramid.Container
                                   ));
        }
예제 #8
0
        private static void SetIsPlaying(bool playing)
        {
            var fullscreens = Fullscreen.GetAllFullscreen()
                              .Select(fullscreen => fullscreen as FullscreenWindow)
                              .Where(fullscreen => fullscreen);

            // We close all the game views created on play, even if the option was disabled in the middle of the play mode
            // This is done to best reproduce the default behaviour of the maximize on play
            if (!playing)
            {
                foreach (var fs in fullscreens)
                {
                    if (fs && fs.CreatedByFullscreenOnPlay) // fs might have been destroyed
                    {
                        fs.Close();
                    }
                }
                return;
            }

            if (!FullscreenPreferences.FullscreenOnPlayEnabled)
            {
                return; // Nothing to do here
            }
            var gameView = FullscreenUtility
                           .GetGameViews()
                           .FirstOrDefault(gv => gv && gv.GetPropertyValue <bool>("maximizeOnPlay"));

            if (!gameView && FullscreenUtility.GetGameViews().Length > 0)
            {
                return;
            }

            foreach (var fs in fullscreens)
            {
                if (fs && fs.Rect.Overlaps(gameView.position)) // fs might have been destroyed
                {
                    return;                                    // We have an open fullscreen where the new one would be, so let it there
                }
            }
            if (gameView && Fullscreen.GetFullscreenFromView(gameView))
            {
                return; // The gameview is already in fullscreen
            }
            var gvfs = Fullscreen.MakeFullscreen(Types.GameView, gameView);
            gvfs.CreatedByFullscreenOnPlay = true;
        }
예제 #9
0
        // This should not be a static method, as static has no this
        // However, the 'this' in the method is unreliable and should be casted before using
        private void OnGUI()
        {
            var _this        = (object)this as SceneView;
            var vp           = new ViewPyramid(_this);
            var shouldRender = Fullscreen.GetFullscreenFromView(vp.Container, false); // Render if this window is in fullscreen

            _this.camera.gameObject.SetActive(shouldRender);

            if (shouldRender)
            {
                patcher.InvokeOriginal(_this); // This possibly throws a ExitGUIException
            }
            else
            {
                CustomOnGUI();
            }
        }
예제 #10
0
        protected override void AfterOpening()
        {
            base.AfterOpening();

            Focus();

            if (m_src.Window)
            {
                m_dst.Window.titleContent = m_src.Window.titleContent; // Copy the title of the window to the placeholder
            }
            SetToolbarStatus(FullscreenPreferences.ToolbarVisible);    // Hide/show the toolbar
            // macOS doesn't like fast things, so we'll wait a bit and do it again
            // Looks like Linux does not like it too
            After.Milliseconds(100d, () => SetToolbarStatus(FullscreenPreferences.ToolbarVisible));

            var notificationWindow = ActualViewPyramid.Window;

            After.Milliseconds(50d, () => {
                if (!notificationWindow) // Might have been closed
                {
                    return;
                }

                var menuItemPath = string.Empty;
                if (notificationWindow.IsOfType(Types.GameView))
                {
                    menuItemPath = Fullscreen
                                   .GetAllFullscreen()
                                   .Where(fs => fs.ActualViewPyramid.Window && fs.ActualViewPyramid.Window.IsOfType(Types.GameView))
                                   .Count() > 1 ?
                                   Shortcut.MOSAIC_PATH :
                                   Shortcut.GAME_VIEW_PATH;
                }
                else if (notificationWindow is SceneView)
                {
                    menuItemPath = Shortcut.SCENE_VIEW_PATH;
                }
                else
                {
                    menuItemPath = Shortcut.CURRENT_VIEW_PATH;
                }

                FullscreenUtility.ShowFullscreenExitNotification(notificationWindow, menuItemPath);
            });
        }
예제 #11
0
        private static void CVMenuItem()
        {
            var focusedView = FullscreenUtility.GetFocusedViewOrWindow();

            if (!focusedView)
            {
                return;
            }

            if (focusedView is EditorWindow)
            {
                Fullscreen.ToggleFullscreen(focusedView as EditorWindow);
            }
            else
            {
                Fullscreen.ToggleFullscreen(focusedView);
            }
        }
예제 #12
0
        private static void MVMenuItem()
        {
            var mainView = FullscreenUtility.GetMainView();

            if (FullscreenUtility.IsLinux)
            {
                wmctrl.ToggleNativeFullscreen(mainView);
                return;
            }

            if (!mainView)
            {
                Logger.Error("No Main View found, this should not happen");
                return;
            }

            Fullscreen.ToggleFullscreen(mainView);
        }
예제 #13
0
        private static void CVMenuItem()
        {
            var focusedView = FullscreenUtility.IsLinux ?
                              EditorWindow.focusedWindow : // Linux does not support View fullscreen, only EditorWindow
                              FullscreenUtility.GetFocusedViewOrWindow();

            if (!focusedView || focusedView is PlaceholderWindow)
            {
                return;
            }

            if (focusedView is EditorWindow)
            {
                Fullscreen.ToggleFullscreen(focusedView as EditorWindow);
            }
            else
            {
                Fullscreen.ToggleFullscreen(focusedView);
            }
        }
예제 #14
0
        public static void BringWindowsAbove()
        {
            if (!FullscreenPreferences.KeepFullscreenBelow)
            {
                return;
            }

            var fullscreens = Fullscreen.GetAllFullscreen();

            if (fullscreens.Length == 0)
            {
                return;
            }

            var methodName = "Internal_BringLiveAfterCreation";
            var windows    = GetAllContainerWindowsOrdered()
                             .Where(w => !Fullscreen.GetFullscreenFromView(w))
                             .Where(w => {
                if (w.GetPropertyValue <int>("showMode") == (int)ShowMode.MainWindow)
                {
                    return(false);    // Main Window should be kept below everything
                }
                if (fullscreens.FirstOrDefault((f) => f.m_src.Container == w))
                {
                    return(false);    // Keep other fullscreen containers below
                }
                return(true);
            });

            foreach (var w in windows)
            {
                if (w.HasMethod(methodName, new Type[] { typeof(bool), typeof(bool), typeof(bool) }))
                {
                    w.InvokeMethod(methodName, true, false, false);
                }
                else
                {
                    w.InvokeMethod(methodName, true, false);
                }
            }
        }
예제 #15
0
        private static void Init()
        {
            // Initial
            RenderingDisabled = Fullscreen.GetAllFullscreen().Length > 0;

            // On preferences change
            FullscreenPreferences.DisableSceneViewRendering.OnValueSaved += (v) =>
                                                                            RenderingDisabled = v && Fullscreen.GetAllFullscreen().Length > 0;

            // On fullscreen open
            FullscreenCallbacks.afterFullscreenOpen += (f) =>
                                                       RenderingDisabled = true;

            // Disable the patching if we're the last fullscreen open
            FullscreenCallbacks.afterFullscreenClose += (f) => {
                if (Fullscreen.GetAllFullscreen().Length <= 1)
                {
                    RenderingDisabled = false;
                }
            };
        }
예제 #16
0
        private static void MosaicMenuItem()
        {
            var openFullscreens = Fullscreen.GetAllFullscreen();

            if (openFullscreens.Length > 0)
            {
                foreach (var fs in openFullscreens)
                {
                    fs.Close();
                }
                return;
            }

            var displays = DisplayInfo
                           .GetDisplays()
                           .Where(d => (d.displayDevice.StateFlags & DisplayDeviceStateFlags.AttachedToDesktop) != 0)
                           .ToList();

            for (var i = 0; i < displays.Count && i < 8; i++)
            {
                var candidate = FindCandidateForFullscreen(Types.GameView, FullscreenUtility.GetMainGameView());

                if (candidate)
                {
                    candidate = EditorWindow.Instantiate(candidate);
                    candidate.Show();
                }

                var fs            = Fullscreen.MakeFullscreen(Types.GameView, candidate, true);
                var gameView      = fs.ActualViewPyramid.Window;
                var targetDisplay = FullscreenPreferences.MosaicMapping.Value[i];

                fs.Rect = displays[i].DpiCorrectedArea;
                FullscreenUtility.SetGameViewDisplayTarget(gameView, targetDisplay);
            }
        }
예제 #17
0
 private static bool CloseAllValidate()
 {
     return(Fullscreen.GetAllFullscreen().Length > 0);
 }
예제 #18
0
        private static void SVMenuItem()
        {
            var sceneView = FindCandidateForFullscreen <SceneView>(SceneView.lastActiveSceneView);

            Fullscreen.ToggleFullscreen(sceneView);
        }
예제 #19
0
        private static void GVMenuItem()
        {
            var gameView = FindCandidateForFullscreen(Types.GameView, FullscreenUtility.GetMainGameView());

            Fullscreen.ToggleFullscreen(Types.GameView, gameView);
        }