| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsScriptEditorPrerequisites.h"
- #include "BsScriptObject.h"
- #include "GUI/BsDragAndDropManager.h"
- namespace bs
- {
- /** @addtogroup ScriptInteropEditor
- * @{
- */
- class ScriptSceneObjectDragDropData;
- class ScriptResourceDragDropData;
- /** Types of drag and drop operations supported by the managed drag and drop system. */
- enum class ScriptDragDropType // Note: Must be equal to C# DragDropType enum
- {
- Resource,
- SceneObject,
- None
- };
- /** Interop class between C++ & CLR for DragAndDropManager. */
- class BS_SCR_BED_EXPORT ScriptDragDrop : public ScriptObject<ScriptDragDrop>
- {
- public:
- SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "DragDrop");
- private:
- ScriptDragDrop(MonoObject* instance);
- /**
- * Triggered when the scene object drag and drop operation ends.
- *
- * @param[in] processed True if the drop operations was accepted by some system.
- */
- static void sceneObjectDragDropFinalize(bool processed);
- /**
- * Triggered when the resource drag and drop operation ends.
- *
- * @param[in] processed True if the drop operations was accepted by some system.
- */
- static void resourceDragDropFinalize(bool processed);
- /************************************************************************/
- /* CLR HOOKS */
- /************************************************************************/
- static bool internal_IsDragInProgress();
- static bool internal_IsDropInProgress();
- static MonoObject* internal_GetData();
- static ScriptDragDropType internal_GetDragType();
- static void internal_StartSceneObjectDrag(ScriptSceneObjectDragDropData* dragData);
- static void internal_StartResourceDrag(ScriptResourceDragDropData* dragData);
- };
- /**
- * Interop class between C++ & CLR for SceneObjectDragDropData. Contains a set of scene objects used during managed drag
- * and drop operations.
- */
- class BS_SCR_BED_EXPORT ScriptSceneObjectDragDropData : public ScriptObject<ScriptSceneObjectDragDropData>
- {
- public:
- SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "SceneObjectDragDropData");
- /** Creates a new managed instance of SceneObjectDragDropData containing the specified scene objects. */
- static MonoObject* create(const Vector<HSceneObject>& sceneObjects);
- /** Returns the scene objects referenced by this object. */
- const Vector<HSceneObject>& getSceneObjects() const { return mSceneObjects; }
- private:
- ScriptSceneObjectDragDropData(MonoObject* instance, const Vector<HSceneObject>& sceneObjects);
- Vector<HSceneObject> mSceneObjects;
- /************************************************************************/
- /* CLR HOOKS */
- /************************************************************************/
- static void internal_CreateInstance(MonoObject* instance, MonoArray* objects);
- static MonoArray* internal_GetObjects(ScriptSceneObjectDragDropData* instance);
- };
- /**
- * Interop class between C++ & CLR for ResourceDragDropData. Contains a set of resource paths used during managed drag
- * and drop operations.
- */
- class BS_SCR_BED_EXPORT ScriptResourceDragDropData : public ScriptObject < ScriptResourceDragDropData >
- {
- public:
- SCRIPT_OBJ(EDITOR_ASSEMBLY, "BansheeEditor", "ResourceDragDropData");
- /** Creates a new managed instance of ResourceDragDropData containing the specified resource paths. */
- static MonoObject* create(const Vector<Path>& paths);
- /** Returns the resource paths referenced by this object. */
- const Vector<Path>& getPaths() const { return mPaths; }
- private:
- ScriptResourceDragDropData(MonoObject* instance, const Vector<Path>& paths);
- Vector<Path> mPaths;
- /************************************************************************/
- /* CLR HOOKS */
- /************************************************************************/
- static void internal_CreateInstance(MonoObject* instance, MonoArray* paths);
- static MonoArray* internal_GetPaths(ScriptResourceDragDropData* instance);
- };
- /** @} */
- /** @addtogroup EditorScript
- * @{
- */
- /**
- * Handles managed drag and drop operations. Wraps the existing functionality of DragAndDropManager. Essentially
- * converts the callback nature of DragAndDropManager into a polling based system.
- */
- class BS_SCR_BED_EXPORT ScriptDragDropManager : public Module<ScriptDragDropManager>
- {
- public:
- ScriptDragDropManager();
- ~ScriptDragDropManager();
- /**
- * Called every frame. Checks for changes in drag and drop operations.
- *
- * @note Internal method.
- */
- void update();
- /** Checks has the user performed a drop operation this frame. */
- bool isDropInProgress() const { return mIsDropInProgress; }
- /**
- * Returns the managed representation of currently dragged data (for example SceneObjectDragDropData). This will be
- * null if drag or drop is not in progress or of unsupported type.
- */
- MonoObject* getDropData() const;
- /** Checks the type of the current drag or drop operation. */
- ScriptDragDropType getDragType() const;
- private:
- /**
- * Triggered when a native drag and drop operation ends.
- *
- * @param[in] evt Pointer data regarding where the drop operation occurred.
- * @param[in] callbackInfo Data whether the drop was processed or not.
- */
- void onMouseDragEnded(const PointerEvent& evt, DragCallbackInfo& callbackInfo);
- HEvent mDragEndedConn;
- bool mIsDropInProgress;
- UINT64 mDroppedFrameIdx;
- ScriptDragDropType mDropType;
- Vector<Path> mDroppedPaths;
- Vector<HSceneObject> mDroppedSceneObjects;
- };
- /** @} */
- }
|