BsGUIVector2Field.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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/BsVector2.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 Vector2 input field.
  15. */
  16. class BS_ED_EXPORT GUIVector2Field : public TGUIField<GUIVector2Field>
  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 X input box. */
  22. static const String& getXFieldStyleType();
  23. /** Style type name for the internal Y input box. */
  24. static const String& getYFieldStyleType();
  25. GUIVector2Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  26. const String& style, const GUIDimensions& dimensions, bool withLabel);
  27. /** Returns the value of the input field. */
  28. Vector2 getValue() const;
  29. /** Sets a new value in the input field. */
  30. void setValue(const Vector2& value);
  31. /** Checks is the input field currently active. */
  32. bool hasInputFocus() const;
  33. /** @copydoc GUIElement::setTint */
  34. void setTint(const Color& color) override;
  35. Event<void(const Vector2&)> onValueChanged; /**< Triggers when the field value changes. */
  36. Event<void()> onConfirm; /**< Triggered when the user hits the Enter key with the input box in focus. */
  37. protected:
  38. virtual ~GUIVector2Field() = default;
  39. protected:
  40. static const UINT32 ELEMENT_LABEL_WIDTH;
  41. /** @copydoc GUIElement::styleUpdated */
  42. void styleUpdated() override;
  43. /** Triggered when the values in either of the input boxes change. */
  44. void valueChanged(float newValue);
  45. /** Triggered when the users confirms input in the input box. */
  46. void inputConfirmed();
  47. GUIFloatField* mFieldX;
  48. GUIFloatField* mFieldY;
  49. };
  50. /** @} */
  51. }