BsGUIVector3Field.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 input boxes. */
  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. /** Returns the value of the input field. */
  26. Vector3 getValue() const;
  27. /** Sets a new value in the input field. */
  28. void setValue(const Vector3& value);
  29. /** Checks is the input field currently active. */
  30. bool hasInputFocus() const;
  31. /** @copydoc GUIElement::setTint */
  32. virtual void setTint(const Color& color) override;
  33. Event<void(const Vector3&)> onValueChanged; /**< Triggers when the field value changes. */
  34. Event<void()> onConfirm; /**< Triggered when the user hits the Enter key with the input box in focus. */
  35. protected:
  36. virtual ~GUIVector3Field() { }
  37. /** @copydoc GUIElement::styleUpdated */
  38. void styleUpdated() override;
  39. /** Triggered when the values in any of the input boxes change. */
  40. void valueChanged(float newValue);
  41. /** Triggered when the users confirms input in the input box. */
  42. void inputConfirmed();
  43. static const UINT32 ELEMENT_LABEL_WIDTH;
  44. GUIFloatField* mFieldX;
  45. GUIFloatField* mFieldY;
  46. GUIFloatField* mFieldZ;
  47. };
  48. /** @} */
  49. }