BsSelection.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsModule.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Handles scene object and resource selection. Triggeres events when selection changes and allows the
  8. * user to query current selection state.
  9. */
  10. class BS_ED_EXPORT Selection : public Module<Selection>
  11. {
  12. public:
  13. Selection();
  14. ~Selection();
  15. /**
  16. * @brief Returns a currently selected set of scene objects.
  17. */
  18. const Vector<HSceneObject>& getSceneObjects() const;
  19. /**
  20. * @brief Sets a new set of scene objects to select, replacing the old ones.
  21. */
  22. void setSceneObjects(const Vector<HSceneObject>& sceneObjects);
  23. /**
  24. * @brief Returns a currently selected set of resource paths.
  25. */
  26. const Vector<Path>& getResourcePaths() const;
  27. /**
  28. * @brief Sets a new set of resource paths to select, replacing the old ones.
  29. */
  30. void setResourcePaths(const Vector<Path>& paths);
  31. /**
  32. * @brief Returns a currently selected set of resource UUIDs.
  33. */
  34. Vector<String> getResourceUUIDs() const;
  35. /**
  36. * @brief Sets a new set of resource UUIDs to select, replacing the old ones.
  37. */
  38. void setResourceUUIDs(const Vector<String>& UUIDs);
  39. /**
  40. * @brief Deselects all currently selected scene objects.
  41. */
  42. void clearSceneSelection();
  43. /**
  44. * @brief Deselects all currently selected resources.
  45. */
  46. void clearResourceSelection();
  47. /**
  48. * @brief Pings the scene object, highlighting it in its respective editors.
  49. */
  50. void ping(const HSceneObject& sceneObject);
  51. /**
  52. * @brief Pings the resource, highlighting it in its respective editors.
  53. */
  54. void ping(const Path& resourcePath);
  55. /**
  56. * @brief Triggered whenever scene object or resource selection changes. The provided
  57. * parameters will contain the newly selected objects/resource paths.
  58. */
  59. Event<void(const Vector<HSceneObject>&, const Vector<Path>&)> onSelectionChanged;
  60. /**
  61. * @brief Triggered when a scene object ping is requested. Ping usually means the
  62. * object will be highlighted in its respective editors.
  63. */
  64. Event<void(const HSceneObject&)> onSceneObjectPing;
  65. /**
  66. * @brief Triggered when a resource ping is requested. Ping usually means the
  67. * object will be highlighted in its respective editors.
  68. */
  69. Event<void(const Path&)> onResourcePing;
  70. private:
  71. /**
  72. * @brief Triggered when the scene object selection in the scene tree view changes.
  73. */
  74. void sceneSelectionChanged();
  75. /**
  76. * @brief Triggered when the resource selection in the resource tree view changes.
  77. */
  78. void resourceSelectionChanged();
  79. /**
  80. * @brief Updates scene and resource tree views with new selection.
  81. */
  82. void updateTreeViews();
  83. Vector<HSceneObject> mSelectedSceneObjects;
  84. Vector<Path> mSelectedResourcePaths;
  85. HMessage mSceneSelectionChangedConn;
  86. HMessage mResourceSelectionChangedConn;
  87. };
  88. }