BsGUIVector4Field.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 "BsGUIFieldBase.h"
  6. #include "BsVector4.h"
  7. namespace BansheeEngine
  8. {
  9. /**
  10. * @brief A composite GUI object representing an editor field. Editor fields are a combination
  11. * of a label and an input field. Label is optional. This specific implementation
  12. * displays a Vector4 input field.
  13. */
  14. class BS_ED_EXPORT GUIVector4Field : public TGUIField<GUIVector4Field>
  15. {
  16. public:
  17. /**
  18. * Returns type name of the GUI element used for finding GUI element styles.
  19. */
  20. static const String& getGUITypeName();
  21. /**
  22. * Style type name for the internal input boxes.
  23. */
  24. static const String& getFloatFieldStyleType();
  25. GUIVector4Field(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  26. const String& style, const GUIDimensions& dimensions, bool withLabel);
  27. /**
  28. * @brief Returns the value of the input field.
  29. */
  30. Vector4 getValue() const;
  31. /**
  32. * @brief Sets a new value in the input field.
  33. */
  34. void setValue(const Vector4& value);
  35. /**
  36. * @brief Checks is the input field currently active.
  37. */
  38. bool hasInputFocus() const;
  39. /**
  40. * @copydoc GUIElement::setTint
  41. */
  42. virtual void setTint(const Color& color) override;
  43. Event<void(const Vector4&)> onValueChanged; /**< Triggers when the field value changes. */
  44. Event<void()> onConfirm; /**< Triggered when the user hits the Enter key with the input box in focus. */
  45. protected:
  46. virtual ~GUIVector4Field() { }
  47. /**
  48. * @copydoc GUIElement::setTint
  49. */
  50. void styleUpdated() override;
  51. /**
  52. * @brief Triggered when the values in any of the input boxes change.
  53. */
  54. void valueChanged(float newValue);
  55. /**
  56. * @brief Triggered when the users confirms input in the input box.
  57. */
  58. void inputConfirmed();
  59. static const UINT32 ELEMENT_LABEL_WIDTH;
  60. GUIFloatField* mFieldX;
  61. GUIFloatField* mFieldY;
  62. GUIFloatField* mFieldZ;
  63. GUIFloatField* mFieldW;
  64. };
  65. }