BsGUIVector2Field.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIFieldBase.h"
  4. #include "BsVector2.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 Vector2 input field.
  11. */
  12. class BS_ED_EXPORT GUIVector2Field : public TGUIField<GUIVector2Field>
  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. GUIVector2Field(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. Vector2 getValue() const;
  29. /**
  30. * @brief Sets a new value in the input field.
  31. */
  32. void setValue(const Vector2& 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 Vector2&)> 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 ~GUIVector2Field() { }
  45. protected:
  46. static const UINT32 ELEMENT_LABEL_WIDTH;
  47. /**
  48. * @copydoc GUIElement::styleUpdated
  49. */
  50. void styleUpdated() override;
  51. /**
  52. * @brief Triggered when the values in either of the input boxes change.
  53. */
  54. void valueChanged(float newValue);
  55. /**
  56. * @brief Triggered when the users confirms input in the input box.
  57. */
  58. void inputConfirmed();
  59. GUIFloatField* mFieldX;
  60. GUIFloatField* mFieldY;
  61. };
  62. }