BsGUIFloatDistributionField.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 "Particles/BsParticleDistribution.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 input field for a floating point distribution.
  16. */
  17. class BS_ED_EXPORT BS_SCRIPT_EXPORT(ed:true,m:GUIEditor)
  18. GUIFloatDistributionField final : public TGUIField<GUIFloatDistributionField>
  19. {
  20. public:
  21. /** Style type name for the internal float fields. */
  22. static constexpr const char* FLOAT_FIELD_STYLE_TYPE = "FloatField";
  23. /** Style type name for the internal curve display field. */
  24. static constexpr const char* CURVES_FIELD_STYLE_TYPE = "CurvesField";
  25. /** Style type name for the internal drop down button. */
  26. static constexpr const char* DROP_DOWN_FIELD_STYLE_TYPE = "DropDownButton";
  27. /** Returns type name of the GUI element used for finding GUI element styles. */
  28. static const String& getGUITypeName();
  29. GUIFloatDistributionField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  30. const String& style, const GUIDimensions& dimensions, bool withLabel);
  31. /** Returns the value of the field. */
  32. BS_SCRIPT_EXPORT(pr:getter,n:Value)
  33. FloatDistribution getValue() const { return mValue; }
  34. /** Changes the value of the field. */
  35. BS_SCRIPT_EXPORT(pr:setter,n:Value)
  36. void setValue(const FloatDistribution& value);
  37. /** @copydoc GUIElement::setTint */
  38. void setTint(const Color& color) override;
  39. /** Checks if any of the float input fields currently have input focus. Only relevant for non-curve distributions. */
  40. BS_SCRIPT_EXPORT(pr:getter,n:HasInputFocus)
  41. bool hasInputFocus() const;
  42. /**
  43. * Triggered when the user clicks on the curve display. Only relevant if the distribution is a curve distribution.
  44. */
  45. BS_SCRIPT_EXPORT(in:true)
  46. Event<void()> onClicked;
  47. /**
  48. * Triggered when the user modifies either of the non-curve (constant) values of the distribution. Only relevant
  49. * if the distribution is not a curve distribution.
  50. */
  51. BS_SCRIPT_EXPORT(in:true)
  52. Event<void()> onConstantModified;
  53. /**
  54. * Triggered when the user confirms inputs in either of the non-curve (constant) values of the distribution. Only
  55. * relevant if the distribution is not a curve distribution.
  56. */
  57. BS_SCRIPT_EXPORT(in:true)
  58. Event<void()> onConstantConfirmed;
  59. /** @name Internal
  60. * @{
  61. */
  62. /** @copydoc GUIElement::_getOptimalSize */
  63. Vector2I _getOptimalSize() const override;
  64. /** @} */
  65. protected:
  66. /** @copydoc GUIElement::styleUpdated */
  67. void styleUpdated() override;
  68. /** Rebuilds the internal GUI components for the current property type. */
  69. void rebuild();
  70. FloatDistribution mValue = 0.0f;
  71. GUIButton* mDropDownButton = nullptr;
  72. GUIFloatField* mMinInput = nullptr;
  73. GUIFloatField* mMaxInput = nullptr;
  74. GUICurves* mCurveDisplay = nullptr;
  75. float mMinConstant = 0.0f;
  76. float mMaxConstant = 0.0f;
  77. TAnimationCurve<float> mCurves[2];
  78. SPtr<GUIContextMenu> mContextMenu;
  79. };
  80. /** @} */
  81. }