BsSelection.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. Vector<HSceneObject> mSelectedSceneObjects;
  67. Vector<Path> mSelectedResourcePaths;
  68. HMessage mSceneSelectionChangedConn;
  69. HMessage mResourceSelectionChangedConn;
  70. };
  71. /** @} */
  72. }