KWin
|
Helper to manipulate colors. More...
#include <colorhelper.h>
Public Types | |
enum | ShadeRole { LightShade , MidlightShade , MidShade , DarkShade , ShadowShade } |
enum | BackgroundRole { NormalBackground = 0 , AlternateBackground = 1 , ActiveBackground = 2 , LinkBackground = 3 , VisitedBackground = 4 , NegativeBackground = 5 , NeutralBackground = 6 , PositiveBackground = 7 } |
enum | ForegroundRole { NormalText = 0 , InactiveText = 1 , ActiveText = 2 , LinkText = 3 , VisitedText = 4 , NegativeText = 5 , NeutralText = 6 , PositiveText = 7 } |
Public Member Functions | |
ColorHelper (QObject *parent=nullptr) | |
~ColorHelper () override | |
Q_INVOKABLE QColor | shade (const QColor &color, ShadeRole role) |
Q_INVOKABLE QColor | shade (const QColor &color, ShadeRole role, qreal contrast) |
Q_INVOKABLE QColor | multiplyAlpha (const QColor &color, qreal alpha) |
Q_INVOKABLE QColor | background (bool active, BackgroundRole role=NormalBackground) const |
Q_INVOKABLE QColor | foreground (bool active, ForegroundRole role=NormalText) const |
qreal | contrast () const |
Properties | |
qreal | contrast |
Helper to manipulate colors.
Exports a few functions from KColorScheme.
Definition at line 16 of file colorhelper.h.
This enumeration describes the background color being selected from the given set.
Background colors are suitable for drawing under text, and should never be used to draw text. In combination with one of the overloads of KColorScheme::shade, they may be used to generate colors for drawing frames, bevels, and similar decorations.
Enumerator | |
---|---|
NormalBackground | Normal background. |
AlternateBackground | Alternate background; for example, for use in lists. This color may be the same as BackgroundNormal, especially in sets other than View and Window. |
ActiveBackground | Third color; for example, items which are new, active, requesting attention, etc. Alerting the user that a certain field must be filled out would be a good usage (although NegativeBackground could be used to the same effect, depending on what you are trying to achieve). Unlike ActiveText, this should not be used for mouseover effects. |
LinkBackground | Fourth color; corresponds to (unvisited) links. Exactly what this might be used for is somewhat harder to qualify; it might be used for bookmarks, as a 'you can click here' indicator, or to highlight recent content (i.e. in a most-recently-accessed list). |
VisitedBackground | Fifth color; corresponds to visited links. This can also be used to indicate "not recent" content, especially when a color is needed to denote content which is "old" or "archival". |
NegativeBackground | Sixth color; for example, errors, untrusted content, etc. |
NeutralBackground | Seventh color; for example, warnings, secure/encrypted content. |
PositiveBackground | Eigth color; for example, success messages, trusted content. |
Definition at line 68 of file colorhelper.h.
This enumeration describes the foreground color being selected from the given set.
Foreground colors are suitable for drawing text or glyphs (such as the symbols on window decoration buttons, assuming a suitable background brush is used), and should never be used to draw backgrounds.
For window decorations, the following is suggested, but not set in stone:
Definition at line 138 of file colorhelper.h.
This enumeration describes the color shade being selected from the given set.
Color shades are used to draw "3d" elements, such as frames and bevels. They are neither foreground nor background colors. Text should not be painted over a shade, and shades should not be used to draw text.
Definition at line 34 of file colorhelper.h.
|
explicit |
Definition at line 10 of file colorhelper.cpp.
|
override |
Definition at line 15 of file colorhelper.cpp.
QColor ColorHelper::background | ( | bool | active, |
ColorHelper::BackgroundRole | role = NormalBackground ) const |
Retrieve the requested background brush's color for the active
button.
active | Whether the active or inactive palette should be used. |
Definition at line 41 of file colorhelper.cpp.
qreal ColorHelper::contrast | ( | ) | const |
Definition at line 29 of file colorhelper.cpp.
QColor ColorHelper::foreground | ( | bool | active, |
ColorHelper::ForegroundRole | role = NormalText ) const |
Retrieve the requested foreground brush's color for the active
button.
active | Whether the active or inactive palette should be used. |
Definition at line 47 of file colorhelper.cpp.
QColor ColorHelper::multiplyAlpha | ( | const QColor & | color, |
qreal | alpha ) |
Retrieve the requested shade color, using the specified color as the base color and the specified contrast.
contrast | Amount roughly specifying the contrast by which to adjust the base color, between -1.0 and 1.0 (values between 0.0 and 1.0 correspond to the value from KGlobalSettings::contrastF) |
Definition at line 34 of file colorhelper.cpp.
QColor ColorHelper::shade | ( | const QColor & | color, |
ColorHelper::ShadeRole | role ) |
Retrieve the requested shade color, using the specified color as the base color and the system contrast setting.
Definition at line 19 of file colorhelper.cpp.
QColor ColorHelper::shade | ( | const QColor & | color, |
ColorHelper::ShadeRole | role, | ||
qreal | contrast ) |
Definition at line 24 of file colorhelper.cpp.
|
read |
Same as KGlobalSettings::contrastF.
Definition at line 22 of file colorhelper.h.