2
0

BsSelection.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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 "BsModule.h"
  6. namespace BansheeEngine
  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<String> getResourceUUIDs() const;
  30. /** Sets a new set of resource UUIDs to select, replacing the old ones. */
  31. void setResourceUUIDs(const Vector<String>& 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. /**
  45. * Triggered whenever scene object or resource selection changes. The provided parameters will contain the newly
  46. * selected objects/resource paths.
  47. */
  48. Event<void(const Vector<HSceneObject>&, const Vector<Path>&)> onSelectionChanged;
  49. /**
  50. * Triggered when a scene object ping is requested. Ping usually means the object will be highlighted in its
  51. * respective editors.
  52. */
  53. Event<void(const HSceneObject&)> onSceneObjectPing;
  54. /**
  55. * Triggered when a resource ping is requested. Ping usually means the object will be highlighted in its respective
  56. * editors.
  57. */
  58. Event<void(const Path&)> onResourcePing;
  59. private:
  60. /** Triggered when the scene object selection in the scene tree view changes. */
  61. void sceneSelectionChanged();
  62. /** Triggered when the resource selection in the resource tree view changes. */
  63. void resourceSelectionChanged();
  64. /** Updates scene and resource tree views with new selection. */
  65. void updateTreeViews();
  66. /** Removes any destroyed scene objects from the selected scene object list. */
  67. void pruneDestroyedSceneObjects() const;
  68. mutable Vector<HSceneObject> mSelectedSceneObjects;
  69. Vector<Path> mSelectedResourcePaths;
  70. HMessage mSceneSelectionChangedConn;
  71. HMessage mResourceSelectionChangedConn;
  72. mutable Vector<HSceneObject> mTempSO;
  73. };
  74. /** @} */
  75. }