File indexing completed on 2024-04-28 05:32:10

0001 #ifndef oxygencoloreffect_h
0002 #define oxygencoloreffect_h
0003 /*
0004 * this file is part of the oxygen gtk engine
0005 * SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
0006 *
0007 * inspired notably from kdelibs/kdeui/colors/kcolorscheme.h
0008 * SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
0009 *
0010 * SPDX-License-Identifier: LGPL-2.0-or-later
0011 */
0012 
0013 #include "oxygenpalette.h"
0014 #include "oxygenrgba.h"
0015 
0016 #include <iostream>
0017 
0018 namespace Oxygen
0019 {
0020 
0021     // forward declaration
0022     class OptionMap;
0023 
0024     namespace ColorUtils
0025     {
0026 
0027         //! used to handle color modification effects
0028         /*! used notably to generate the correct disabled palette from kde options */
0029         class Effect
0030         {
0031 
0032             public:
0033 
0034             //!constructor
0035             explicit Effect( void ):
0036                 _intensityEffect( IntensityNoEffect ),
0037                 _intensityEffectAmount(0),
0038                 _colorEffect( ColorNoEffect ),
0039                 _colorEffectAmount(0),
0040                 _contrastEffect( ContrastNoEffect ),
0041                 _contrastEffectAmount(0),
0042                 _enabled( false )
0043             {}
0044 
0045             //! constructor from option map
0046             explicit Effect( Palette::Group, const OptionMap& );
0047 
0048             //! destructor
0049             virtual ~Effect( void )
0050             {}
0051 
0052             //! apply effect to input background
0053             Rgba color( const Rgba& background ) const;
0054 
0055             //! apply effect to input foreground
0056             Rgba color( const Rgba& foreground, const Rgba& background ) const;
0057 
0058             private:
0059 
0060             //!@name intensity
0061             //@{
0062 
0063             enum IntensityEffect
0064             {
0065                 IntensityNoEffect,
0066                 IntensityShade,
0067                 IntensityDarken,
0068                 IntensityLighten,
0069             };
0070 
0071             IntensityEffect _intensityEffect;
0072             double _intensityEffectAmount;
0073 
0074             //@}
0075 
0076             //!@name color
0077             //@{
0078 
0079             enum ColorEffect
0080             {
0081                 ColorNoEffect,
0082                 ColorDesaturate,
0083                 ColorFade,
0084                 ColorTint
0085             };
0086 
0087             Rgba _color;
0088             ColorEffect _colorEffect;
0089             double _colorEffectAmount;
0090 
0091             //@}
0092 
0093             //!@name contrast
0094             //@{
0095 
0096             enum ContrastEffect
0097             {
0098                 ContrastNoEffect,
0099                 ContrastFade,
0100                 ContrastTint
0101             };
0102 
0103             ContrastEffect _contrastEffect;
0104             double _contrastEffectAmount;
0105 
0106             //@}
0107 
0108             //! enable state
0109             bool _enabled;
0110 
0111             // streamer
0112             friend std::ostream& operator << (std::ostream&, const Effect& );
0113 
0114         };
0115 
0116     }
0117 }
0118 #endif