| Wireshark 4.7.3 The Wireshark network protocol analyzer

Loading...
Searching...
No Matches
color_math.h
Go to the documentation of this file.
1
9
10#ifndef COLOR_MATH_H
11#define COLOR_MATH_H
12
13#include <ui/qt/utils/theme_manager.h>
14
15#include <QColor>
16
28 class ColorMath
29{
30 public:
31 // ---------------------------------------------------------------
32 // Luminance & contrast
33 // ---------------------------------------------------------------
34
36 static double relativeLuminance(const QColor &color);
37
40 static qreal contrastRatio(const QColor &color1, const QColor &color2);
41
52 static QColor ensureContrast(const QColor &c, const QColor &bg, qreal minRatio);
53
57 static bool isDark(const QColor &color);
58
59 // ---------------------------------------------------------------
60 // Mix / shade
61 // ---------------------------------------------------------------
62
65 static QColor mix(const QColor &a, const QColor &b, qreal ratio = 0.5);
66 static ThemeColorPair mix(const ThemeColorPair &a, const ThemeColorPair &b, qreal ratio = 0.5);
67
70 static QColor darken(const QColor &c, int percent);
71 static ThemeColorPair darken(const ThemeColorPair &p, int percent);
72
75 static QColor lighten(const QColor &c, int percent);
76 static ThemeColorPair lighten(const ThemeColorPair &p, int percent);
77
78 // ---------------------------------------------------------------
79 // Alpha
80 // ---------------------------------------------------------------
81
83 static QColor withAlpha(const QColor &c, int alpha);
84 static ThemeColorPair withAlpha(const ThemeColorPair &p, int alpha);
85
87 static QColor withAlphaF(const QColor &c, qreal alpha);
88 static ThemeColorPair withAlphaF(const ThemeColorPair &p, qreal alpha);
89
90 // ---------------------------------------------------------------
91 // Contrast & state
92 // ---------------------------------------------------------------
93
97 static QColor contrastingText(const QColor &surface);
98 static ThemeColorPair contrastingText(const ThemeColorPair &pair);
99
104 static QColor contrastingTextOver(const QColor &surface, const QColor &backdrop);
105
107 static QColor disabled(const QColor &c, const QColor &background);
108 static ThemeColorPair disabled(const ThemeColorPair &p, const QColor &background);
109
111 static QColor hoverBg(const QColor &c, const QColor &background);
112 static ThemeColorPair hoverBg(const ThemeColorPair &p, const QColor &background);
113};
114
115#endif /* COLOR_MATH_H */
ColorMath
Definition color_math.h:29
ColorMath::isDark
static bool isDark(const QColor &color)
Definition color_math.cpp:71
ColorMath::withAlpha
static QColor withAlpha(const QColor &c, int alpha)
Definition color_math.cpp:133
ColorMath::contrastingTextOver
static QColor contrastingTextOver(const QColor &surface, const QColor &backdrop)
Definition color_math.cpp:184
ColorMath::ensureContrast
static QColor ensureContrast(const QColor &c, const QColor &bg, qreal minRatio)
Definition color_math.cpp:51
ColorMath::lighten
static QColor lighten(const QColor &c, int percent)
Definition color_math.cpp:115
ColorMath::disabled
static QColor disabled(const QColor &c, const QColor &background)
Definition color_math.cpp:202
ColorMath::mix
static QColor mix(const QColor &a, const QColor &b, qreal ratio=0.5)
Definition color_math.cpp:80
ColorMath::darken
static QColor darken(const QColor &c, int percent)
Definition color_math.cpp:101
ColorMath::contrastRatio
static qreal contrastRatio(const QColor &color1, const QColor &color2)
Definition color_math.cpp:42
ColorMath::withAlphaF
static QColor withAlphaF(const QColor &c, qreal alpha)
Definition color_math.cpp:145
ColorMath::contrastingText
static QColor contrastingText(const QColor &surface)
Definition color_math.cpp:161
ColorMath::relativeLuminance
static double relativeLuminance(const QColor &color)
Definition color_math.cpp:34
ColorMath::hoverBg
static QColor hoverBg(const QColor &c, const QColor &background)
Definition color_math.cpp:212
ThemeColorPair
Definition theme_manager.h:39
theme_manager.h