BsGUIColorField.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 "Image/BsColor.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 color input field.
  15. */
  16. class BS_ED_EXPORT GUIColorField : public TGUIField<GUIColorField>
  17. {
  18. public:
  19. /** Returns type name of the GUI element used for finding GUI element styles. */
  20. static const String& getGUITypeName();
  21. /** Style type name for the internal color field. */
  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. /** Returns the value of the field. */
  26. Color getValue() const { return mValue; }
  27. /** Changes the value of the field. */
  28. void setValue(const Color& value);
  29. /** @copydoc GUIElement::setTint */
  30. virtual void setTint(const Color& color) override;
  31. Event<void()> onClicked; /**< Triggered when the user clicks on the GUI element. */
  32. /** @name Internal
  33. * @{
  34. */
  35. /** @copydoc GUIElement::_getOptimalSize */
  36. Vector2I _getOptimalSize() const override;
  37. /** @} */
  38. protected:
  39. virtual ~GUIColorField();
  40. /** @copydoc GUIElement::styleUpdated */
  41. void styleUpdated() override;
  42. /** Triggered when the child color input field is clicked on. */
  43. void clicked();
  44. UINT32 mLabelWidth;
  45. Color mValue;
  46. GUILabel* mLabel;
  47. GUIColor* mColor;
  48. };
  49. /** @} */
  50. }