BsGUISliderField.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIFieldBase.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief A composite GUI object representing an editor field. Editor fields are a combination
  8. * of a label and an input field. Label is optional. This specific implementation
  9. * displays a horizontal slider and a floating point input box.
  10. */
  11. class BS_ED_EXPORT GUISliderField : public TGUIField<GUISliderField>
  12. {
  13. public:
  14. /**
  15. * Returns type name of the GUI element used for finding GUI element styles.
  16. */
  17. static const String& getGUITypeName();
  18. /**
  19. * Style type name for the internal input box.
  20. */
  21. static const String& getInputStyleType();
  22. /**
  23. * Style type name for the internal slider.
  24. */
  25. static const String& getSliderStyleType();
  26. GUISliderField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  27. const String& style, const GUIDimensions& dimensions, bool withLabel);
  28. /**
  29. * @brief Returns the value of the input field/slider.
  30. */
  31. float getValue() const;
  32. /**
  33. * @brief Sets a new value in the input field/slider.
  34. */
  35. void setValue(float value);
  36. /**
  37. * @brief Sets a minimum and maximum allow values in the input field.
  38. * Set to large negative/positive values if you don't require clamping.
  39. */
  40. void setRange(float min, float max);
  41. /**
  42. * @brief Sets a step that defines the minimal increment the value can be increased/decreased by. Set to zero
  43. * to have no step.
  44. */
  45. void setStep(float step);
  46. /**
  47. * @copydoc GUIElement::setTint
  48. */
  49. void setTint(const Color& color) override;
  50. /**
  51. * @brief Sets a new value in the input field, and also allows you to choose should the field trigger an
  52. * onValueChanged event.
  53. */
  54. void _setValue(float value, bool triggerEvent);
  55. Event<void(float)> onValueChanged; /**< Triggers when the field value changes. */
  56. protected:
  57. virtual ~GUISliderField();
  58. /**
  59. * @copydoc GUIElementContainer::styleUpdated
  60. */
  61. void styleUpdated() override;
  62. /**
  63. * @brief Triggered when the input box value changes.
  64. */
  65. void valueChanged(const WString& newValue);
  66. /**
  67. * @brief Triggered when the slider is moved.
  68. */
  69. void sliderChanged(float newValue);
  70. /**
  71. * @brief Callback that checks can the provided string be
  72. * converted to a floating point value.
  73. */
  74. static bool floatFilter(const WString& str);
  75. GUIInputBox* mInputBox;
  76. GUISliderHorz* mSlider;
  77. };
  78. }