BsGUISliderField.h 2.8 KB

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