BsSelection.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. * @param resourcePath Resource path relative to the project library resources folder.
  55. */
  56. void ping(const Path& resourcePath);
  57. /**
  58. * @brief Triggered whenever scene object or resource selection changes. The provided
  59. * parameters will contain the newly selected objects/resource paths.
  60. */
  61. Event<void(const Vector<HSceneObject>&, const Vector<Path>&)> onSelectionChanged;
  62. /**
  63. * @brief Triggered when a scene object ping is requested. Ping usually means the
  64. * object will be highlighted in its respective editors.
  65. */
  66. Event<void(const HSceneObject&)> onSceneObjectPing;
  67. /**
  68. * @brief Triggered when a resource ping is requested. Ping usually means the
  69. * object will be highlighted in its respective editors.
  70. */
  71. Event<void(const Path&)> onResourcePing;
  72. private:
  73. /**
  74. * @brief Triggered when the scene object selection in the scene tree view changes.
  75. */
  76. void sceneSelectionChanged();
  77. /**
  78. * @brief Triggered when the resource selection in the resource tree view changes.
  79. */
  80. void resourceSelectionChanged();
  81. /**
  82. * @brief Updates scene and resource tree views with new selection.
  83. */
  84. void updateTreeViews();
  85. Vector<HSceneObject> mSelectedSceneObjects;
  86. Vector<Path> mSelectedResourcePaths;
  87. HMessage mSceneSelectionChangedConn;
  88. HMessage mResourceSelectionChangedConn;
  89. };
  90. }