BsGUIToggleField.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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 "GUI/BsGUIFieldBase.h"
  6. namespace bs
  7. {
  8. /** @addtogroup GUI-Editor
  9. * @{
  10. */
  11. /**
  12. * A composite GUI object representing an editor field. Editor fields are a combination of a label and an input field.
  13. * Label is optional. This specific implementation displays a toggle button.
  14. */
  15. class BS_ED_EXPORT GUIToggleField : public TGUIField<GUIToggleField>
  16. {
  17. public:
  18. /** Returns type name of the GUI element used for finding GUI element styles. */
  19. static const String& getGUITypeName();
  20. /** Returns style type name of the internal GUIToggle element. */
  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. /** Returns the current value of the toggle. */
  25. bool getValue() const { return mValue; }
  26. /** Activates/deactivates the toggle. */
  27. void setValue(bool value);
  28. /** @copydoc GUIElement::setTint */
  29. void setTint(const Color& color) override;
  30. Event<void(bool)> onValueChanged; /** Triggered when the value of the toggle changes. */
  31. protected:
  32. virtual ~GUIToggleField() { }
  33. /** @copydoc GUIElement::styleUpdated */
  34. void styleUpdated() override;
  35. /** Triggered when the value of the internal toggle button changes. */
  36. void valueChanged(bool newValue);
  37. GUIToggle* mToggle;
  38. bool mValue;
  39. };
  40. /** @} */
  41. }