BsGUIVector4Field.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIFieldBase.h"
  4. #include "BsVector4.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief A composite GUI object representing an editor field. Editor fields are a combination
  9. * of a label and an input field. Label is optional. This specific implementation
  10. * displays a Vector4 input field.
  11. */
  12. class BS_ED_EXPORT GUIVector4Field : public TGUIField<GUIVector4Field>
  13. {
  14. public:
  15. /**
  16. * Returns type name of the GUI element used for finding GUI element styles.
  17. */
  18. static const String& getGUITypeName();
  19. /**
  20. * Style type name for the internal input boxes.
  21. */
  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. /**
  26. * @brief Returns the value of the input field.
  27. */
  28. Vector4 getValue() const;
  29. /**
  30. * @brief Sets a new value in the input field.
  31. */
  32. void setValue(const Vector4& value);
  33. /**
  34. * @brief Checks is the input field currently active.
  35. */
  36. bool hasInputFocus() const;
  37. /**
  38. * @copydoc GUIElement::setTint
  39. */
  40. virtual void setTint(const Color& color) override;
  41. Event<void(const Vector4&)> onValueChanged; /**< Triggers when the field value changes. */
  42. Event<void()> onConfirm; /**< Triggered when the user hits the Enter key with the input box in focus. */
  43. protected:
  44. virtual ~GUIVector4Field() { }
  45. /**
  46. * @copydoc GUIElement::setTint
  47. */
  48. void styleUpdated() override;
  49. /**
  50. * @brief Triggered when the values in any of the input boxes change.
  51. */
  52. void valueChanged(float newValue);
  53. /**
  54. * @brief Triggered when the users confirms input in the input box.
  55. */
  56. void inputConfirmed();
  57. static const UINT32 ELEMENT_LABEL_WIDTH;
  58. GUIFloatField* mFieldX;
  59. GUIFloatField* mFieldY;
  60. GUIFloatField* mFieldZ;
  61. GUIFloatField* mFieldW;
  62. };
  63. }