BsGUIColorField.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIFieldBase.h"
  4. #include "BsColor.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief A composite GUI object representing an editor field. Editor fields are a combination
  9. * of a label and an input field. Label is optional. This specific implementation
  10. * displays a color input field.
  11. */
  12. class BS_ED_EXPORT GUIColorField : public TGUIField<GUIColorField>
  13. {
  14. public:
  15. /**
  16. * Returns type name of the GUI element used for finding GUI element styles.
  17. */
  18. static const String& getGUITypeName();
  19. /**
  20. * Style type name for the internal color field.
  21. */
  22. static const String& getColorInputStyleType();
  23. GUIColorField(const PrivatelyConstruct& dummy, const GUIContent& labelContent, UINT32 labelWidth,
  24. const String& style, const GUIDimensions& dimensions, bool withLabel);
  25. /**
  26. * @brief Returns the value of the field.
  27. */
  28. Color getValue() const { return mValue; }
  29. /**
  30. * @brief Changes the value of the field.
  31. */
  32. void setValue(const Color& value);
  33. /**
  34. * @copydoc GUIElement::setTint
  35. */
  36. virtual void setTint(const Color& color) override;
  37. /**
  38. * @copydoc GUIElement::_getOptimalSize
  39. */
  40. Vector2I _getOptimalSize() const override;
  41. Event<void()> onClicked; /**< Triggered when the user clicks on the GUI element. */
  42. protected:
  43. virtual ~GUIColorField();
  44. /**
  45. * @copydoc GUIElement::styleUpdated
  46. */
  47. void styleUpdated() override;
  48. /**
  49. * @brief Triggered when the child color input field is clicked on.
  50. */
  51. void clicked();
  52. UINT32 mLabelWidth;
  53. Color mValue;
  54. GUILabel* mLabel;
  55. GUIColor* mColor;
  56. };
  57. }