AzAssetBrowserRequestHandler.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <SandboxAPI.h>
  10. #include <AzCore/std/smart_ptr/unique_ptr.h>
  11. #include <AzQtComponents/Buses/DragAndDrop.h>
  12. #include <AzToolsFramework/AssetBrowser/AssetBrowserBus.h>
  13. #include <AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h>
  14. #include <AzToolsFramework/AssetBrowser/Previewer/PreviewerBus.h>
  15. namespace AZ
  16. {
  17. class Entity;
  18. }
  19. namespace AzQtComponents
  20. {
  21. class DragAndDropContextBase;
  22. }
  23. namespace AzToolsFramework
  24. {
  25. namespace AssetBrowser
  26. {
  27. class AssetBrowserEntry;
  28. class PreviewerFactory;
  29. class ProductAssetBrowserEntry;
  30. class SourceAssetBrowserEntry;
  31. class AssetBrowserTreeView;
  32. class AssetBrowserTableView;
  33. class AssetBrowserThumbnailView;
  34. }
  35. }
  36. // on windows, this is a DLL Exported class that derives from non-dll-exported
  37. // baseclasses, which issues a warning (which is then treated as an error).
  38. // However, all of the derived classes are ebus handlers that are all available in static
  39. // libraries or by direct header inclusions, so they ARE available:
  40. AZ_PUSH_DISABLE_DLL_EXPORT_BASECLASS_WARNING
  41. // this also triggers a MEMBER warning on the actual EBus Handler we derive from
  42. // because it has members like m_node.
  43. AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING
  44. class SANDBOX_API AzAssetBrowserRequestHandler
  45. : protected AzToolsFramework::AssetBrowser::AssetBrowserInteractionNotificationBus::Handler
  46. , protected AzQtComponents::DragAndDropEventsBus::Handler
  47. , protected AzQtComponents::DragAndDropItemViewEventsBus::Handler
  48. {
  49. public:
  50. AzAssetBrowserRequestHandler();
  51. ~AzAssetBrowserRequestHandler() override;
  52. //////////////////////////////////////////////////////////////////////////
  53. // AssetBrowserInteractionNotificationBus
  54. //////////////////////////////////////////////////////////////////////////
  55. void AddContextMenuActions(QWidget* caller, QMenu* menu, const AZStd::vector<const AzToolsFramework::AssetBrowser::AssetBrowserEntry*>& entries) override;
  56. void AddSourceFileOpeners(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileOpenerList& openers) override;
  57. void AddSourceFileCreators(const char* fullSourceFileName, const AZ::Uuid& sourceUUID, AzToolsFramework::AssetBrowser::SourceFileCreatorList& openers) override;
  58. void OpenAssetInAssociatedEditor(const AZ::Data::AssetId& assetId, bool& alreadyHandled) override;
  59. static bool OpenWithOS(const AZStd::string& fullEntryPath);
  60. void AddCreateMenu(QMenu* menu, const AZStd::string fullFolderPath);
  61. void CreateSortAction(
  62. QMenu* menu,
  63. AzToolsFramework::AssetBrowser::AssetBrowserThumbnailView* thumbnailView,
  64. AzToolsFramework::AssetBrowser::AssetBrowserTreeView* treeView,
  65. QString name,
  66. AzToolsFramework::AssetBrowser::AssetBrowserEntry::AssetEntrySortMode sortMode);
  67. void AddSortMenu(QMenu* menu,
  68. AzToolsFramework::AssetBrowser::AssetBrowserThumbnailView* thumbnailView,
  69. AzToolsFramework::AssetBrowser::AssetBrowserTreeView* treeView,
  70. AzToolsFramework::AssetBrowser::AssetBrowserTableView* tableView
  71. );
  72. protected:
  73. //////////////////////////////////////////////////////////////////////////
  74. // AzQtComponents::DragAndDropEventsBus::Handler
  75. //////////////////////////////////////////////////////////////////////////
  76. void DragEnter(QDragEnterEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
  77. void DragMove(QDragMoveEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
  78. void DragLeave(QDragLeaveEvent* event) override;
  79. void Drop(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) override;
  80. // listview/outliner dragging:
  81. void CanDropItemView(bool& accepted, AzQtComponents::DragAndDropContextBase& context) override;
  82. void DoDropItemView(bool& accepted, AzQtComponents::DragAndDropContextBase& context) override;
  83. bool CanAcceptDragAndDropEvent(QDropEvent* event, AzQtComponents::DragAndDropContextBase& context) const;
  84. bool DecodeDragMimeData(const QMimeData* mimeData,
  85. AZStd::vector<const AzToolsFramework::AssetBrowser::ProductAssetBrowserEntry*>* outVector = nullptr) const;
  86. };
  87. AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING
  88. AZ_POP_DISABLE_DLL_EXPORT_BASECLASS_WARNING