BookmarkAnchorComponent.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <qgraphicswidget.h>
  10. #include <qcolor.h>
  11. #include <AzCore/Component/Component.h>
  12. #include <AzCore/Math/Color.h>
  13. #include <GraphCanvas/Components/Bookmarks/BookmarkBus.h>
  14. #include <GraphCanvas/Components/GeometryBus.h>
  15. #include <GraphCanvas/Components/GraphCanvasPropertyBus.h>
  16. #include <GraphCanvas/Components/EntitySaveDataBus.h>
  17. #include <GraphCanvas/Components/SceneBus.h>
  18. #include <GraphCanvas/Components/VisualBus.h>
  19. #include <GraphCanvas/Types/EntitySaveData.h>
  20. namespace GraphCanvas
  21. {
  22. //! Manages all of the start required by the bookmarks
  23. class BookmarkAnchorComponent
  24. : public GraphCanvasPropertyComponent
  25. , public BookmarkRequestBus::Handler
  26. , public SceneBookmarkRequestBus::Handler
  27. , public SceneMemberNotificationBus::Handler
  28. , public EntitySaveDataRequestBus::Handler
  29. , public BookmarkAnchorComponentSaveDataCallback
  30. {
  31. public:
  32. AZ_COMPONENT(BookmarkAnchorComponent, "{33C63E10-81EE-458D-A716-F63478E57517}");
  33. static void Reflect(AZ::ReflectContext* reflectContext);
  34. friend class BookmarkVisualComponentSaveData;
  35. BookmarkAnchorComponent();
  36. ~BookmarkAnchorComponent() = default;
  37. // AZ::Component
  38. void Init() override;
  39. void Activate() override;
  40. void Deactivate() override;
  41. ////
  42. // SceneMemberNotificationBus
  43. void OnSceneSet(const AZ::EntityId& sceneId) override;
  44. void OnRemovedFromScene(const AZ::EntityId& sceneId) override;
  45. void OnSceneMemberDeserialized(const AZ::EntityId& graphId, const GraphSerialization& serializationTarget) override;
  46. ////
  47. // SceneBookmarkRequests
  48. AZ::EntityId GetBookmarkId() const override;
  49. ////
  50. // BookmarkRequestBus
  51. void RemoveBookmark() override;
  52. int GetShortcut() const override;
  53. void SetShortcut(int quickIndex) override;
  54. AZStd::string GetBookmarkName() const override;
  55. void SetBookmarkName(const AZStd::string& bookmarkName) override;
  56. QRectF GetBookmarkTarget() const override;
  57. QColor GetBookmarkColor() const override;
  58. ////
  59. // EntitySaveDataRequestBus
  60. void WriteSaveData(EntitySaveDataContainer& saveDataContainer) const override;
  61. void ReadSaveData(const EntitySaveDataContainer& saveDataContainer) override;
  62. ////
  63. protected:
  64. // SaveDataCallback
  65. void OnBookmarkNameChanged() override;
  66. void OnBookmarkColorChanged() override;
  67. ////
  68. private:
  69. BookmarkAnchorComponentSaveData m_saveData;
  70. AZ::EntityId m_sceneId;
  71. };
  72. }