BsGUIVector3Field.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIFieldBase.h"
  4. #include "BsVector3.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 Vector3 input field.
  11. */
  12. class BS_ED_EXPORT GUIVector3Field : public TGUIField<GUIVector3Field>
  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. GUIVector3Field(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. Vector3 getValue() const;
  29. /**
  30. * @brief Sets a new value in the input field.
  31. */
  32. void setValue(const Vector3& 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 Vector3&)> 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 ~GUIVector3Field() { }
  45. /**
  46. * @copydoc GUIElement::styleUpdated
  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. };
  62. }