BsGUICurvesField.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2018 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "GUI/BsGUIFieldBase.h"
  6. #include "Animation/BsAnimationCurve.h"
  7. namespace bs
  8. {
  9. class GUICurves;
  10. /** @addtogroup GUI-Editor
  11. * @{
  12. */
  13. /**
  14. * A composite GUI object representing an editor field. Editor fields are a combination of a label and an input field.
  15. * Label is optional. This specific implementation displays an animation curve or a range between two animation curves.
  16. */
  17. class BS_ED_EXPORT BS_SCRIPT_EXPORT(ed:true,m:GUIEditor) GUICurvesField final : public TGUIField<GUICurvesField>
  18. {
  19. public:
  20. /** Returns type name of the GUI element used for finding GUI element styles. */
  21. static const String& getGUITypeName();
  22. /** Style type name for the internal curve field. */
  23. static const String& getCurveStyleType();
  24. GUICurvesField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  25. const String& style, const GUIDimensions& dimensions, bool withLabel);
  26. /** Sets an animation curve to display on the field. */
  27. BS_SCRIPT_EXPORT()
  28. void setCurve(const TAnimationCurve<float>& curve);
  29. /** Sets a set of animation curves and displays the difference (range) between them. */
  30. BS_SCRIPT_EXPORT()
  31. void setCurveRange(const TAnimationCurve<float>& curveA, const TAnimationCurve<float>& curveB);
  32. /**
  33. * Returns the curve represented by the field. If the field represents a curve range this returns the minimal
  34. * curve of that range.
  35. */
  36. BS_SCRIPT_EXPORT(pr:getter,n:Curve)
  37. const TAnimationCurve<float>& getCurve() const;
  38. /**
  39. * Returns the minimal curve represented by the field containing a curve range. Returns the only available
  40. * curve if the field doesn't represent a range.
  41. */
  42. BS_SCRIPT_EXPORT(pr:getter,n:MinCurve)
  43. const TAnimationCurve<float>& getMinCurve() const;
  44. /**
  45. * Returns the maximal curve represented by the field containing a curve range. Returns the only available
  46. * curve if the field doesn't represent a range.
  47. */
  48. BS_SCRIPT_EXPORT(pr:getter,n:MaxCurve)
  49. const TAnimationCurve<float>& getMaxCurve() const;
  50. /** @copydoc GUIElement::setTint */
  51. void setTint(const Color& color) override;
  52. BS_SCRIPT_EXPORT(in:true)
  53. Event<void()> onClicked; /**< Triggered when the user clicks on the GUI element. */
  54. /** @name Internal
  55. * @{
  56. */
  57. /** @copydoc GUIElement::_getOptimalSize */
  58. Vector2I _getOptimalSize() const override;
  59. /** @} */
  60. protected:
  61. /** @copydoc GUIElement::styleUpdated */
  62. void styleUpdated() override;
  63. /** Triggered when the child color input field is clicked on. */
  64. void clicked();
  65. UINT32 mLabelWidth = 100;
  66. GUILabel* mLabel = nullptr;
  67. GUICurves* mCurves = nullptr;
  68. };
  69. /** @} */
  70. }