BsGUIResourceTreeView.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUITreeView.h"
  4. #include "BsProjectLibrary.h"
  5. #include "BsEvent.h"
  6. namespace BansheeEngine
  7. {
  8. class GUIResourceTreeView : public GUITreeView
  9. {
  10. struct ResourceTreeElement : public GUITreeView::TreeElement
  11. {
  12. Path mFullPath;
  13. WString mElementName;
  14. };
  15. struct DraggedResources
  16. {
  17. Vector<String>::type resourceUUIDs;
  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. protected:
  39. virtual ~GUIResourceTreeView();
  40. protected:
  41. InternalDraggedResources* mDraggedResources;
  42. ResourceTreeElement mRootElement;
  43. RenderWindow* mCurrentWindow;
  44. OSDropTarget* mDropTarget;
  45. bool mDropTargetDragActive;
  46. HEvent mDropTargetEnterConn;
  47. HEvent mDropTargetMoveConn;
  48. HEvent mDropTargetLeaveConn;
  49. HEvent mDropTargetDroppedConn;
  50. GUIResourceTreeView(const String& backgroundStyle, const String& elementBtnStyle,
  51. const String& foldoutBtnStyle, const String& selectionBackgroundStyle, const String& editBoxStyle,
  52. const String& dragHighlightStyle, const String& dragSepHighlightStyle, const GUILayoutOptions& layoutOptions);
  53. virtual void _updateLayoutInternal(INT32 x, INT32 y, UINT32 width, UINT32 height,
  54. RectI clipRect, UINT8 widgetDepth, UINT16 areaDepth);
  55. virtual TreeElement& getRootElement() { return mRootElement; }
  56. virtual const TreeElement& getRootElementConst() const { return mRootElement; }
  57. virtual void updateTreeElementHierarchy();
  58. virtual void renameTreeElement(TreeElement* element, const WString& name);
  59. virtual void deleteTreeElement(TreeElement* element);
  60. virtual bool acceptDragAndDrop() const;
  61. virtual void dragAndDropStart();
  62. virtual void dragAndDropEnded(TreeElement* overTreeElement);
  63. virtual void dragAndDropFinalize();
  64. virtual bool _acceptDragAndDrop(const Vector2I position, UINT32 typeId) const;
  65. void updateFromProjectLibraryEntry(ResourceTreeElement* treeElement, const ProjectLibrary::LibraryEntry* libraryEntry);
  66. ResourceTreeElement* addTreeElement(ResourceTreeElement* parent, const Path& fullPath);
  67. void deleteTreeElement(ResourceTreeElement* element);
  68. void sortTreeElement(ResourceTreeElement* element);
  69. ResourceTreeElement* findTreeElement(const Path& fullPath);
  70. void entryAdded(const Path& path);
  71. void entryRemoved(const Path& path);
  72. void setDropTarget(RenderWindow* parentWindow, INT32 x, INT32 y, UINT32 width, UINT32 height);
  73. void clearDropTarget();
  74. void dropTargetDragMove(INT32 x, INT32 y);
  75. void dropTargetDragLeave();
  76. void dropTargetDragDropped(INT32 x, INT32 y);
  77. Path findUniquePath(const Path& path);
  78. void _changeParentWidget(GUIWidget* widget);
  79. };
  80. }