BsGUIVector3Field.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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/BsVector3.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 Vector3 input field.
  15. */
  16. class BS_ED_EXPORT GUIVector3Field : public TGUIField<GUIVector3Field>
  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. /** Style type name for the internal Z input box. */
  26. static const String& getZFieldStyleType();
  27. GUIVector3Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  28. const String& style, const GUIDimensions& dimensions, bool withLabel);
  29. /** Returns the value of the input field. */
  30. Vector3 getValue() const;
  31. /** Sets a new value in the input field. */
  32. void setValue(const Vector3& value);
  33. /** Checks is the input field currently active. */
  34. bool hasInputFocus() const;
  35. /** @copydoc GUIElement::setTint */
  36. void setTint(const Color& color) override;
  37. Event<void(const Vector3&)> onValueChanged; /**< Triggers when the field value changes. */
  38. Event<void()> onConfirm; /**< Triggered when the user hits the Enter key with the input box in focus. */
  39. protected:
  40. virtual ~GUIVector3Field() = default;
  41. /** @copydoc GUIElement::styleUpdated */
  42. void styleUpdated() override;
  43. /** Triggered when the values in any 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. static const UINT32 ELEMENT_LABEL_WIDTH;
  48. GUIFloatField* mFieldX;
  49. GUIFloatField* mFieldY;
  50. GUIFloatField* mFieldZ;
  51. };
  52. /** @} */
  53. }