BsGUIColor.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsGUIElement.h"
  4. #include "BsImageSprite.h"
  5. #include "BsGUIContent.h"
  6. namespace BansheeEngine
  7. {
  8. class GUIColor : public GUIElement
  9. {
  10. public:
  11. static const String& getGUITypeName();
  12. static GUIColor* create(const String& styleName = StringUtil::BLANK);
  13. static GUIColor* create(const GUIOptions& options, const String& styleName = StringUtil::BLANK);
  14. virtual Vector2I _getOptimalSize() const;
  15. void setColor(const Color& color);
  16. Color getColor() const { return mColor; }
  17. /**
  18. * @copydoc GUIElement::setTint
  19. */
  20. virtual void setTint(const Color& color);
  21. Event<void(const Color&)> onValueChanged;
  22. protected:
  23. GUIColor(const String& styleName, const GUIDimensions& dimensions);
  24. virtual ~GUIColor();
  25. /**
  26. * @copydoc GUIElement::getNumRenderElements()
  27. */
  28. virtual UINT32 _getNumRenderElements() const;
  29. /**
  30. * @copydoc GUIElement::getMaterial()
  31. */
  32. virtual const GUIMaterialInfo& _getMaterial(UINT32 renderElementIdx) const;
  33. /**
  34. * @copydoc GUIElement::getNumQuads()
  35. */
  36. virtual UINT32 _getNumQuads(UINT32 renderElementIdx) const;
  37. /**
  38. * @copydoc GUIElement::fillBuffer()
  39. */
  40. virtual void _fillBuffer(UINT8* vertices, UINT8* uv, UINT32* indices, UINT32 startingQuad,
  41. UINT32 maxNumQuads, UINT32 vertexStride, UINT32 indexStride, UINT32 renderElementIdx) const;
  42. /**
  43. * @copydoc GUIElement::updateRenderElementsInternal()
  44. */
  45. virtual void updateRenderElementsInternal();
  46. /**
  47. * @copydoc GUIElement::updateBounds()
  48. */
  49. virtual void updateClippedBounds();
  50. virtual bool _mouseEvent(const GUIMouseEvent& ev);
  51. private:
  52. static const float ALPHA_SPLIT_POSITION;
  53. ImageSprite* mColorSprite;
  54. ImageSprite* mAlphaSprite;
  55. IMAGE_SPRITE_DESC mColorImageDesc;
  56. IMAGE_SPRITE_DESC mAlphaImageDesc;
  57. Color mColor;
  58. Color mTint;
  59. };
  60. }