31
Source/Engine/Platform/Base/DragDropHelper.h
Normal file
31
Source/Engine/Platform/Base/DragDropHelper.h
Normal file
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Threading/ThreadPool.h"
|
||||
#include "Engine/Scripting/Scripting.h"
|
||||
#include "Engine/Scripting/ManagedCLR/MDomain.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Platform/Platform.h"
|
||||
|
||||
/// <summary>
|
||||
/// Async DoDragDrop helper (used for rendering frames during main thread stall).
|
||||
/// </summary>
|
||||
class DoDragDropJob : public ThreadPoolTask
|
||||
{
|
||||
public:
|
||||
int64 ExitFlag = 0;
|
||||
|
||||
// [ThreadPoolTask]
|
||||
bool Run() override
|
||||
{
|
||||
Scripting::GetScriptsDomain()->Dispatch();
|
||||
while (Platform::AtomicRead(&ExitFlag) == 0)
|
||||
{
|
||||
Engine::OnDraw();
|
||||
Platform::Sleep(20);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
@@ -8,9 +8,7 @@
|
||||
#include "Engine/Platform/IGuiData.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Platform/CriticalSection.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Threading/ThreadPool.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Platform/Base/DragDropHelper.h"
|
||||
#endif
|
||||
#include "Engine/Core/Log.h"
|
||||
#include "Engine/Input/Input.h"
|
||||
@@ -25,23 +23,7 @@
|
||||
// Data for drawing window while doing drag&drop on Mac (engine is paused during platform tick)
|
||||
CriticalSection MacDragLocker;
|
||||
NSDraggingSession* MacDragSession = nullptr;
|
||||
class DoDragDropJob* MacDragJob = nullptr;
|
||||
|
||||
class DoDragDropJob : public ThreadPoolTask
|
||||
{
|
||||
public:
|
||||
int64 ExitFlag = 0;
|
||||
|
||||
bool Run() override
|
||||
{
|
||||
while (Platform::AtomicRead(&ExitFlag) == 0)
|
||||
{
|
||||
Engine::OnDraw();
|
||||
Platform::Sleep(20);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
DoDragDropJob* MacDragJob = nullptr;
|
||||
#endif
|
||||
|
||||
inline bool IsWindowInvalid(Window* win)
|
||||
|
||||
@@ -12,14 +12,10 @@
|
||||
#include "Engine/Graphics/GPUDevice.h"
|
||||
#if USE_EDITOR
|
||||
#include "Engine/Core/Collections/Array.h"
|
||||
#include "Engine/Engine/Engine.h"
|
||||
#include "Engine/Platform/IGuiData.h"
|
||||
#include "Engine/Platform/Base/DragDropHelper.h"
|
||||
#include "Engine/Input/Input.h"
|
||||
#include "Engine/Input/Mouse.h"
|
||||
#include "Engine/Threading/ThreadPoolTask.h"
|
||||
#include "Engine/Threading/ThreadPool.h"
|
||||
#include "Engine/Scripting/Scripting.h"
|
||||
#include "Engine/Scripting/ManagedCLR/MDomain.h"
|
||||
#endif
|
||||
#include "../Win32/IncludeWindowsHeaders.h"
|
||||
#include <propidl.h>
|
||||
@@ -1829,36 +1825,13 @@ private:
|
||||
|
||||
WindowsGuiData GuiDragDropData;
|
||||
|
||||
/// <summary>
|
||||
/// Async DoDragDrop helper (used for rendering frames during main thread stall).
|
||||
/// </summary>
|
||||
class DoDragDropJob : public ThreadPoolTask
|
||||
{
|
||||
public:
|
||||
int64 ExitFlag = 0;
|
||||
|
||||
// [ThreadPoolTask]
|
||||
bool Run() override
|
||||
{
|
||||
Scripting::GetScriptsDomain()->Dispatch();
|
||||
while (Platform::AtomicRead(&ExitFlag) == 0)
|
||||
{
|
||||
Engine::OnDraw();
|
||||
Platform::Sleep(20);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
DragDropEffect WindowsWindow::DoDragDrop(const StringView& data)
|
||||
{
|
||||
// Create background worker that will keep updating GUI (perform rendering)
|
||||
const auto task = New<DoDragDropJob>();
|
||||
Task::StartNew(task);
|
||||
while (task->GetState() == TaskState::Queued)
|
||||
{
|
||||
Platform::Sleep(1);
|
||||
}
|
||||
|
||||
// Create descriptors
|
||||
FORMATETC fmtetc = { CF_TEXT, nullptr, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
|
||||
|
||||
Reference in New Issue
Block a user