UiAnimViewCurveEditor.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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 "UiAnimViewDopeSheetBase.h"
  10. #include "UiAnimViewSplineCtrl.h"
  11. #include "Animation/Controls/UiTimelineCtrl.h"
  12. #include "UiEditorAnimationBus.h"
  13. #include <QWidget>
  14. namespace Ui
  15. {
  16. class UiAnimViewCurveEditor;
  17. }
  18. /** CUiAnimViewGraph dialog.
  19. Placed at the same position as tracks dialog, and display spline graphs of track.
  20. */
  21. class CUiAnimViewCurveEditor
  22. : public QWidget
  23. , public IUiAnimationContextListener
  24. , public IEditorNotifyListener
  25. , public IUiAnimViewSequenceListener
  26. , public UiEditorAnimListenerBus::Handler
  27. {
  28. friend class UiAnimViewCurveEditorDialog;
  29. public:
  30. CUiAnimViewCurveEditor(QWidget* parent);
  31. virtual ~CUiAnimViewCurveEditor();
  32. void SetEditLock(bool bLock);
  33. void SetFPS(float fps);
  34. float GetFPS() const;
  35. void SetTickDisplayMode(EUiAVTickMode mode);
  36. CUiAnimViewSplineCtrl& GetSplineCtrl();
  37. void ResetSplineCtrlZoomLevel();
  38. void SetPlayCallback(const std::function<void()>& callback);
  39. // IUiAnimationContextListener
  40. void OnSequenceChanged(CUiAnimViewSequence* pNewSequence) override;
  41. void OnTimeChanged(float newTime) override;
  42. protected:
  43. void showEvent(QShowEvent* event) override;
  44. private:
  45. void OnSplineChange();
  46. void OnSplineCmd(UINT cmd);
  47. void OnSplineCmdUpdateUI();
  48. void OnTimelineChange();
  49. void OnHorizontalScrollBarChange();
  50. void OnVerticalScrollBarChange();
  51. void OnSplineScrollZoom();
  52. // IEditorNotifyListener
  53. virtual void OnEditorNotifyEvent(EEditorNotifyEvent event) override;
  54. //IUiAnimViewSequenceListener
  55. virtual void OnKeysChanged(CUiAnimViewSequence* pSequence) override;
  56. virtual void OnKeySelectionChanged(CUiAnimViewSequence* pSequence) override;
  57. virtual void OnNodeChanged(CUiAnimViewNode* pNode, ENodeChangeType type) override;
  58. virtual void OnNodeSelectionChanged(CUiAnimViewSequence* pSequence) override;
  59. virtual void OnSequenceSettingsChanged(CUiAnimViewSequence* pSequence) override;
  60. // UiEditorAnimListenerInterface
  61. void OnActiveCanvasChanged() override;
  62. // ~UiEditorAnimListenerInterface
  63. void UpdateSplines();
  64. void UpdateTimeRange(CUiAnimViewSequence* pSequence);
  65. void AddSpline(CUiAnimViewTrack* pTrack);
  66. void ResetScrollBarRange();
  67. TimelineWidget m_timelineCtrl;
  68. bool m_hasActiveCanvas;
  69. QScopedPointer<Ui::UiAnimViewCurveEditor> m_ui;
  70. };
  71. class UiAnimViewCurveEditorDialog
  72. : public QWidget
  73. , public IUiAnimViewSequenceListener
  74. , public IUiAnimationContextListener
  75. {
  76. public:
  77. UiAnimViewCurveEditorDialog(QWidget* parent);
  78. virtual ~UiAnimViewCurveEditorDialog() {}
  79. void SetPlayCallback(const std::function<void()>& callback) { m_widget->SetPlayCallback(callback); }
  80. void SetEditLock(bool bLock) { m_widget->SetEditLock(bLock); }
  81. CUiAnimViewSplineCtrl& GetSplineCtrl(){ return m_widget->GetSplineCtrl(); }
  82. void SetFPS(float fps) { m_widget->SetFPS(fps); }
  83. float GetFPS() const { return m_widget->GetFPS(); }
  84. void SetTickDisplayMode(EUiAVTickMode mode) { m_widget->SetTickDisplayMode(mode); }
  85. void OnSequenceChanged(CUiAnimViewSequence* pNewSequence) override { m_widget->OnSequenceChanged(pNewSequence); }
  86. void OnTimeChanged(float newTime) override { m_widget->OnTimeChanged(newTime); }
  87. virtual void OnKeysChanged(CUiAnimViewSequence* pSequence) override { m_widget->OnKeysChanged(pSequence); }
  88. virtual void OnKeySelectionChanged(CUiAnimViewSequence* pSequence) override { m_widget->OnKeySelectionChanged(pSequence); }
  89. virtual void OnNodeChanged(CUiAnimViewNode* pNode, ENodeChangeType type) override { m_widget->OnNodeChanged(pNode, type); }
  90. virtual void OnNodeSelectionChanged(CUiAnimViewSequence* pSequence) override { m_widget->OnNodeSelectionChanged(pSequence); }
  91. virtual void OnSequenceSettingsChanged(CUiAnimViewSequence* pSequence) override { m_widget->OnSequenceSettingsChanged(pSequence); }
  92. private:
  93. CUiAnimViewCurveEditor* m_widget;
  94. };