ColorButton.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #ifndef CRYINCLUDE_EDITORCOMMON_COLORBUTTON_H
  10. #define CRYINCLUDE_EDITORCOMMON_COLORBUTTON_H
  11. #include <Include/EditorCoreAPI.h>
  12. #if !defined(Q_MOC_RUN)
  13. #include <QToolButton>
  14. #endif
  15. class QColor;
  16. class QPaintEvent;
  17. class EDITOR_CORE_API ColorButton
  18. : public QToolButton
  19. {
  20. Q_OBJECT
  21. Q_PROPERTY(QColor Color READ Color WRITE SetColor)
  22. public:
  23. ColorButton(QWidget* parent = nullptr);
  24. virtual ~ColorButton() {};
  25. QColor Color() const { return m_color; }
  26. void SetColor(const QColor& color)
  27. {
  28. m_color = color;
  29. update();
  30. }
  31. protected:
  32. void paintEvent(QPaintEvent* event) override;
  33. private:
  34. QColor m_color;
  35. signals:
  36. void ColorChanged(const QColor& color);
  37. private slots:
  38. void OnClick();
  39. };
  40. #endif // CRYINCLUDE_EDITORCOMMON_COLORBUTTON_H