Krita Source Code Documentation
Loading...
Searching...
No Matches
StateEffects Class Reference

Public Member Functions

QBrush brush (const QBrush &background) const
 
QBrush brush (const QBrush &foreground, const QBrush &background) const
 
 StateEffects (QPalette::ColorGroup state, const KSharedConfigPtr &)
 
 ~StateEffects ()
 

Private Types

enum  Effects {
  Intensity = 0 , Color = 1 , Contrast = 2 , IntensityNoEffect = 0 ,
  IntensityShade = 1 , IntensityDarken = 2 , IntensityLighten = 3 , ColorNoEffect = 0 ,
  ColorDesaturate = 1 , ColorFade = 2 , ColorTint = 3 , ContrastNoEffect = 0 ,
  ContrastFade = 1 , ContrastTint = 2
}
 

Private Attributes

double _amount [3]
 
QColor _color
 
int _effects [3]
 

Detailed Description

Definition at line 18 of file kcolorscheme.cpp.

Member Enumeration Documentation

◆ Effects

enum StateEffects::Effects
private
Enumerator
Intensity 
Color 
Contrast 
IntensityNoEffect 
IntensityShade 
IntensityDarken 
IntensityLighten 
ColorNoEffect 
ColorDesaturate 
ColorFade 
ColorTint 
ContrastNoEffect 
ContrastFade 
ContrastTint 

Definition at line 28 of file kcolorscheme.cpp.

28 {
29 // Effects
30 Intensity = 0,
31 Color = 1,
32 Contrast = 2,
33 // Intensity
38 // Color
39 ColorNoEffect = 0,
41 ColorFade = 2,
42 ColorTint = 3,
43 // Contrast
45 ContrastFade = 1,
46 ContrastTint = 2
47 };

Constructor & Destructor Documentation

◆ StateEffects()

StateEffects::StateEffects ( QPalette::ColorGroup state,
const KSharedConfigPtr & config )
explicit

Definition at line 55 of file kcolorscheme.cpp.

56 : _color(0, 0, 0, 0) //, _chain(0) not needed yet
57{
58 QString group;
59 if (state == QPalette::Disabled) {
60 group = QLatin1String("ColorEffects:Disabled");
61 } else if (state == QPalette::Inactive) {
62 group = QLatin1String("ColorEffects:Inactive");
63 }
64
65 _effects[0] = 0;
66 _effects[1] = 0;
67 _effects[2] = 0;
68
69 // NOTE: keep this in sync with kdebase/workspace/kcontrol/colors/colorscm.cpp
70 if (! group.isEmpty()) {
71 KConfigGroup cfg(config, group);
72 const bool enabledByDefault = (state == QPalette::Disabled);
73 if (cfg.readEntry("Enable", enabledByDefault)) {
74 _effects[Intensity] = cfg.readEntry("IntensityEffect",
75 (int)(state == QPalette::Disabled ? IntensityDarken : IntensityNoEffect));
76 _effects[Color] = cfg.readEntry("ColorEffect",
77 (int)(state == QPalette::Disabled ? ColorNoEffect : ColorDesaturate));
78 _effects[Contrast] = cfg.readEntry("ContrastEffect",
79 (int)(state == QPalette::Disabled ? ContrastFade : ContrastTint));
80 _amount[Intensity] = cfg.readEntry("IntensityAmount", state == QPalette::Disabled ? 0.10 : 0.0);
81 _amount[Color] = cfg.readEntry("ColorAmount", state == QPalette::Disabled ? 0.0 : -0.9);
82 _amount[Contrast] = cfg.readEntry("ContrastAmount", state == QPalette::Disabled ? 0.65 : 0.25);
84 _color = cfg.readEntry("Color", state == QPalette::Disabled ? QColor(56, 56, 56) : QColor(112, 111, 110));
85 }
86 }
87 }
88}
double _amount[3]

References _amount, _color, _effects, Color, ColorDesaturate, ColorNoEffect, Contrast, ContrastFade, ContrastTint, Intensity, IntensityDarken, and IntensityNoEffect.

◆ ~StateEffects()

StateEffects::~StateEffects ( )
inline

Definition at line 22 of file kcolorscheme.cpp.

22{} //{ delete chain; } not needed yet

Member Function Documentation

◆ brush() [1/2]

QBrush StateEffects::brush ( const QBrush & background) const

Definition at line 90 of file kcolorscheme.cpp.

91{
92 QColor color = background.color(); // TODO - actually work on brushes
93 switch (_effects[Intensity]) {
94 case IntensityShade:
95 color = KColorUtils::shade(color, _amount[Intensity]);
96 break;
97 case IntensityDarken:
98 color = KColorUtils::darken(color, _amount[Intensity]);
99 break;
100 case IntensityLighten:
101 color = KColorUtils::lighten(color, _amount[Intensity]);
102 break;
103 }
104 switch (_effects[Color]) {
105 case ColorDesaturate:
106 color = KColorUtils::darken(color, 0.0, 1.0 - _amount[Color]);
107 break;
108 case ColorFade:
109 color = KColorUtils::mix(color, _color, _amount[Color]);
110 break;
111 case ColorTint:
112 color = KColorUtils::tint(color, _color, _amount[Color]);
113 break;
114 }
115 return QBrush(color);
116}

References _amount, _color, _effects, ColorDesaturate, ColorFade, ColorTint, Intensity, IntensityDarken, IntensityLighten, and IntensityShade.

◆ brush() [2/2]

QBrush StateEffects::brush ( const QBrush & foreground,
const QBrush & background ) const

Definition at line 118 of file kcolorscheme.cpp.

119{
120 QColor color = foreground.color(); // TODO - actually work on brushes
121 QColor bg = background.color();
122 // Apply the foreground effects
123 switch (_effects[Contrast]) {
124 case ContrastFade:
125 color = KColorUtils::mix(color, bg, _amount[Contrast]);
126 break;
127 case ContrastTint:
128 color = KColorUtils::tint(color, bg, _amount[Contrast]);
129 break;
130 }
131 // Now apply global effects
132 return brush(color);
133}
QBrush brush(const QBrush &background) const

References _amount, _effects, brush(), Contrast, ContrastFade, and ContrastTint.

Member Data Documentation

◆ _amount

double StateEffects::_amount[3]
private

Definition at line 50 of file kcolorscheme.cpp.

◆ _color

QColor StateEffects::_color
private

Definition at line 51 of file kcolorscheme.cpp.

◆ _effects

int StateEffects::_effects[3]
private

Definition at line 49 of file kcolorscheme.cpp.


The documentation for this class was generated from the following file: