ExtAssetDragDropOp.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
  2. #pragma once
  3. #include "CoreMinimal.h"
  4. #include "AssetRegistry/AssetData.h"
  5. #include "Input/DragAndDrop.h"
  6. #include "Layout/Visibility.h"
  7. #include "DragAndDrop/DecoratedDragDropOp.h"
  8. struct FExtAssetData;
  9. class FExtAssetThumbnail;
  10. class FExtAssetThumbnailPool;
  11. class UActorFactory;
  12. class FExtAssetDragDropOp : public FDecoratedDragDropOp
  13. {
  14. public:
  15. DRAG_DROP_OPERATOR_TYPE(FExtAssetDragDropOp, FDecoratedDragDropOp)
  16. static TSharedRef<FExtAssetDragDropOp> New(const FExtAssetData& InAssetData, UActorFactory* ActorFactory = nullptr);
  17. static TSharedRef<FExtAssetDragDropOp> New(TArray<FExtAssetData> InAssetData, UActorFactory* ActorFactory = nullptr);
  18. static TSharedRef<FExtAssetDragDropOp> New(FString InAssetPath);
  19. static TSharedRef<FExtAssetDragDropOp> New(TArray<FString> InAssetPaths);
  20. static TSharedRef<FExtAssetDragDropOp> New(TArray<FExtAssetData> InAssetData, TArray<FString> InAssetPaths, UActorFactory* ActorFactory = nullptr);
  21. /** @return true if this drag operation contains assets */
  22. bool HasAssets() const
  23. {
  24. return AssetData.Num() > 0;
  25. }
  26. /** @return true if this drag operation contains asset paths */
  27. bool HasAssetPaths() const
  28. {
  29. return AssetPaths.Num() > 0;
  30. }
  31. /** @return The assets from this drag operation */
  32. const TArray<FExtAssetData>& GetAssets() const
  33. {
  34. return AssetData;
  35. }
  36. /** @return The asset paths from this drag operation */
  37. const TArray<FString>& GetAssetPaths() const
  38. {
  39. return AssetPaths;
  40. }
  41. /** @return The actor factory to use if converting this asset to an actor */
  42. UActorFactory* GetActorFactory() const
  43. {
  44. return ActorFactory.Get();
  45. }
  46. public:
  47. virtual ~FExtAssetDragDropOp();
  48. virtual TSharedPtr<SWidget> GetDefaultDecorator() const override;
  49. FText GetDecoratorText() const;
  50. private:
  51. void Init();
  52. /** Data for the assets this item represents */
  53. TArray<FExtAssetData> AssetData;
  54. /** Data for the asset paths this item represents */
  55. TArray<FString> AssetPaths;
  56. /** Pool for maintaining and rendering thumbnails */
  57. TSharedPtr<FExtAssetThumbnailPool> ThumbnailPool;
  58. /** Handle to the thumbnail resource */
  59. TSharedPtr<FExtAssetThumbnail> AssetThumbnail;
  60. /** The actor factory to use if converting this asset to an actor */
  61. TWeakObjectPtr<UActorFactory> ActorFactory;
  62. /** The size of the thumbnail */
  63. int32 ThumbnailSize;
  64. };