BsGUIVector4Field.h 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/BsVector4.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 Vector4 input field.
  15. */
  16. class BS_ED_EXPORT BS_SCRIPT_EXPORT(m:GUIEditor,api:bed)
  17. GUIVector4Field final : public TGUIField<GUIVector4Field>
  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. /** Style type name for the internal W input box. */
  29. static constexpr const char* W_FIELD_STYLE_TYPE = "WFloatField";
  30. GUIVector4Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  31. const String& style, const GUIDimensions& dimensions, bool withLabel);
  32. /** Returns the value of the input field. */
  33. BS_SCRIPT_EXPORT(pr:getter,n:Value)
  34. Vector4 getValue() const;
  35. /** Sets a new value in the input field. */
  36. BS_SCRIPT_EXPORT(pr:setter,n:Value)
  37. void setValue(const Vector4& value);
  38. /** Checks is the input field currently active. */
  39. BS_SCRIPT_EXPORT(pr:getter,n:HasInputFocus)
  40. bool hasInputFocus() const;
  41. /** Sets input focus to a specific component's input box. */
  42. BS_SCRIPT_EXPORT()
  43. void setInputFocus(VectorComponent component, bool focus);
  44. /** @copydoc GUIElement::setTint */
  45. void setTint(const Color& color) override;
  46. /** Reports the new value of the vector when the user changes the value of any of the vector components. */
  47. BS_SCRIPT_EXPORT()
  48. Event<void(const Vector4&)> onValueChanged;
  49. /** Reports the new value of an individual vector component when the user changes it. */
  50. BS_SCRIPT_EXPORT()
  51. Event<void(float, VectorComponent)> onComponentChanged;
  52. /** Triggered when an individual component loses or gains focus. */
  53. BS_SCRIPT_EXPORT()
  54. Event<void(bool, VectorComponent)> onComponentFocusChanged;
  55. /** Triggered when the user hits the Enter key with any of the component input boxes in focus. */
  56. BS_SCRIPT_EXPORT()
  57. Event<void(VectorComponent)> onConfirm;
  58. protected:
  59. /** @copydoc GUIElement::setTint */
  60. void styleUpdated() override;
  61. /** Triggered when the values in any of the input boxes change. */
  62. void valueChanged(float newValue, VectorComponent component);
  63. /** Triggered when the users confirms input in the input box. */
  64. void inputConfirmed(VectorComponent component);
  65. static const UINT32 ELEMENT_LABEL_WIDTH;
  66. GUIFloatField* mFieldX = nullptr;
  67. GUIFloatField* mFieldY = nullptr;
  68. GUIFloatField* mFieldZ = nullptr;
  69. GUIFloatField* mFieldW = nullptr;
  70. };
  71. /** @} */
  72. }