From 692183e1dde5b365ffa416f2088a99892101f981 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 19 Jan 2025 22:43:50 +0200 Subject: [PATCH] _dragging fixes windows --- Source/Editor/GUI/Docking/DockHintWindow.cs | 9 ++-- Source/Engine/Platform/Base/WindowBase.h | 17 ------- .../Platform/SDL/SDLPlatform.Windows.cpp | 45 +++++++++---------- Source/Engine/Platform/SDL/SDLWindow.cpp | 13 ------ Source/Engine/Platform/SDL/SDLWindow.h | 2 - 5 files changed, 28 insertions(+), 58 deletions(-) diff --git a/Source/Editor/GUI/Docking/DockHintWindow.cs b/Source/Editor/GUI/Docking/DockHintWindow.cs index 581bf73d0..edc8a9e9e 100644 --- a/Source/Editor/GUI/Docking/DockHintWindow.cs +++ b/Source/Editor/GUI/Docking/DockHintWindow.cs @@ -159,8 +159,8 @@ namespace FlaxEditor.GUI.Docking if (_toMove == null) return; - _toMove.Window?.Window.StopDragging(); - + _toMove.Window.Window.Opacity = 1.0f; + // Check if window won't be docked if (_toSet == DockState.Float) { @@ -392,8 +392,11 @@ namespace FlaxEditor.GUI.Docking // Make sure the all the dock hint areas are not under other windows _toDock?.RootWindow.Window.BringToFront(); _toMove.RootWindow.Window.BringToFront(); - } + // Make the dragged window transparent when dock hints are visible + _toMove.Window.Window.Opacity = _toDock == null ? 1.0f : 0.4f; + } + // Check dock state to use bool showProxyHints = _toDock != null; bool showBorderHints = showProxyHints; diff --git a/Source/Engine/Platform/Base/WindowBase.h b/Source/Engine/Platform/Base/WindowBase.h index cd65c5067..ef069cb84 100644 --- a/Source/Engine/Platform/Base/WindowBase.h +++ b/Source/Engine/Platform/Base/WindowBase.h @@ -748,23 +748,6 @@ public: /// True during the frame the user releases the button API_FUNCTION() bool GetMouseButtonUp(MouseButton button) const; -public: - /// - /// Start dragging the window. - /// - /// The position offset for drag from top-left corner. - /// The source window where the dragging is started from. For attached tabs, this is the parent window - API_FUNCTION() virtual void StartDragging(const Float2& offset, Window* dragSourceWindow) - { - } - - /// - /// Ends dragging the window. - /// - API_FUNCTION() virtual void StopDragging() - { - } - public: void OnShow(); void OnResize(int32 width, int32 height); diff --git a/Source/Engine/Platform/SDL/SDLPlatform.Windows.cpp b/Source/Engine/Platform/SDL/SDLPlatform.Windows.cpp index 8e879ac65..2de6c44f1 100644 --- a/Source/Engine/Platform/SDL/SDLPlatform.Windows.cpp +++ b/Source/Engine/Platform/SDL/SDLPlatform.Windows.cpp @@ -53,31 +53,30 @@ bool SDLCALL SDLPlatform::EventMessageHook(void* userdata, MSG* msg) draggedWindow = window; draggedWindowStartPosition = draggedWindow->GetClientPosition(); - draggedWindowMousePosition.X = static_cast(static_cast(WINDOWS_GET_X_LPARAM(msg->lParam))); - draggedWindowMousePosition.Y = static_cast(static_cast(WINDOWS_GET_Y_LPARAM(msg->lParam))); + Float2 mousePos(static_cast(static_cast(WINDOWS_GET_X_LPARAM(msg->lParam))), static_cast(static_cast(WINDOWS_GET_Y_LPARAM(msg->lParam)))); + draggedWindowMousePosition = mousePos; draggedWindowMousePosition -= draggedWindowStartPosition; - //auto hit = static_cast(msg->wParam); - //if (SDLPlatform::CheckWindowDragging(window, hit)) - // return false; - //bool result = false; - //window->OnLeftButtonHit(static_cast(msg->wParam), result); - //if (result) - // return false; - - //::ClientToScreen(static_cast(window->GetNativePtr()), &p); - //const Float2 mousePos(static_cast(p.x), static_cast(p.y)); - - SDL_Event event{0}; - event.button.type = SDL_EVENT_MOUSE_BUTTON_DOWN; - event.button.down = true; - event.button.timestamp = SDL_GetTicksNS(); - event.button.windowID = SDL_GetWindowID(window->GetSDLWindow()); - event.button.button = SDL_BUTTON_LEFT; - event.button.clicks = 1; - event.button.x = draggedWindowMousePosition.X; - event.button.y = draggedWindowMousePosition.Y; - SDL_PushEvent(&event); + bool result = false; + WindowHitCodes hit = static_cast(msg->wParam); + window->OnHitTest(mousePos, hit, result); + //if (result && hit != WindowHitCodes::Caption) + // return false; + + if (hit == WindowHitCodes::Caption) + { + SDL_Event event{ 0 }; + event.button.type = SDL_EVENT_MOUSE_BUTTON_DOWN; + event.button.down = true; + event.button.timestamp = SDL_GetTicksNS(); + event.button.windowID = SDL_GetWindowID(window->GetSDLWindow()); + event.button.button = SDL_BUTTON_LEFT; + event.button.clicks = 1; + event.button.x = draggedWindowMousePosition.X; + event.button.y = draggedWindowMousePosition.Y; + + SDL_PushEvent(&event); + } } /*else if (msg->message == WM_NCLBUTTONUP || msg->message == WM_CAPTURECHANGED) { diff --git a/Source/Engine/Platform/SDL/SDLWindow.cpp b/Source/Engine/Platform/SDL/SDLWindow.cpp index 0b1d848af..f1502be32 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.cpp +++ b/Source/Engine/Platform/SDL/SDLWindow.cpp @@ -1310,7 +1310,6 @@ DragDropEffect SDLWindow::DoDragDrop(const StringView& data, const Float2& offse #endif } - //SetOpacity(0.1f); #if PLATFORM_LINUX if (SDLPlatform::UsesWayland() DoDragDropWayland(String("notawindow"), dragSourceWindow, dragOffset); @@ -1353,17 +1352,5 @@ DragDropEffect SDLWindow::DoDragDrop(const StringView& data, const Float2& offse return DragDropEffect::None; } -void SDLWindow::StartDragging(const Float2& offset, Window* dragSourceWindow) -{ -} - -void SDLWindow::StopDragging() -{ - LOG(Info, "StopDragging"); - - SetOpacity(1.0f); - //draggingActive = false; -} - #endif diff --git a/Source/Engine/Platform/SDL/SDLWindow.h b/Source/Engine/Platform/SDL/SDLWindow.h index 28c60264d..46c93d33f 100644 --- a/Source/Engine/Platform/SDL/SDLWindow.h +++ b/Source/Engine/Platform/SDL/SDLWindow.h @@ -109,8 +109,6 @@ public: void StartClippingCursor(const Rectangle& bounds) override; void EndClippingCursor() override; void SetCursor(CursorType type) override; - void StartDragging(const Float2& offset, Window* dragSourceWindow) override; - void StopDragging() override; #if USE_EDITOR && PLATFORM_WINDOWS // [IUnknown]