File indexing completed on 2024-04-28 05:32:12
0001 /* 0002 this file is part of the oxygen gtk engine 0003 SPDX-FileCopyrightText: 2010 Hugo Pereira Da Costa <hugo.pereira@free.fr> 0004 0005 inspired notably from kdelibs/kdeui/color/kcolorscheme.h 0006 SPDX-FileCopyrightText: 2007 Matthew Woehlke <mw_triad@users.sourceforge.net> 0007 0008 SPDX-License-Identifier: LGPL-2.0-or-later 0009 */ 0010 0011 #include "oxygenpalette.h" 0012 #include "oxygencoloreffect.h" 0013 #include "oxygencolorutils.h" 0014 0015 namespace Oxygen 0016 { 0017 0018 //____________________________________________________________________________________ 0019 std::ostream& operator << ( std::ostream& out, const Palette::ColorList& colors ) 0020 { 0021 for( unsigned int i=0; i<colors.size(); i++ ) 0022 { out << Palette::roleName( Palette::Role(i) ) << "=" << colors[i] << std::endl; } 0023 0024 return out; 0025 0026 } 0027 0028 //____________________________________________________________________________________ 0029 std::ostream& operator << ( std::ostream& out, const Palette::ColorSet& colors ) 0030 { 0031 for( Palette::ColorSet::const_iterator iter = colors.begin(); iter != colors.end(); ++iter ) 0032 { out << Palette::roleName( iter->first ) << "=" << iter->second << std::endl; } 0033 0034 return out; 0035 0036 } 0037 0038 //____________________________________________________________________________________ 0039 std::ostream& operator << ( std::ostream& out, const Palette& palette ) 0040 { 0041 out << "[Colors:" << Palette::groupName( Palette::Active ) << "]" << std::endl; 0042 out << palette._activeColors << std::endl; 0043 0044 out << "[Colors:" << Palette::groupName( Palette::Inactive ) << "]" << std::endl; 0045 out << palette._inactiveColors << std::endl; 0046 0047 out << "[Colors:" << Palette::groupName( Palette::Disabled ) << "]" << std::endl; 0048 out << palette._disabledColors << std::endl; 0049 0050 return out; 0051 } 0052 0053 //_______________________________________________________ 0054 void Palette::generate( Group from, Group to, const ColorUtils::Effect& effect, bool changeSelectionColor ) 0055 { 0056 // start by copying palette 0057 colorList(to) = colorList(from); 0058 0059 const ColorList& source = colorList(from); 0060 ColorList &destination = colorList(to); 0061 0062 // apply effects to background 0063 destination[Window] = effect.color(source[Window]); 0064 destination[Button] = effect.color(source[Button]); 0065 destination[Base] = effect.color(source[Base]); 0066 destination[BaseAlternate] = effect.color(source[BaseAlternate]); 0067 0068 if( changeSelectionColor ) destination[Selected] = effect.color( ColorUtils::tint( source[Window], source[Selected], 0.4 ) ); 0069 else destination[Selected] = effect.color( source[Selected] ); 0070 0071 // apply effects to text 0072 destination[WindowText] = effect.color( effect.color( source[WindowText], source[Window] ) ); 0073 destination[ButtonText] = effect.color( effect.color( source[ButtonText], source[Button] ) ); 0074 destination[Text] = effect.color( effect.color(source[Text], source[Base] ) ); 0075 0076 // apply effects to focus 0077 destination[Focus] = effect.color(source[Focus], source[Base] ); 0078 destination[Hover] = effect.color(source[Hover], source[Base] ); 0079 0080 } 0081 0082 }