BsGUIVector4Field.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #include "Math/BsVector4.h"
  7. namespace bs
  8. {
  9. /** @addtogroup GUI-Editor
  10. * @{
  11. */
  12. /**
  13. * A composite GUI object representing an editor field. Editor fields are a combination of a label and an input field.
  14. * Label is optional. This specific implementation displays a Vector4 input field.
  15. */
  16. class BS_ED_EXPORT GUIVector4Field : public TGUIField<GUIVector4Field>
  17. {
  18. public:
  19. /** Returns type name of the GUI element used for finding GUI element styles. */
  20. static const String& getGUITypeName();
  21. /** Style type name for the internal input boxes. */
  22. static const String& getFloatFieldStyleType();
  23. GUIVector4Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  24. const String& style, const GUIDimensions& dimensions, bool withLabel);
  25. /** Returns the value of the input field. */
  26. Vector4 getValue() const;
  27. /** Sets a new value in the input field. */
  28. void setValue(const Vector4& value);
  29. /** Checks is the input field currently active. */
  30. bool hasInputFocus() const;
  31. /** @copydoc GUIElement::setTint */
  32. virtual void setTint(const Color& color) override;
  33. Event<void(const Vector4&)> onValueChanged; /**< Triggers when the field value changes. */
  34. Event<void()> onConfirm; /**< Triggered when the user hits the Enter key with the input box in focus. */
  35. protected:
  36. virtual ~GUIVector4Field() { }
  37. /** @copydoc GUIElement::setTint */
  38. void styleUpdated() override;
  39. /** Triggered when the values in any of the input boxes change. */
  40. void valueChanged(float newValue);
  41. /** Triggered when the users confirms input in the input box. */
  42. void inputConfirmed();
  43. static const UINT32 ELEMENT_LABEL_WIDTH;
  44. GUIFloatField* mFieldX;
  45. GUIFloatField* mFieldY;
  46. GUIFloatField* mFieldZ;
  47. GUIFloatField* mFieldW;
  48. };
  49. /** @} */
  50. }