digiKam
dcolorchoosermode_p.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2010-02-20
7  * Description : color chooser widgets
8  *
9  * Copyright (C) 2010 by Christoph Feck <christoph at maxiom dot de>
10  * Copyright (C) 2015-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_DCOLOR_CHOOSER_MODE_PRIVATE_H
26 #define DIGIKAM_DCOLOR_CHOOSER_MODE_PRIVATE_H
27 
28 #include "dcolorchoosermode.h"
29 
30 // Qt includes
31 
32 #include <QtGlobal>
33 
34 class QColor;
35 
36 namespace Digikam
37 {
38 
42 extern qreal getComponentValue(const QColor& color, DColorChooserMode chooserMode);
43 extern void setComponentValue(QColor& color, DColorChooserMode chooserMode, qreal value);
44 
48 static inline int componentValueSteps(DColorChooserMode chooserMode)
49 {
50  if (chooserMode == ChooserHue)
51  {
52  return 6;
53  }
54  else
55  {
56  return 1;
57  }
58 }
59 
63 static inline DColorChooserMode chooserXMode(DColorChooserMode chooserMode)
64 {
65  if (chooserMode >= ChooserRed)
66  {
67  return (chooserMode == ChooserRed ? ChooserGreen : ChooserRed);
68  }
69  else
70  {
71  return (chooserMode == ChooserHue ? ChooserSaturation : ChooserHue);
72  }
73 }
74 
78 static inline DColorChooserMode chooserYMode(DColorChooserMode chooserMode)
79 {
80  if (chooserMode >= ChooserRed)
81  {
82  return (chooserMode == ChooserBlue ? ChooserGreen : ChooserBlue);
83  }
84  else
85  {
86  return (chooserMode == ChooserValue ? ChooserSaturation : ChooserValue);
87  }
88 }
89 
90 static inline int componentXSteps(DColorChooserMode chooserMode)
91 {
92  return componentValueSteps(chooserXMode(chooserMode));
93 }
94 
95 static inline int componentYSteps(DColorChooserMode chooserMode)
96 {
97  return componentValueSteps(chooserYMode(chooserMode));
98 }
99 
100 static inline qreal getComponentX(const QColor& color, DColorChooserMode chooserMode)
101 {
102  return getComponentValue(color, chooserXMode(chooserMode));
103 }
104 
105 static inline qreal getComponentY(const QColor& color, DColorChooserMode chooserMode)
106 {
107  return getComponentValue(color, chooserYMode(chooserMode));
108 }
109 
110 static inline void setComponentX(QColor& color, DColorChooserMode chooserMode, qreal x)
111 {
112  setComponentValue(color, chooserXMode(chooserMode), x);
113 }
114 
115 static inline void setComponentY(QColor& color, DColorChooserMode chooserMode, qreal y)
116 {
117  setComponentValue(color, chooserYMode(chooserMode), y);
118 }
119 
120 } // namespace Digikam
121 
122 #endif // DIGIKAM_DCOLOR_CHOOSER_MODE_PRIVATE_H
qulonglong value
Definition: itemviewutilities.cpp:592
Definition: datefolderview.cpp:43
DColorChooserMode
Definition: dcolorchoosermode.h:32
@ ChooserGreen
Definition: dcolorchoosermode.h:38
@ ChooserBlue
Definition: dcolorchoosermode.h:39
@ ChooserRed
Definition: dcolorchoosermode.h:37
@ ChooserHue
Definition: dcolorchoosermode.h:34
@ ChooserSaturation
Definition: dcolorchoosermode.h:35
@ ChooserValue
Definition: dcolorchoosermode.h:36
void setComponentValue(QColor &color, DColorChooserMode chooserMode, qreal value)
Definition: dcolorchoosermode.cpp:58
qreal getComponentValue(const QColor &color, DColorChooserMode chooserMode)
Definition: dcolorchoosermode.cpp:34