BsGUIResourceTreeView.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsServiceLocator.h"
  4. #include "BsGUITreeView.h"
  5. #include "BsProjectLibrary.h"
  6. #include "BsEvent.h"
  7. namespace BansheeEngine
  8. {
  9. struct DraggedResources
  10. {
  11. Vector<Path> resourcePaths;
  12. };
  13. class GUIResourceTreeView : public GUITreeView
  14. {
  15. struct ResourceTreeElement : public GUITreeView::TreeElement
  16. {
  17. Path mFullPath;
  18. WString mElementName;
  19. };
  20. struct InternalDraggedResources
  21. {
  22. InternalDraggedResources(UINT32 numObjects);
  23. ~InternalDraggedResources();
  24. UINT32 numObjects;
  25. Path* resourcePaths;
  26. };
  27. public:
  28. static const String& getGUITypeName();
  29. static GUIResourceTreeView* create(
  30. const String& backgroundStyle = StringUtil::BLANK, const String& elementBtnStyle = StringUtil::BLANK,
  31. const String& foldoutBtnStyle = StringUtil::BLANK, const String& selectionBackgroundStyle = StringUtil::BLANK,
  32. const String& editBoxStyle = StringUtil::BLANK, const String& dragHighlightStyle = StringUtil::BLANK,
  33. const String& dragSepHighlightStyle = StringUtil::BLANK);
  34. static GUIResourceTreeView* create(const GUIOptions& options,
  35. const String& backgroundStyle = StringUtil::BLANK, const String& elementBtnStyle = StringUtil::BLANK,
  36. const String& foldoutBtnStyle = StringUtil::BLANK, const String& selectionBackgroundStyle = StringUtil::BLANK,
  37. const String& editBoxStyle = StringUtil::BLANK, const String& dragHighlightStyle = StringUtil::BLANK,
  38. const String& dragSepHighlightStyle = StringUtil::BLANK);
  39. Vector<Path> getSelection() const;
  40. void setSelection(const Vector<Path>& paths);
  41. Event<void()> onSelectionChanged;
  42. static const MessageId SELECTION_CHANGED_MSG;
  43. protected:
  44. virtual ~GUIResourceTreeView();
  45. protected:
  46. InternalDraggedResources* mDraggedResources;
  47. ResourceTreeElement mRootElement;
  48. RenderWindow* mCurrentWindow;
  49. OSDropTarget* mDropTarget;
  50. bool mDropTargetDragActive;
  51. HEvent mDropTargetEnterConn;
  52. HEvent mDropTargetMoveConn;
  53. HEvent mDropTargetLeaveConn;
  54. HEvent mDropTargetDroppedConn;
  55. GUIResourceTreeView(const String& backgroundStyle, const String& elementBtnStyle,
  56. const String& foldoutBtnStyle, const String& selectionBackgroundStyle, const String& editBoxStyle,
  57. const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUIDimensions& dimensions);
  58. virtual void _updateLayoutInternal(const GUILayoutData& data);
  59. virtual TreeElement& getRootElement() { return mRootElement; }
  60. virtual const TreeElement& getRootElementConst() const { return mRootElement; }
  61. virtual void updateTreeElementHierarchy();
  62. virtual void renameTreeElement(TreeElement* element, const WString& name);
  63. virtual void deleteTreeElement(TreeElement* element);
  64. virtual bool acceptDragAndDrop() const;
  65. virtual void dragAndDropStart();
  66. virtual void dragAndDropEnded(TreeElement* overTreeElement);
  67. virtual void dragAndDropFinalize();
  68. virtual bool _acceptDragAndDrop(const Vector2I position, UINT32 typeId) const;
  69. virtual void selectionChanged();
  70. void updateFromProjectLibraryEntry(ResourceTreeElement* treeElement, const ProjectLibrary::LibraryEntry* libraryEntry);
  71. ResourceTreeElement* addTreeElement(ResourceTreeElement* parent, const Path& fullPath);
  72. void deleteTreeElement(ResourceTreeElement* element);
  73. void sortTreeElement(ResourceTreeElement* element);
  74. ResourceTreeElement* findTreeElement(const Path& fullPath);
  75. void entryAdded(const Path& path);
  76. void entryRemoved(const Path& path);
  77. void setDropTarget(RenderWindow* parentWindow, INT32 x, INT32 y, UINT32 width, UINT32 height);
  78. void clearDropTarget();
  79. void dropTargetDragMove(INT32 x, INT32 y);
  80. void dropTargetDragLeave();
  81. void dropTargetDragDropped(INT32 x, INT32 y);
  82. Path findUniquePath(const Path& path);
  83. void _changeParentWidget(GUIWidget* widget);
  84. };
  85. typedef ServiceLocator<GUIResourceTreeView> ResourceTreeViewLocator;
  86. }