BsSelection.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Utility/BsModule.h"
  6. namespace bs
  7. {
  8. /** @addtogroup Scene-Editor
  9. * @{
  10. */
  11. /**
  12. * Handles scene object and resource selection. Triggeres events when selection changes and allows the user to query
  13. * current selection state.
  14. */
  15. class BS_ED_EXPORT Selection : public Module<Selection>
  16. {
  17. public:
  18. Selection();
  19. ~Selection();
  20. /** Returns a currently selected set of scene objects. */
  21. const Vector<HSceneObject>& getSceneObjects() const;
  22. /** Sets a new set of scene objects to select, replacing the old ones. */
  23. void setSceneObjects(const Vector<HSceneObject>& sceneObjects);
  24. /** Returns a currently selected set of resource paths. */
  25. const Vector<Path>& getResourcePaths() const;
  26. /** Sets a new set of resource paths to select, replacing the old ones. */
  27. void setResourcePaths(const Vector<Path>& paths);
  28. /** Returns a currently selected set of resource UUIDs. */
  29. Vector<UUID> getResourceUUIDs() const;
  30. /** Sets a new set of resource UUIDs to select, replacing the old ones. */
  31. void setResourceUUIDs(const Vector<UUID>& UUIDs);
  32. /** Deselects all currently selected scene objects. */
  33. void clearSceneSelection();
  34. /** Deselects all currently selected resources. */
  35. void clearResourceSelection();
  36. /** Pings the scene object, highlighting it in its respective editors. */
  37. void ping(const HSceneObject& sceneObject);
  38. /**
  39. * Pings the resource, highlighting it in its respective editors.
  40. *
  41. * @param[in] resourcePath Resource path relative to the project library resources folder.
  42. */
  43. void ping(const Path& resourcePath);
  44. /** Triggered when one or multiple scene objects is being added to the selection. */
  45. Event<void(const Vector<HSceneObject>&)> onSceneObjectsAdded;
  46. /** Triggered when one or multiple resources are being added to the selection. */
  47. Event<void(const Vector<Path>&)> onResourcesAdded;
  48. /** Triggered when one or multiple scene objects is being removed from the selection. */
  49. Event<void(const Vector<HSceneObject>&)> onSceneObjectsRemoved;
  50. /** Triggered when one or multiple resources are being removed from the selection. */
  51. Event<void(const Vector<Path>&)> onResourcesRemoved;
  52. /**
  53. * Triggered whenever scene object or resource selection changes. The provided parameters will contain the newly
  54. * selected objects/resource paths.
  55. */
  56. Event<void(const Vector<HSceneObject>&, const Vector<Path>&)> onSelectionChanged;
  57. /**
  58. * Triggered when a scene object ping is requested. Ping usually means the object will be highlighted in its
  59. * respective editors.
  60. */
  61. Event<void(const HSceneObject&)> onSceneObjectPing;
  62. /**
  63. * Triggered when a resource ping is requested. Ping usually means the object will be highlighted in its respective
  64. * editors.
  65. */
  66. Event<void(const Path&)> onResourcePing;
  67. private:
  68. /** Triggered when the scene object selection in the scene tree view changes. */
  69. void sceneSelectionChanged();
  70. /** Triggered when the resource selection in the resource tree view changes. */
  71. void resourceSelectionChanged();
  72. /** Updates scene and resource tree views with new selection. */
  73. void updateTreeViews();
  74. /** Removes any destroyed scene objects from the provided scene object list. */
  75. void pruneDestroyedSceneObjects(Vector<HSceneObject>& sceneObjects) const;
  76. mutable Vector<HSceneObject> mSelectedSceneObjects;
  77. Vector<Path> mSelectedResourcePaths;
  78. HMessage mSceneSelectionChangedConn;
  79. HMessage mResourceSelectionChangedConn;
  80. mutable Vector<HSceneObject> mTempPrune;
  81. mutable Vector<HSceneObject> mTempSceneObjects;
  82. mutable Vector<Path> mTempResources;
  83. };
  84. /** @} */
  85. }