hue_slider.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**
  2. * \file
  3. *
  4. * \author Mattia Basaglia
  5. *
  6. * \copyright Copyright (C) 2014 Calle Laakkonen
  7. * \copyright Copyright (C) 2013-2020 Mattia Basaglia
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Lesser General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. #ifndef HUE_SLIDER_HPP
  24. #define HUE_SLIDER_HPP
  25. #include "gradient_slider.hpp"
  26. namespace color_widgets {
  27. /**
  28. * \brief A slider for selecting a hue value
  29. */
  30. class QCP_EXPORT HueSlider : public GradientSlider
  31. {
  32. Q_OBJECT
  33. /**
  34. * \brief Saturation used in the rainbow gradient, as a [0-1] float
  35. */
  36. Q_PROPERTY(qreal colorSaturation READ colorSaturation WRITE setColorSaturation NOTIFY colorSaturationChanged)
  37. /**
  38. * \brief Value used in the rainbow gradient, as a [0-1] float
  39. */
  40. Q_PROPERTY(qreal colorValue READ colorValue WRITE setColorValue NOTIFY colorValueChanged)
  41. /**
  42. * \brief Alpha used in the rainbow gradient, as a [0-1] float
  43. */
  44. Q_PROPERTY(qreal colorAlpha READ colorAlpha WRITE setColorAlpha NOTIFY colorAlphaChanged)
  45. /**
  46. * \brief Color with corresponding color* components
  47. */
  48. Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
  49. /**
  50. * \brief Normalized Hue, as indicated from the slider
  51. */
  52. Q_PROPERTY(qreal colorHue READ colorHue WRITE setColorHue NOTIFY colorHueChanged)
  53. public:
  54. explicit HueSlider(QWidget *parent = nullptr);
  55. explicit HueSlider(Qt::Orientation orientation, QWidget *parent = nullptr);
  56. ~HueSlider();
  57. qreal colorSaturation() const;
  58. qreal colorValue() const;
  59. qreal colorAlpha() const;
  60. QColor color() const;
  61. qreal colorHue() const;
  62. public Q_SLOTS:
  63. void setColorValue(qreal value);
  64. void setColorSaturation(qreal value);
  65. void setColorAlpha(qreal alpha);
  66. void setColorHue(qreal colorHue);
  67. /**
  68. * \brief Set Hue Saturation and ColorValue, ignoring alpha
  69. */
  70. void setColor(const QColor& color);
  71. /**
  72. * \brief Set Hue Saturation, ColorValue and Alpha
  73. */
  74. void setFullColor(const QColor& color);
  75. Q_SIGNALS:
  76. void colorHueChanged(qreal colorHue);
  77. void colorChanged(QColor);
  78. void colorAlphaChanged(qreal v);
  79. void colorSaturationChanged(qreal v);
  80. void colorValueChanged(qreal v);
  81. private:
  82. class Private;
  83. Private * const p;
  84. };
  85. } // namespace color_widgets
  86. #endif // HUE_SLIDER_HPP