color_button.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * color_button.h - choose color button
  3. * Copyright (C) 2017 caryoscelus
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef __STUDIO__COLOR_BUTTON_H__2CC74D64
  19. #define __STUDIO__COLOR_BUTTON_H__2CC74D64
  20. #include <QDebug>
  21. #include <QPushButton>
  22. #include <core/color.h>
  23. #include <generic/node_editor.h>
  24. namespace core {
  25. template <class T>
  26. class Value;
  27. }
  28. namespace studio {
  29. class ColorButton : public QPushButton {
  30. Q_OBJECT
  31. public:
  32. ColorButton(QWidget* parent = nullptr);
  33. public:
  34. inline core::colors::Color value() const {
  35. return color;
  36. }
  37. void setReadOnly(bool ro);
  38. Q_SIGNALS:
  39. void editingFinished();
  40. protected:
  41. void update_value(core::colors::Color color_);
  42. private Q_SLOTS:
  43. void choose_color();
  44. private:
  45. void update_button_color();
  46. private:
  47. core::colors::Color color;
  48. };
  49. } // namespace studio
  50. #endif