BsGUIResourceTreeView.h 3.9 KB

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