/// <summary> /// Inits docking proxy windows. /// </summary> /// <param name="initSize">Initial size of the proxy window.</param> public static void Init(ref Vector2 initSize) { if (Window == null) { // Create proxy window CreateWindowSettings settings = CreateWindowSettings.Default; settings.Title = "DockHint.Window"; settings.Size = initSize; settings.AllowInput = true; settings.AllowMaximize = false; settings.AllowMinimize = false; settings.HasBorder = false; settings.HasSizingFrame = false; settings.IsRegularWindow = false; settings.SupportsTransparency = true; settings.ShowInTaskbar = false; settings.ShowAfterFirstPaint = true; settings.IsTopmost = true; Window = FlaxEngine.Window.Create(settings); // Set opacity and background color Window.Opacity = 0.6f; Window.GUI.BackgroundColor = Style.Current.DragWindow; } else { // Resize proxy Window.ClientSize = initSize; } InitHitProxy(); }
/// <inheritdoc /> public override void OnExit() { // Shutdown windows for (int i = 0; i < Windows.Count; i++) { Windows[i].OnExit(); } // Unbind events SceneManager.OnSceneSaveError -= OnSceneSaveError; SceneManager.OnSceneLoaded -= OnSceneLoaded; SceneManager.OnSceneLoadError -= OnSceneLoadError; SceneManager.OnSceneLoading -= OnSceneLoading; SceneManager.OnSceneSaved -= OnSceneSaved; SceneManager.OnSceneSaving -= OnSceneSaving; SceneManager.OnSceneUnloaded -= OnSceneUnloaded; SceneManager.OnSceneUnloading -= OnSceneUnloading; // Close main window MainWindow?.Close(ClosingReason.EngineExit); MainWindow = null; // Close all windows var windows = Window.Windows.ToArray(); for (int i = 0; i < windows.Length; i++) { if (windows[i].IsVisible) { windows[i].Close(ClosingReason.EngineExit); } } }
private static void CreateProxy(ref FlaxEngine.Window win, string name) { if (win != null) { return; } CreateWindowSettings settings = CreateWindowSettings.Default; settings.Title = name; settings.Size = new Vector2(HintWindowsSize); settings.AllowInput = false; settings.AllowMaximize = false; settings.AllowMinimize = false; settings.HasBorder = false; settings.HasSizingFrame = false; settings.IsRegularWindow = false; settings.SupportsTransparency = true; settings.ShowInTaskbar = false; settings.ActivateWhenFirstShown = false; settings.IsTopmost = true; win = FlaxEngine.Window.Create(settings); win.Opacity = 0.6f; win.GUI.BackgroundColor = Style.Current.DragWindow; }
/// <inheritdoc /> public override void OnExit() { // Unbind events Level.SceneSaveError -= OnSceneSaveError; Level.SceneLoaded -= OnSceneLoaded; Level.SceneLoadError -= OnSceneLoadError; Level.SceneLoading -= OnSceneLoading; Level.SceneSaved -= OnSceneSaved; Level.SceneSaving -= OnSceneSaving; Level.SceneUnloaded -= OnSceneUnloaded; Level.SceneUnloading -= OnSceneUnloading; ScriptsBuilder.ScriptsReloadEnd -= OnScriptsReloadEnd; Editor.StateMachine.StateChanged -= OnEditorStateChanged; // Close main window MainWindow?.Close(ClosingReason.EngineExit); MainWindow = null; // Close all windows var windows = Windows.ToArray(); for (int i = 0; i < windows.Length; i++) { if (windows[i] != null) { windows[i].Close(ClosingReason.EngineExit); } } }
private static void HideProxy(ref FlaxEngine.Window win) { if (win) { win.Hide(); } }
private void OnClosing(ClosingReason reason, ref bool cancel) { // Check if can close window if (CanCloseWindow(reason)) { if (reason == ClosingReason.User) { _result = DialogResult.Cancel; } // Clean up _window = null; // Check if any thead is blocked during ShowDialog, then wait for it bool wait = true; while (wait) { wait = Interlocked.Read(ref _isWaitingForDialog) > 0; Thread.Sleep(1); } // Close window return; } // Suppress closing cancel = true; }
/// <inheritdoc /> public override void OnInit() { Assert.IsNull(MainWindow); _windowsLayoutPath = StringUtils.CombinePaths(Globals.ProjectCacheFolder, "WindowsLayout.xml"); // Create main window var dpiScale = Platform.DpiScale; var settings = CreateWindowSettings.Default; settings.Title = "Flax Editor"; settings.Size = new Vector2(1300 * dpiScale, 900 * dpiScale); settings.StartPosition = WindowStartPosition.CenterScreen; if (!Editor.Instance.Options.Options.Interface.UseNativeWindowSystem) { settings.HasBorder = false; settings.HasSizingFrame = false; } MainWindow = Window.Create(settings); if (MainWindow == null) { // Error Editor.LogError("Failed to create editor main window!"); return; } UpdateWindowTitle(); // Link for main window events MainWindow.Closing += MainWindow_OnClosing; MainWindow.Closed += MainWindow_OnClosed; // Create default editor windows ContentWin = new ContentWindow(Editor); EditWin = new EditGameWindow(Editor); GameWin = new GameWindow(Editor); PropertiesWin = new PropertiesWindow(Editor); SceneWin = new SceneTreeWindow(Editor); DebugLogWin = new DebugLogWindow(Editor); OutputLogWin = new OutputLogWindow(Editor); ToolboxWin = new ToolboxWindow(Editor); GraphicsQualityWin = new GraphicsQualityWindow(Editor); GameCookerWin = new GameCookerWindow(Editor); ProfilerWin = new ProfilerWindow(Editor); EditorOptionsWin = new EditorOptionsWindow(Editor); PluginsWin = new PluginsWindow(Editor); // Bind events SceneManager.SceneSaveError += OnSceneSaveError; SceneManager.SceneLoaded += OnSceneLoaded; SceneManager.SceneLoadError += OnSceneLoadError; SceneManager.SceneLoading += OnSceneLoading; SceneManager.SceneSaved += OnSceneSaved; SceneManager.SceneSaving += OnSceneSaving; SceneManager.SceneUnloaded += OnSceneUnloaded; SceneManager.SceneUnloading += OnSceneUnloading; ScriptsBuilder.ScriptsReloadEnd += OnScriptsReloadEnd; }
private static void DisposeProxy(ref FlaxEngine.Window win) { if (win) { win.Close(ClosingReason.User); win = null; } }
private static void SaveBounds(XmlWriter writer, Window win) { var bounds = win.ClientBounds; writer.WriteAttributeString("X", bounds.X.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("Y", bounds.Y.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("Width", bounds.Width.ToString(CultureInfo.InvariantCulture)); writer.WriteAttributeString("Height", bounds.Height.ToString(CultureInfo.InvariantCulture)); }
/// <summary> /// Closes this dialog. /// </summary> public void Close() { if (_window != null) { var win = _window; _window = null; win.Close(); } }
/// <summary> /// Gathers input from the specified window. /// </summary> /// <param name="window">The window.</param> public void Gather(FlaxEngine.Window window) { IsControlDown = window.GetKey(Keys.Control); IsShiftDown = window.GetKey(Keys.Shift); IsAltDown = window.GetKey(Keys.Alt); IsMouseRightDown = window.GetMouseButton(MouseButton.Right); IsMouseMiddleDown = window.GetMouseButton(MouseButton.Middle); IsMouseLeftDown = window.GetMouseButton(MouseButton.Left); }
/// <inheritdoc /> public override void OnInit() { Assert.IsNull(MainWindow); _windowsLayoutPath = StringUtils.CombinePaths(Globals.ProjectCacheFolder, "WindowsLayout.xml"); // Create main window var settings = CreateWindowSettings.Default; settings.Title = "Flax Editor"; settings.Size = new Vector2(1300, 900); settings.StartPosition = WindowStartPosition.CenterScreen; MainWindow = Window.Create(settings); if (MainWindow == null) { // Error Debug.LogError("Failed to create editor main window!"); return; } UpdateWindowTitle(); // Link for main window events MainWindow.OnClosing += MainWindow_OnClosing; MainWindow.OnClosed += MainWindow_OnClosed; // Create default editor windows ContentWin = new ContentWindow(Editor); EditWin = new EditGameWindow(Editor); GameWin = new GameWindow(Editor); PropertiesWin = new PropertiesWindow(Editor); SceneWin = new SceneTreeWindow(Editor); DebugWin = new DebugLogWindow(Editor); ToolboxWin = new ToolboxWindow(Editor); GraphicsQualityWin = new GraphicsQualityWindow(Editor); GameCookerWin = new GameCookerWindow(Editor); ProfilerWin = new ProfilerWindow(Editor); EditorOptionsWin = new EditorOptionsWindow(Editor); // Bind events SceneManager.SceneSaveError += OnSceneSaveError; SceneManager.SceneLoaded += OnSceneLoaded; SceneManager.SceneLoadError += OnSceneLoadError; SceneManager.SceneLoading += OnSceneLoading; SceneManager.SceneSaved += OnSceneSaved; SceneManager.SceneSaving += OnSceneSaving; SceneManager.SceneUnloaded += OnSceneUnloaded; SceneManager.SceneUnloading += OnSceneUnloading; }
private void MainWindow_OnClosed() { Editor.Log("Main window is closed"); MainWindow = null; // Capture project icon screenshot (not in play mode and if editor was used for some time) if (!Editor.StateMachine.IsPlayMode && Time.TimeSinceStartup >= 5.0f) { Editor.Log("Capture project icon screenshot"); _projectIconScreenshotTimeout = Time.TimeSinceStartup + 0.8f; // wait 800ms for a screenshot task EditWin.Viewport.SaveProjectIcon(); } else { // Close editor Application.Exit(); } }
/// <summary> /// Shows the dialog and waits for the result. /// </summary> /// <param name="parentWindow">The parent window.</param> /// <returns>The dialog result.</returns> public DialogResult ShowDialog(FlaxEngine.Window parentWindow) { // Show window Show(parentWindow); // Set wait flag Interlocked.Increment(ref _isWaitingForDialog); // Wait for the closing do { Thread.Sleep(1); } while (_window); // Clear wait flag Interlocked.Decrement(ref _isWaitingForDialog); return(_result); }
/// <summary> /// Shows the dialog. /// </summary> /// <param name="parentWindow">The parent window.</param> public void Show(FlaxEngine.Window parentWindow) { // Setup initial window settings CreateWindowSettings settings = CreateWindowSettings.Default; settings.Title = _title; settings.Size = Size; settings.AllowMaximize = false; settings.AllowMinimize = false; settings.HasSizingFrame = false; settings.StartPosition = WindowStartPosition.CenterParent; settings.Parent = parentWindow; SetupWindowSettings(ref settings); // Create window _window = FlaxEngine.Window.Create(settings); var windowGUI = _window.GUI; // Attach events _window.Closing += OnClosing; _window.Closed += OnClosed; // Link to the window Parent = windowGUI; // Show _window.Show(); _window.Focus(); _window.FlashWindow(); // Perform layout windowGUI.UnlockChildrenRecursive(); windowGUI.PerformLayout(); OnShow(); }
/// <inheritdoc /> public override void OnInit() { Assert.IsNull(MainWindow); _windowsLayoutPath = StringUtils.CombinePaths(Globals.ProjectCacheFolder, "WindowsLayout.xml"); // Create main window var dpiScale = Platform.DpiScale; var settings = CreateWindowSettings.Default; settings.Title = "Flax Editor"; settings.Size = Platform.DesktopSize; settings.StartPosition = WindowStartPosition.CenterScreen; settings.ShowAfterFirstPaint = true; #if PLATFORM_WINDOWS if (!Editor.Instance.Options.Options.Interface.UseNativeWindowSystem) #endif { settings.HasBorder = false; #if PLATFORM_WINDOWS // Skip OS sizing frame and implement it using LeftButtonHit settings.HasSizingFrame = false; #endif } MainWindow = Platform.CreateWindow(ref settings); if (MainWindow == null) { // Error Editor.LogError("Failed to create editor main window!"); return; } UpdateWindowTitle(); // Link for main window events MainWindow.Closing += MainWindow_OnClosing; MainWindow.Closed += MainWindow_OnClosed; // Create default editor windows ContentWin = new ContentWindow(Editor); EditWin = new EditGameWindow(Editor); GameWin = new GameWindow(Editor); PropertiesWin = new PropertiesWindow(Editor); SceneWin = new SceneTreeWindow(Editor); DebugLogWin = new DebugLogWindow(Editor); OutputLogWin = new OutputLogWindow(Editor); ToolboxWin = new ToolboxWindow(Editor); GraphicsQualityWin = new GraphicsQualityWindow(Editor); GameCookerWin = new GameCookerWindow(Editor); ProfilerWin = new ProfilerWindow(Editor); EditorOptionsWin = new EditorOptionsWindow(Editor); PluginsWin = new PluginsWindow(Editor); VisualScriptDebuggerWin = new VisualScriptDebuggerWindow(Editor); // Bind events Level.SceneSaveError += OnSceneSaveError; Level.SceneLoaded += OnSceneLoaded; Level.SceneLoadError += OnSceneLoadError; Level.SceneLoading += OnSceneLoading; Level.SceneSaved += OnSceneSaved; Level.SceneSaving += OnSceneSaving; Level.SceneUnloaded += OnSceneUnloaded; Level.SceneUnloading += OnSceneUnloading; ScriptsBuilder.ScriptsReloadEnd += OnScriptsReloadEnd; Editor.StateMachine.StateChanged += OnEditorStateChanged; }
private void OnClosed() { _window = null; }