BsGUIVector3Field.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 BS_SCRIPT_EXPORT(m:GUIEditor,api:bed)
  17. GUIVector3Field final : public TGUIField<GUIVector3Field>
  18. {
  19. public:
  20. /** Returns type name of the GUI element used for finding GUI element styles. */
  21. static const String& getGUITypeName();
  22. /** Style type name for the internal X input box. */
  23. static constexpr const char* X_FIELD_STYLE_TYPE = "XFloatField";
  24. /** Style type name for the internal Y input box. */
  25. static constexpr const char* Y_FIELD_STYLE_TYPE = "YFloatField";
  26. /** Style type name for the internal Z input box. */
  27. static constexpr const char* Z_FIELD_STYLE_TYPE = "ZFloatField";
  28. GUIVector3Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  29. const String& style, const GUIDimensions& dimensions, bool withLabel);
  30. /** Returns the value of the input field. */
  31. BS_SCRIPT_EXPORT(pr:getter,n:Value)
  32. Vector3 getValue() const;
  33. /** Sets a new value in the input field. */
  34. BS_SCRIPT_EXPORT(pr:setter,n:Value)
  35. void setValue(const Vector3& value);
  36. /** Checks is the input field currently active. */
  37. BS_SCRIPT_EXPORT(pr:getter,n:HasInputFocus)
  38. bool hasInputFocus() const;
  39. /** Sets input focus to a specific component's input box. */
  40. BS_SCRIPT_EXPORT()
  41. void setInputFocus(VectorComponent component, bool focus);
  42. /** @copydoc GUIElement::setTint */
  43. void setTint(const Color& color) override;
  44. /** Reports the new value of the vector when the user changes the value of any of the vector components. */
  45. BS_SCRIPT_EXPORT()
  46. Event<void(const Vector3&)> onValueChanged;
  47. /** Reports the new value of an individual vector component when the user changes it. */
  48. BS_SCRIPT_EXPORT()
  49. Event<void(float, VectorComponent)> onComponentChanged;
  50. /** Triggered when an individual component loses or gains focus. */
  51. BS_SCRIPT_EXPORT()
  52. Event<void(bool, VectorComponent)> onComponentFocusChanged;
  53. /** Triggered when the user hits the Enter key with any of the component input boxes in focus. */
  54. BS_SCRIPT_EXPORT()
  55. Event<void(VectorComponent)> onConfirm;
  56. protected:
  57. /** @copydoc GUIElement::styleUpdated */
  58. void styleUpdated() override;
  59. /** Triggered when the values in any of the input boxes change. */
  60. void valueChanged(float newValue, VectorComponent component);
  61. /** Triggered when the users confirms input in the input box. */
  62. void inputConfirmed(VectorComponent component);
  63. static const UINT32 ELEMENT_LABEL_WIDTH;
  64. GUIFloatField* mFieldX = nullptr;
  65. GUIFloatField* mFieldY = nullptr;
  66. GUIFloatField* mFieldZ = nullptr;
  67. };
  68. /** @} */
  69. }