BsGUIResourceTreeView.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUITreeView.h"
  4. #include "BsProjectLibrary.h"
  5. #include <boost/signal.hpp>
  6. namespace BansheeEditor
  7. {
  8. class GUIResourceTreeView : public GUITreeView
  9. {
  10. struct ResourceTreeElement : public GUITreeView::TreeElement
  11. {
  12. CM::WString mFullPath;
  13. CM::WString mElementName;
  14. };
  15. struct DraggedResources
  16. {
  17. CM::Vector<CM::String>::type resourceUUIDs;
  18. };
  19. struct InternalDraggedResources
  20. {
  21. InternalDraggedResources(CM::UINT32 numObjects);
  22. ~InternalDraggedResources();
  23. CM::UINT32 numObjects;
  24. CM::WString* resourcePaths;
  25. };
  26. public:
  27. static const CM::String& getGUITypeName();
  28. static GUIResourceTreeView* create(BS::GUIWidget& parent,
  29. BS::GUIElementStyle* backgroundStyle = nullptr, BS::GUIElementStyle* elementBtnStyle = nullptr,
  30. BS::GUIElementStyle* foldoutBtnStyle = nullptr, BS::GUIElementStyle* selectionBackgroundStyle = nullptr,
  31. BS::GUIElementStyle* editBoxStyle = nullptr, BS::GUIElementStyle* dragHighlightStyle = nullptr,
  32. BS::GUIElementStyle* dragSepHighlightStyle = nullptr);
  33. static GUIResourceTreeView* create(BS::GUIWidget& parent, const BS::GUIOptions& options,
  34. BS::GUIElementStyle* backgroundStyle = nullptr, BS::GUIElementStyle* elementBtnStyle = nullptr,
  35. BS::GUIElementStyle* foldoutBtnStyle = nullptr, BS::GUIElementStyle* selectionBackgroundStyle = nullptr,
  36. BS::GUIElementStyle* editBoxStyle = nullptr, BS::GUIElementStyle* dragHighlightStyle = nullptr,
  37. BS::GUIElementStyle* dragSepHighlightStyle = nullptr);
  38. protected:
  39. virtual ~GUIResourceTreeView();
  40. protected:
  41. InternalDraggedResources* mDraggedResources;
  42. ResourceTreeElement mRootElement;
  43. CM::RenderWindow* mCurrentWindow;
  44. CM::OSDropTarget* mDropTarget;
  45. bool mDropTargetDragActive;
  46. boost::signals::connection mDropTargetEnterConn;
  47. boost::signals::connection mDropTargetMoveConn;
  48. boost::signals::connection mDropTargetLeaveConn;
  49. boost::signals::connection mDropTargetDroppedConn;
  50. GUIResourceTreeView(BS::GUIWidget& parent, BS::GUIElementStyle* backgroundStyle, BS::GUIElementStyle* elementBtnStyle,
  51. BS::GUIElementStyle* foldoutBtnStyle, BS::GUIElementStyle* selectionBackgroundStyle, BS::GUIElementStyle* editBoxStyle,
  52. BS::GUIElementStyle* dragHighlightStyle, BS::GUIElementStyle* dragSepHighlightStyle, const BS::GUILayoutOptions& layoutOptions);
  53. virtual void _updateLayoutInternal(CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height,
  54. CM::RectI clipRect, CM::UINT8 widgetDepth, CM::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 CM::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. void updateFromProjectLibraryEntry(ResourceTreeElement* treeElement, const ProjectLibrary::LibraryEntry* libraryEntry);
  65. ResourceTreeElement* addTreeElement(ResourceTreeElement* parent, const CM::WString& fullPath);
  66. void deleteTreeElement(ResourceTreeElement* element);
  67. void sortTreeElement(ResourceTreeElement* element);
  68. ResourceTreeElement* findTreeElement(const CM::WString& fullPath);
  69. void entryAdded(const CM::WString& path);
  70. void entryRemoved(const CM::WString& path);
  71. void setDropTarget(CM::RenderWindow* parentWindow, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
  72. void clearDropTarget();
  73. void dropTargetDragMove(CM::INT32 x, CM::INT32 y);
  74. void dropTargetDragLeave();
  75. void dropTargetDragDropped(CM::INT32 x, CM::INT32 y);
  76. CM::WString findUniquePath(const CM::WString& path);
  77. void _changeParentWidget(BS::GUIWidget* widget);
  78. };
  79. }