BsGUIResourceTreeView.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUITreeView.h"
  4. #include "BsVirtualInput.h"
  5. #include "CmPath.h"
  6. #include <boost/signal.hpp>
  7. namespace BansheeEditor
  8. {
  9. class GUIResourceTreeView : public GUITreeView
  10. {
  11. struct ResourceTreeElement : public GUITreeView::TreeElement
  12. {
  13. CM::WPath mFullPath;
  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::WPath* 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 bool acceptDragAndDrop() const;
  60. virtual void dragAndDropStart();
  61. virtual void dragAndDropEnded(TreeElement* overTreeElement);
  62. virtual void dragAndDropFinalize();
  63. ResourceTreeElement* addTreeElement(ResourceTreeElement* parent, const CM::WPath& fullPath);
  64. void deleteTreeElement(ResourceTreeElement* element);
  65. void sortTreeElement(ResourceTreeElement* element);
  66. ResourceTreeElement* findTreeElement(const CM::WPath& fullPath);
  67. void entryAdded(const CM::WPath& path);
  68. void entryRemoved(const CM::WPath& path);
  69. void setDropTarget(CM::RenderWindow* parentWindow, CM::INT32 x, CM::INT32 y, CM::UINT32 width, CM::UINT32 height);
  70. void clearDropTarget();
  71. void dropTargetDragMove(CM::INT32 x, CM::INT32 y);
  72. void dropTargetDragLeave();
  73. void dropTargetDragDropped(CM::INT32 x, CM::INT32 y);
  74. void quicksortTreeElements(CM::Vector<TreeElement*>::type& elements, CM::INT32 first, CM::INT32 last);
  75. CM::WPath findUniquePath(const CM::WPath& path);
  76. void _changeParentWidget(BS::GUIWidget* widget);
  77. };
  78. }