1 /*
2 * this file is part of the oxygen gtk engine
3 * Copyright (c) 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr>
4 * Copyright (c) 2010 Ruslan Kabatsayev <b7.10110111@gmail.com>
5 *
6 * inspired notably from kdelibs/kdeui/color/kcolorutils.h
7 * Copyright (C) 2007 Matthew Woehlke <mw_triad@users.sourceforge.net>
8 * Copyright (C) 2007 Thomas Zander <zander@kde.org>
9 * Copyright (C) 2007 Zack Rusin <zack@kde.org>
10 *
11 * This  library is free  software; you can  redistribute it and/or
12 * modify it  under  the terms  of the  GNU Lesser  General  Public
13 * License  as published  by the Free  Software  Foundation; either
14 * version 2 of the License, or( at your option ) any later version.
15 *
16 * This library is distributed  in the hope that it will be useful,
17 * but  WITHOUT ANY WARRANTY; without even  the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License  along  with  this library;  if not,  write to  the Free
23 * Software Foundation, Inc., 51  Franklin St, Fifth Floor, Boston,
24 * MA 02110-1301, USA.
25 */
26 
27 #include "oxygenshadowconfiguration.h"
28 #include "config.h"
29 
30 #include <cassert>
31 
32 namespace Oxygen
33 {
34 
35     //_________________________________________________________
ShadowConfiguration(Palette::Group group)36     ShadowConfiguration::ShadowConfiguration( Palette::Group group ):
37         _colorGroup(group),
38         _enabled(true)
39     {
40         assert(group==Palette::Active||group==Palette::Inactive);
41 
42         if( _colorGroup == Palette::Active )
43         {
44 
45             _shadowSize = 40;
46             _horizontalOffset = 0;
47             _verticalOffset = 0.1;
48 
49             _innerColor = ColorUtils::Rgba( 0.44, 0.94, 1.0 );
50             _outerColor = ColorUtils::Rgba( 0.33, 0.64, 0.94 );
51             _useOuterColor = true;
52 
53         } else {
54 
55             _shadowSize = 40;
56             _horizontalOffset = 0;
57             _verticalOffset = 0.2;
58 
59             _innerColor = ColorUtils::Rgba::black();
60             _outerColor = _innerColor;
61             _useOuterColor = false;
62 
63         }
64 
65     }
66 
67 
68     //_________________________________________________________
initialize(const OptionMap & options)69     void ShadowConfiguration::initialize( const OptionMap& options )
70     {
71 
72         #if OXYGEN_DEBUG
73         std::cerr << "Oxygen::ShadowConfiguration::initialize - " << (_colorGroup == Palette::Active ? "Active": "Inactive" ) << std::endl;
74         #endif
75 
76         if( _colorGroup == Palette::Active)
77         {
78 
79             _innerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[ActiveShadow]", "InnerColor", "112,241,255" ) );
80             _outerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[ActiveShadow]", "OuterColor", "84,167,240" ) );
81 
82             _shadowSize = options.getOption( "[ActiveShadow]","Size" ).toVariant<double>(40);
83             _verticalOffset = options.getOption( "[ActiveShadow]","VerticalOffset" ).toVariant<double>(0.1);
84             _useOuterColor = options.getOption( "[ActiveShadow]","UseOuterColor" ).toVariant<std::string>("true") == "true";
85 
86         } else {
87 
88             _innerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[InactiveShadow]", "InnerColor", "0,0,0" ) );
89             _outerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[InactiveShadow]", "OuterColor", "0,0,0" ) );
90 
91             _shadowSize = options.getOption( "[InactiveShadow]","Size" ).toVariant<double>(40);
92             _verticalOffset = options.getOption( "[InactiveShadow]","VerticalOffset" ).toVariant<double>(0.2);
93             _useOuterColor = options.getOption( "[InactiveShadow]", "UseOuterColor" ).toVariant<std::string>("false") == "true";
94 
95         }
96 
97         if(!_useOuterColor)
98             _outerColor=_innerColor;
99 
100     }
101 
102     //_________________________________________________________
operator <<(std::ostream & out,const ShadowConfiguration & configuration)103     std::ostream& operator << (std::ostream& out, const ShadowConfiguration& configuration )
104     {
105         out << "Oxygen::ShadowConfiguration - (" << (configuration._colorGroup == Palette::Active ? "Active": "Inactive" ) << ")" << std::endl;
106         out << "  enabled: " << (configuration._enabled ? "true":"false" ) << std::endl;
107         out << "  size: " << configuration._shadowSize << std::endl;
108         out << "  offset: " << configuration._verticalOffset << std::endl;
109         out << "  innerColor: " << configuration._innerColor << std::endl;
110         out << "  outerColor: ";
111         if( configuration._useOuterColor ) out << "unused";
112         else out <<  configuration._outerColor;
113         out << std::endl;
114         return out;
115     }
116 }
117