_drag release offset investigation
Some checks failed
Build Android / Game (Android, Release ARM64) (push) Has been cancelled
Build iOS / Game (iOS, Release ARM64) (push) Has been cancelled
Build Linux / Editor (Linux, Development x64) (push) Has been cancelled
Build Linux / Game (Linux, Release x64) (push) Has been cancelled
Build macOS / Editor (Mac, Development ARM64) (push) Has been cancelled
Build macOS / Game (Mac, Release ARM64) (push) Has been cancelled
Build Windows / Editor (Windows, Development x64) (push) Has been cancelled
Build Windows / Game (Windows, Release x64) (push) Has been cancelled
Cooker / Cook (Mac) (push) Has been cancelled
Tests / Tests (Linux) (push) Has been cancelled
Tests / Tests (Windows) (push) Has been cancelled

This commit is contained in:
2025-01-12 22:15:38 +02:00
parent 1b9c9436bc
commit ed4d5a5397
4 changed files with 54 additions and 40 deletions

View File

@@ -640,16 +640,41 @@ void SDLWindow::HandleEvent(SDL_Event& event)
return;
}
case SDL_EVENT_DROP_BEGIN:
case SDL_EVENT_DROP_POSITION:
case SDL_EVENT_DROP_FILE:
case SDL_EVENT_DROP_TEXT:
case SDL_EVENT_DROP_COMPLETE:
{
LOG(Info, "SDL_EVENT_DROP_BEGIN");
//LOG(Info, "SDL_EVENT_DROP_BEGIN");
static Float2 dragStartPosition = Float2::Zero;
auto dpiScale = GetDpiScale();
const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
//const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
const Float2 mousePos = dragStartPosition + Float2(event.drop.x * dpiScale, event.drop.y * dpiScale);
DragDropEffect effect = DragDropEffect::None;
auto daata = event.drop.data;
SDLDropTextData dropData;
OnDragEnter(&dropData, mousePos, effect);
if (event.type == SDL_EVENT_DROP_BEGIN)
{
dragStartPosition = Platform::GetMousePosition();
OnDragEnter(&dropData, mousePos, effect);
}
else if (event.type == SDL_EVENT_DROP_POSITION)
{
Input::Mouse->OnMouseMove(mousePos, this);
OnDragOver(&dropData, mousePos, effect);
}
else if (event.type == SDL_EVENT_DROP_FILE)
OnDragDrop(&dropData, mousePos, effect);
else if (event.type == SDL_EVENT_DROP_TEXT)
OnDragDrop(&dropData, mousePos, effect);
else if (event.type == SDL_EVENT_DROP_COMPLETE)
OnDragLeave();
/*Focus();
Float2 mousePosition;
SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
@@ -659,21 +684,19 @@ void SDLWindow::HandleEvent(SDL_Event& event)
SDLDropTextData dropData;
OnDragEnter(&dropData, mousePosition, effect);
OnDragOver(&dropData, mousePosition, effect);*/
return;
break;
}
case SDL_EVENT_DROP_POSITION:
/*case SDL_EVENT_DROP_POSITION:
{
auto dpiScale = GetDpiScale();
const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
//const Float2 mousePos = ClientToScreen({ event.drop.x * dpiScale, event.drop.y * dpiScale});
const Float2 mousePos(event.drop.x * dpiScale, event.drop.y * dpiScale);
DragDropEffect effect = DragDropEffect::None;
auto daata = event.drop.data;
SDLDropTextData dropData;
OnDragOver(&dropData, mousePos, effect);
/*DragDropEffect effect = DragDropEffect::None;
SDLDropTextData dropData;
OnDragOver(&dropData, Float2(static_cast<float>(event.drop.x), static_cast<float>(event.drop.y)), effect);*/
break;
}
case SDL_EVENT_DROP_FILE:
@@ -688,16 +711,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
OnDragDrop(&dropData, mousePos, effect);
/*SDLDropFilesData dropData;
dropData.Files.Add(StringAnsi(event.drop.data).ToString()); // TODO: collect multiple files at once?
Focus();
Float2 mousePosition;
SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
mousePosition = ScreenToClient(mousePosition);
DragDropEffect effect = DragDropEffect::None;
OnDragDrop(&dropData, mousePosition, effect);*/
return;
}
case SDL_EVENT_DROP_TEXT:
@@ -713,16 +727,6 @@ void SDLWindow::HandleEvent(SDL_Event& event)
SDLDropTextData dropData;
OnDragDrop(&dropData, mousePos, effect);
/*SDLDropTextData dropData;
String str = StringAnsi(event.drop.data).ToString();
dropData.Text = StringView(str);
Focus();
Float2 mousePosition;
SDL_GetGlobalMouseState(&mousePosition.X, &mousePosition.Y);
mousePosition = ScreenToClient(mousePosition);
DragDropEffect effect = DragDropEffect::None;
OnDragDrop(&dropData, mousePosition, effect);*/
return;
}
case SDL_EVENT_DROP_COMPLETE:
@@ -740,7 +744,7 @@ void SDLWindow::HandleEvent(SDL_Event& event)
//_dragOver = false;
}
return;
}
}*/
#endif
case SDL_EVENT_WINDOW_MOUSE_LEAVE:
{