BsGUIVector2Field.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 "BsVector2.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 Vector2 input field.
  13. */
  14. class BS_ED_EXPORT GUIVector2Field : public TGUIField<GUIVector2Field>
  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. GUIVector2Field(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. Vector2 getValue() const;
  31. /**
  32. * @brief Sets a new value in the input field.
  33. */
  34. void setValue(const Vector2& 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 Vector2&)> 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 ~GUIVector2Field() { }
  47. protected:
  48. static const UINT32 ELEMENT_LABEL_WIDTH;
  49. /**
  50. * @copydoc GUIElement::styleUpdated
  51. */
  52. void styleUpdated() override;
  53. /**
  54. * @brief Triggered when the values in either of the input boxes change.
  55. */
  56. void valueChanged(float newValue);
  57. /**
  58. * @brief Triggered when the users confirms input in the input box.
  59. */
  60. void inputConfirmed();
  61. GUIFloatField* mFieldX;
  62. GUIFloatField* mFieldY;
  63. };
  64. }