BsGUIToggleField.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 toggle button.
  12. */
  13. class BS_ED_EXPORT GUIToggleField : public TGUIField<GUIToggleField>
  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. * Returns style type name of the internal GUIToggle element.
  22. */
  23. static const String& getToggleStyleType();
  24. GUIToggleField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  25. const String& style, const GUIDimensions& dimensions, bool withLabel);
  26. /**
  27. * @brief Returns the current value of the toggle.
  28. */
  29. bool getValue() const { return mValue; }
  30. /**
  31. * @brief Activates/deactivates the toggle.
  32. */
  33. void setValue(bool value);
  34. /**
  35. * @copydoc GUIElement::setTint
  36. */
  37. void setTint(const Color& color) override;
  38. /**
  39. * @brief Sets a new value in the input field, and also allows you to choose should the field trigger an
  40. * onValueChanged event.
  41. */
  42. void _setValue(bool value, bool triggerEvent);
  43. Event<void(bool)> onValueChanged; /** Triggered when the value of the toggle changes. */
  44. protected:
  45. virtual ~GUIToggleField() { }
  46. /**
  47. * @copydoc GUIElement::styleUpdated
  48. */
  49. void styleUpdated() override;
  50. /**
  51. * @brief Triggered when the value of the internal toggle button changes.
  52. */
  53. void valueChanged(bool newValue);
  54. GUIToggle* mToggle;
  55. bool mValue;
  56. };
  57. }