1 #ifndef COLORSCHEME_H_HEADER_DEFINED
2 #define COLORSCHEME_H_HEADER_DEFINED
3 
4 #include "../libAfterImage/afterimage.h"
5 
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
9 
10 /* Color scheme principles :
11  *	Primary colors :
12  *		We use 4 primary colors : Base(background), Inactive1, Inactive2 and Active
13  *		Then we use 3 contrasting colors for InactiveText1, InactiveText2 and ActiveText
14  *      -----------------
15  * 		7 colors total.
16  * 		It makes sense to use analogous color scheme with 4 complimetary color :
17  * 		here is the color hues relationship :
18  *
19  * 		Inactive1	= Base + Angle
20  * 		Inactive2	= Base - Angle
21  * 		Active		= Base - 180    ( complimentary to Background )
22  *
23  * 		where Angle is preset constant in range of 10-60 ( default is 30 ).
24  *
25  * 		Brightness of each of these colors should not exceed 80%.
26  *
27  * 		For the text we use either witish or blackish color, which we calculate by
28  *      either reducing saturation of the contrasting color to  5% ( to get witish color )
29  *          or reducing brightness of the contrasting color to 30% ( to get blackish color )
30  *
31  * 		To determine if we need blackish or witish color we use this formula :
32  * 		if( (0.5*Red+Green+0.3*Blue)>220 )
33  * 			blackish
34  * 		else
35  * 			whitish
36  *
37  * 		We use the folowing formula to determine contrasting hues :
38  * 		ActiveText	  = Base  ( same as background )
39  * 		InactiveText1 = Inactive1 - 180
40  * 		InactiveText2 = Inactive2 - 180
41  *
42  *
43  * 		P.S. AS the matter of fact we only use 6 primary colors as ActiveText uses
44  * 		same hue as the background.
45  *
46  * 	Secondary colors :
47  *		Menu colors : HighInactive, HighActive
48  * 			These should have same hue as Inactive1 and Active, but brightness
49  *          at 10% higher.
50  *		Menu text colors should be the same as InactiveText1 and ActiveText
51  * 		Menu disabled item's text color: DisabledText
52  *			This one should have same hue as Inactive1, but saturation reduced
53  *          to 5% level.
54  *
55  * 	Derived gradient colors
56  * 		Colors Background, Inactive1, Inactive2, Active, HighInactive, HighActive
57  *      will have a 2 color gradient associated with them. To calculate these colors
58  *      we add 10% and substract 10% to/from brightness of the respectable color.
59  *  ____________________
60  *  10 colors total: 6 primary colors and 4 derived colors
61  */
62 
63 #define ASMC_Base 					0
64 #define ASMC_Inactive1 				1
65 #define ASMC_Inactive2 				2
66 #define ASMC_Active 				3
67 #define ASMC_InactiveText1 		    4
68 #define ASMC_InactiveText2 			5
69 
70 #define ASMC_ActiveText 			6
71 #define ASMC_HighInactive 			7
72 #define ASMC_HighActive 			8
73 #define ASMC_HighInactiveBack 		9
74 #define ASMC_HighActiveBack 	    10
75 #define ASMC_HighInactiveText 		11
76 #define ASMC_HighActiveText			12
77 #define ASMC_DisabledText			13
78 
79 #define ASMC_BaseDark				14
80 #define ASMC_BaseLight				15
81 #define ASMC_Inactive1Dark			16
82 #define ASMC_Inactive1Light			17
83 #define ASMC_Inactive2Dark			18
84 #define ASMC_Inactive2Light			19
85 #define ASMC_ActiveDark				20
86 #define ASMC_ActiveLight			21
87 #define ASMC_HighInactiveDark		22
88 #define ASMC_HighInactiveLight		23
89 #define ASMC_HighActiveDark			24
90 #define ASMC_HighActiveLight		25
91 #define ASMC_HighInactiveBackDark	26
92 #define ASMC_HighInactiveBackLight	27
93 #define ASMC_HighActiveBackDark		28
94 #define ASMC_HighActiveBackLight   	29
95 #define ASMC_Cursor				   	30
96 #define ASMC_MainColors			    31
97 
98 
99 extern char *ASMainColorNames[ASMC_MainColors];
100 
101 typedef struct ASColorScheme
102 {
103 	int angle ;
104 
105 	ASFlagType   set_main_colors ;             /* set bits represent colors
106 												* set manually, instead of
107 												* being computed from the
108 												* base color */
109 	int 		 main_saturations[ASMC_MainColors] ;
110 	int 		 main_values[ASMC_MainColors] ;
111 	int 		 main_hues[ASMC_MainColors] ;
112 	ARGB32       main_colors[ASMC_MainColors] ;
113 
114 }ASColorScheme;
115 
116 #define ASCS_MIN_ANGLE	5
117 #define ASCS_MAX_ANGLE	60
118 #define ASCS_DEFAULT_ANGLE	15
119 
120 #define ASCS_MAX_BRIGHTNESS 100
121 #define ASCS_MAX_SATURATION 100
122 #define ASCS_MAX_HUE 		360
123 #define ASCS_MAX_COLD_HUE	300
124 #define ASCS_MIN_COLD_HUE	120
125 
126 #define ASCS_COLD_SATURATION_OFFSET	 20
127 
128 #define ASCS_MAX_PRIMARY_BRIGHTNESS 70
129 #define ASCS_MIN_PRIMARY_BRIGHTNESS 30
130 #define ASCS_MIN_PRIMARY_SATURATION 10
131 
132 #define ASCS_WHITING_SATURATION_LEVEL	2
133 #define ASCS_WHITING_MIN_BRIGHTNESS_LEVEL	90
134 #define ASCS_WHITING_ACTV_MIN_BRIGHT_LEVEL	98
135 #define ASCS_BLACKING_BRIGHTNESS_LEVEL	10
136 
137 #define ASCS_BLACK_O_WHITE_CRITERIA16_VAL(r16,g16,b16)  (( ((CARD32)(r16)) *222+((CARD32)(g16))*707+((CARD32)(b16)) *71)/1000)
138 #define ASCS_BLACK_O_WHITE_CRITERIA16(r16,g16,b16)  (ASCS_BLACK_O_WHITE_CRITERIA16_VAL(r16,g16,b16)>0x09FFF)
139 
140 #define ASCS_NORMAL_BRIGHTNESS_OFFSET	 	10
141 #define ASCS_HIGH_BRIGHTNESS_OFFSET	 		20
142 #define ASCS_DISABLED_SATURATION_LEVEL		20
143 #define ASCS_GRADIENT_BRIGHTNESS_OFFSET 	20
144 #define ASCS_DISABLED_SATURATION_THRESHOLD  75
145 
146 #define ASCS_MONO_MIN_SHADE					10
147 #define ASCS_MONO_MAX_SHADE					90
148 #define ASCS_MONO_MIN_BASE_SHADE   			20
149 #define ASCS_MONO_MAX_BASE_SHADE   			80
150 #define ASCS_MONO_CONTRAST_OFFSET			45
151 #define ASCS_MONO_TEXT_CONTRAST				65
152 #define ASCS_MONO_SIMILAR_OFFSET			15
153 #define ASCS_MONO_GRADIENT_OFFSET			15
154 #define ASCS_MONO_HIGH_OFFSET			     5
155 
156 
157 
158 ARGB32 make_color_scheme_argb( ASColorScheme *cs, int id, CARD32 base_alpha16, CARD32 hue360, CARD32 sat100, CARD32 val100 );
159 void make_color_scheme_hsv( ARGB32 argb, int *phue, int *psat, int *pval );
160 
161 ASColorScheme *make_ascolor_scheme( ARGB32 base, int angle );
162 #define make_default_ascolor_scheme()  make_ascolor_scheme(DEFAULT_COLORSCHEME_BASE,ASCS_DEFAULT_ANGLE)
163 ASColorScheme *make_NeXTish_ascolor_scheme();
164 
165 
166 void populate_ascs_colors_rgb( ASColorScheme *cs );
167 void populate_ascs_colors_xml( ASColorScheme *cs );
168 
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 
175 
176 #endif
177 
178