BsGUIToggleField.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 toggle button.
  10. */
  11. class BS_ED_EXPORT GUIToggleField : public TGUIField<GUIToggleField>
  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. * Returns style type name of the internal GUIToggle element.
  20. */
  21. static const String& getToggleStyleType();
  22. GUIToggleField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  23. const String& style, const GUIDimensions& dimensions, bool withLabel);
  24. /**
  25. * @brief Returns the current value of the toggle.
  26. */
  27. bool getValue() const { return mValue; }
  28. /**
  29. * @brief Activates/deactivates the toggle.
  30. */
  31. void setValue(bool value);
  32. /**
  33. * @copydoc GUIElement::setTint
  34. */
  35. virtual void setTint(const Color& color) override;
  36. Event<void(bool)> onValueChanged; /** Triggered when the value of the toggle changes. */
  37. protected:
  38. virtual ~GUIToggleField() { }
  39. /**
  40. * @copydoc GUIElement::styleUpdated
  41. */
  42. void styleUpdated() override;
  43. /**
  44. * @brief Triggered when the value of the internal toggle button changes.
  45. */
  46. void valueChanged(bool newValue);
  47. GUIToggle* mToggle;
  48. bool mValue;
  49. };
  50. }