Add flag for Window types
This commit is contained in:
@@ -259,7 +259,7 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
desc.AllowMaximize = false;
|
||||
desc.AllowDragAndDrop = false;
|
||||
desc.IsTopmost = true;
|
||||
desc.IsRegularWindow = false;
|
||||
desc.Type = WindowType.Utility;
|
||||
desc.HasSizingFrame = false;
|
||||
OnWindowCreating(ref desc);
|
||||
_window = Platform.CreateWindow(ref desc);
|
||||
|
||||
@@ -441,7 +441,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
settings.AllowMinimize = false;
|
||||
settings.HasBorder = false;
|
||||
settings.HasSizingFrame = false;
|
||||
settings.IsRegularWindow = false;
|
||||
settings.Type = WindowType.Utility;
|
||||
settings.SupportsTransparency = true;
|
||||
settings.ShowInTaskbar = false;
|
||||
settings.ShowAfterFirstPaint = false;
|
||||
@@ -488,7 +488,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
settings.AllowMinimize = false;
|
||||
settings.HasBorder = false;
|
||||
settings.HasSizingFrame = false;
|
||||
settings.IsRegularWindow = false;
|
||||
settings.Type = WindowType.Utility;
|
||||
settings.SupportsTransparency = true;
|
||||
settings.ShowInTaskbar = false;
|
||||
settings.ActivateWhenFirstShown = false;
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace FlaxEditor.GUI.Docking
|
||||
settings.AllowMaximize = true;
|
||||
settings.AllowDragAndDrop = true;
|
||||
settings.IsTopmost = false;
|
||||
settings.IsRegularWindow = true;
|
||||
settings.Type = WindowType.Regular;
|
||||
settings.HasSizingFrame = true;
|
||||
settings.ShowAfterFirstPaint = false;
|
||||
settings.ShowInTaskbar = true;
|
||||
|
||||
@@ -165,7 +165,7 @@ void SplashScreen::Show()
|
||||
settings.AllowMaximize = false;
|
||||
settings.AllowDragAndDrop = false;
|
||||
settings.IsTopmost = false;
|
||||
settings.IsRegularWindow = false;
|
||||
settings.Type = WindowType::Utility;
|
||||
settings.HasSizingFrame = false;
|
||||
settings.ShowAfterFirstPaint = true;
|
||||
settings.StartPosition = WindowStartPosition::CenterScreen;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace FlaxEngine
|
||||
AllowMinimize = true,
|
||||
AllowMaximize = true,
|
||||
AllowDragAndDrop = true,
|
||||
IsRegularWindow = true,
|
||||
Type = WindowType.Regular,
|
||||
HasSizingFrame = true,
|
||||
ShowAfterFirstPaint = true,
|
||||
};
|
||||
|
||||
@@ -26,6 +26,32 @@ API_ENUM() enum class WindowStartPosition
|
||||
Manual,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the type of the window.
|
||||
/// </summary>
|
||||
API_ENUM() enum class WindowType
|
||||
{
|
||||
/// <summary>
|
||||
/// Regular window.
|
||||
/// </summary>
|
||||
Regular,
|
||||
|
||||
/// <summary>
|
||||
/// Utility window.
|
||||
/// </summary>
|
||||
Utility,
|
||||
|
||||
/// <summary>
|
||||
/// Tooltip window.
|
||||
/// </summary>
|
||||
Tooltip,
|
||||
|
||||
/// <summary>
|
||||
/// Popup window.
|
||||
/// </summary>
|
||||
Popup,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Settings for new window.
|
||||
/// </summary>
|
||||
@@ -119,9 +145,15 @@ DECLARE_SCRIPTING_TYPE_MINIMAL(CreateWindowSettings);
|
||||
API_FIELD() bool IsTopmost = false;
|
||||
|
||||
/// <summary>
|
||||
/// True if it's a regular window, false for tooltips, contextmenu and other utility windows.
|
||||
/// True if it's a regular window, false for tooltips, context menu and other utility windows.
|
||||
/// </summary>
|
||||
API_FIELD() bool IsRegularWindow = true;
|
||||
API_FIELD() DEPRECATED bool IsRegularWindow = true;
|
||||
|
||||
/// <summary>
|
||||
/// The type of window. The type affects the behaviour of the window in system level.
|
||||
/// Note: Tooltip and Popup windows require Parent to be set.
|
||||
/// </summary>
|
||||
API_FIELD() WindowType Type = WindowType::Regular;
|
||||
|
||||
/// <summary>
|
||||
/// Enable/disable window sizing frame.
|
||||
|
||||
@@ -98,20 +98,45 @@ SDLWindow::SDLWindow(const CreateWindowSettings& settings)
|
||||
uint32 flags = 0;
|
||||
if (!_settings.HasBorder)
|
||||
flags |= SDL_WINDOW_BORDERLESS;
|
||||
if (_settings.IsRegularWindow)
|
||||
if (_settings.Type == WindowType::Regular)
|
||||
flags |= SDL_WINDOW_INPUT_FOCUS;
|
||||
else if (_settings.Type == WindowType::Utility)
|
||||
flags |= SDL_WINDOW_UTILITY;
|
||||
else if (_settings.Type == WindowType::Tooltip)
|
||||
flags |= SDL_WINDOW_TOOLTIP;
|
||||
else if (_settings.Type == WindowType::Popup)
|
||||
flags |= SDL_WINDOW_POPUP_MENU;
|
||||
|
||||
|
||||
if (!_settings.AllowInput)
|
||||
flags |= SDL_WINDOW_NOT_FOCUSABLE;
|
||||
if (!_settings.ShowInTaskbar && _settings.IsRegularWindow)
|
||||
flags |= SDL_WINDOW_UTILITY;
|
||||
//if (!_settings.ShowInTaskbar && _settings.IsRegularWindow)
|
||||
//flags |= SDL_WINDOW_UTILITY;
|
||||
if (_settings.ShowAfterFirstPaint)
|
||||
flags |= SDL_WINDOW_HIDDEN;
|
||||
if (_settings.HasSizingFrame)
|
||||
flags |= SDL_WINDOW_RESIZABLE;
|
||||
//flags |= SDL_WINDOW_HIGH_PIXEL_DENSITY;
|
||||
|
||||
if (_settings.Parent == nullptr && (_settings.Type == WindowType::Tooltip || _settings.Type == WindowType::Popup))
|
||||
{
|
||||
// Creating a popup window on some platforms brings the parent window on top.
|
||||
// Use the currently focused window as the parent instead to avoid losing focus of it
|
||||
WindowsManager::WindowsLocker.Lock();
|
||||
for (auto win : WindowsManager::Windows)
|
||||
{
|
||||
if (win->IsFocused())
|
||||
{
|
||||
_settings.Parent = win;
|
||||
break;
|
||||
}
|
||||
}
|
||||
WindowsManager::WindowsLocker.Unlock();
|
||||
|
||||
if (_settings.Parent == nullptr)
|
||||
_settings.Parent = Engine::MainWindow;
|
||||
}
|
||||
|
||||
// The SDL window position is always relative to the parent window
|
||||
if (_settings.Parent != nullptr)
|
||||
{
|
||||
@@ -671,7 +696,7 @@ void SDLWindow::Show()
|
||||
BringToFront();
|
||||
|
||||
// Reused top-most windows (DockHintWindow) doesn't stay on top for some reason
|
||||
if (_settings.IsTopmost)
|
||||
if (_settings.IsTopmost && _settings.Type != WindowType::Tooltip)
|
||||
SDL_SetWindowAlwaysOnTop(_window, SDL_TRUE);
|
||||
|
||||
if (_isTrackingMouse)
|
||||
|
||||
@@ -111,7 +111,7 @@ WindowsWindow::WindowsWindow(const CreateWindowSettings& settings)
|
||||
if (settings.IsRegularWindow)
|
||||
style |= WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME | WS_GROUP;
|
||||
#elif WINDOWS_USE_NEWER_BORDER_LESS
|
||||
if (settings.IsRegularWindow)
|
||||
if (settings.Type == WindowType::Regular)
|
||||
style |= WS_THICKFRAME | WS_SYSMENU | WS_CAPTION;
|
||||
#endif
|
||||
exStyle |= WS_EX_WINDOWEDGE;
|
||||
@@ -155,7 +155,7 @@ WindowsWindow::WindowsWindow(const CreateWindowSettings& settings)
|
||||
|
||||
#if WINDOWS_USE_NEWER_BORDER_LESS
|
||||
// Enable shadow
|
||||
if (_settings.IsRegularWindow && !_settings.HasBorder && IsCompositionEnabled())
|
||||
if (settings.Type == WindowType::Regular && !_settings.HasBorder && IsCompositionEnabled())
|
||||
{
|
||||
const int margin[4] = { 1, 1, 1, 1 };
|
||||
::DwmExtendFrameIntoClientArea(_handle, margin);
|
||||
@@ -288,7 +288,7 @@ void WindowsWindow::SetBorderless(bool isBorderless, bool maximized)
|
||||
if (_settings.IsRegularWindow)
|
||||
style |= WS_BORDER | WS_CAPTION | WS_DLGFRAME | WS_SYSMENU | WS_THICKFRAME | WS_GROUP;
|
||||
#elif WINDOWS_USE_NEWER_BORDER_LESS
|
||||
if (_settings.IsRegularWindow)
|
||||
if (_settings.Type == WindowType::Regular)
|
||||
lStyle |= WS_THICKFRAME | WS_SYSMENU;
|
||||
#endif
|
||||
|
||||
@@ -364,7 +364,7 @@ void WindowsWindow::BringToFront(bool force)
|
||||
{
|
||||
ASSERT(HasHWND());
|
||||
|
||||
if (_settings.IsRegularWindow)
|
||||
if (_settings.Type == WindowType::Regular)
|
||||
{
|
||||
if (IsIconic(_handle))
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace FlaxEngine.GUI
|
||||
desc.AllowMaximize = false;
|
||||
desc.AllowDragAndDrop = false;
|
||||
desc.IsTopmost = true;
|
||||
desc.IsRegularWindow = false;
|
||||
desc.Type = WindowType.Tooltip;
|
||||
desc.HasSizingFrame = false;
|
||||
desc.ShowAfterFirstPaint = true;
|
||||
_window = Platform.CreateWindow(ref desc);
|
||||
|
||||
Reference in New Issue
Block a user