File indexing completed on 2024-04-28 05:32:14
0001 /* 0002 this file is part of the oxygen gtk engine 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0004 SPDX-FileCopyrightText: 2010 Ruslan Kabatsayev <b7.10110111@gmail.com> 0005 0006 inspired notably from kdelibs/kdeui/color/kcolorutils.h 0007 SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> 0008 SPDX-FileCopyrightText: 2007 Thomas Zander <zander@kde.org> 0009 SPDX-FileCopyrightText: 2007 Zack Rusin <zack@kde.org> 0010 0011 SPDX-License-Identifier: LGPL-2.0-or-later 0012 */ 0013 0014 #include "oxygenshadowconfiguration.h" 0015 #include "config.h" 0016 0017 #include <cassert> 0018 0019 namespace Oxygen 0020 { 0021 0022 //_________________________________________________________ 0023 ShadowConfiguration::ShadowConfiguration( Palette::Group group ): 0024 _colorGroup(group), 0025 _enabled(true) 0026 { 0027 assert(group==Palette::Active||group==Palette::Inactive); 0028 0029 if( _colorGroup == Palette::Active ) 0030 { 0031 0032 _shadowSize = 40; 0033 _horizontalOffset = 0; 0034 _verticalOffset = 0.1; 0035 0036 _innerColor = ColorUtils::Rgba( 0.44, 0.94, 1.0 ); 0037 _outerColor = ColorUtils::Rgba( 0.33, 0.64, 0.94 ); 0038 _useOuterColor = true; 0039 0040 } else { 0041 0042 _shadowSize = 40; 0043 _horizontalOffset = 0; 0044 _verticalOffset = 0.2; 0045 0046 _innerColor = ColorUtils::Rgba::black(); 0047 _outerColor = _innerColor; 0048 _useOuterColor = false; 0049 0050 } 0051 0052 } 0053 0054 0055 //_________________________________________________________ 0056 void ShadowConfiguration::initialize( const OptionMap& options ) 0057 { 0058 0059 #if OXYGEN_DEBUG 0060 std::cerr << "Oxygen::ShadowConfiguration::initialize - " << (_colorGroup == Palette::Active ? "Active": "Inactive" ) << std::endl; 0061 #endif 0062 0063 if( _colorGroup == Palette::Active) 0064 { 0065 0066 _innerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[ActiveShadow]", "InnerColor", "112,241,255" ) ); 0067 _outerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[ActiveShadow]", "OuterColor", "84,167,240" ) ); 0068 0069 _shadowSize = options.getOption( "[ActiveShadow]","Size" ).toVariant<double>(40); 0070 _verticalOffset = options.getOption( "[ActiveShadow]","VerticalOffset" ).toVariant<double>(0.1); 0071 _useOuterColor = options.getOption( "[ActiveShadow]","UseOuterColor" ).toVariant<std::string>("true") == "true"; 0072 0073 } else { 0074 0075 _innerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[InactiveShadow]", "InnerColor", "0,0,0" ) ); 0076 _outerColor = ColorUtils::Rgba::fromKdeOption( options.getValue( "[InactiveShadow]", "OuterColor", "0,0,0" ) ); 0077 0078 _shadowSize = options.getOption( "[InactiveShadow]","Size" ).toVariant<double>(40); 0079 _verticalOffset = options.getOption( "[InactiveShadow]","VerticalOffset" ).toVariant<double>(0.2); 0080 _useOuterColor = options.getOption( "[InactiveShadow]", "UseOuterColor" ).toVariant<std::string>("false") == "true"; 0081 0082 } 0083 0084 if(!_useOuterColor) 0085 _outerColor=_innerColor; 0086 0087 } 0088 0089 //_________________________________________________________ 0090 std::ostream& operator << (std::ostream& out, const ShadowConfiguration& configuration ) 0091 { 0092 out << "Oxygen::ShadowConfiguration - (" << (configuration._colorGroup == Palette::Active ? "Active": "Inactive" ) << ")" << std::endl; 0093 out << " enabled: " << (configuration._enabled ? "true":"false" ) << std::endl; 0094 out << " size: " << configuration._shadowSize << std::endl; 0095 out << " offset: " << configuration._verticalOffset << std::endl; 0096 out << " innerColor: " << configuration._innerColor << std::endl; 0097 out << " outerColor: "; 0098 if( configuration._useOuterColor ) out << "unused"; 0099 else out << configuration._outerColor; 0100 out << std::endl; 0101 return out; 0102 } 0103 }