BsGUIColorField.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "BsColor.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 color input field.
  13. */
  14. class BS_ED_EXPORT GUIColorField : public TGUIField<GUIColorField>
  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 color field.
  23. */
  24. static const String& getColorInputStyleType();
  25. GUIColorField(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 field.
  29. */
  30. Color getValue() const { return mValue; }
  31. /**
  32. * @brief Changes the value of the field.
  33. */
  34. void setValue(const Color& value);
  35. /**
  36. * @copydoc GUIElement::setTint
  37. */
  38. virtual void setTint(const Color& color) override;
  39. /**
  40. * @copydoc GUIElement::_getOptimalSize
  41. */
  42. Vector2I _getOptimalSize() const override;
  43. Event<void()> onClicked; /**< Triggered when the user clicks on the GUI element. */
  44. protected:
  45. virtual ~GUIColorField();
  46. /**
  47. * @copydoc GUIElement::styleUpdated
  48. */
  49. void styleUpdated() override;
  50. /**
  51. * @brief Triggered when the child color input field is clicked on.
  52. */
  53. void clicked();
  54. UINT32 mLabelWidth;
  55. Color mValue;
  56. GUILabel* mLabel;
  57. GUIColor* mColor;
  58. };
  59. }