]> git.vomp.tv Git - vompclient.git/blob - colour.h
10 CWFs
[vompclient.git] / colour.h
1 /*
2     Copyright 2005 Chris Tallon
3
4     This file is part of VOMP.
5
6     VOMP is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     VOMP is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with VOMP.  If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifndef COLOUR_H
21 #define COLOUR_H
22
23 class Colour
24 {
25   public:
26     Colour()
27       { red = 0; green = 0; blue = 0; alpha = 255; }
28
29     Colour(int Tred, int Tgreen, int Tblue)
30       { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; }
31
32     Colour(int Tred, int Tgreen, int Tblue, int Talpha)
33       { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; }
34
35     Colour(unsigned int color)
36         {
37                 red = (color & 0x00ff0000)>>16;
38                 green = (color & 0x0000ff00)>>8;
39                 blue = (color & 0x000000ff);
40                 alpha = (color & 0xff000000)>>24;
41         }
42
43     void set(int Tred, int Tgreen, int Tblue)
44       { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; }
45
46     void set(int Tred, int Tgreen, int Tblue, int Talpha)
47       { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; }
48
49     inline unsigned long rgba() const
50     {
51       return (alpha << 24) | (red << 16) | (green << 8) | blue;
52     }
53
54     int red;
55     int green;
56     int blue;
57     int alpha;
58
59
60
61
62 };
63
64 // TODO move to seperate File
65 class DrawStyle: public Colour
66 {
67 public:
68         DrawStyle()
69     { red = 0; green = 0; blue = 0; alpha = 255; ft=Color;ct=Global; }
70
71         DrawStyle(int Tred, int Tgreen, int Tblue)
72     { red = Tred; green = Tgreen; blue = Tblue; alpha = 255 ;ft=Color;ct=Global;  }
73
74         DrawStyle(int Tred, int Tgreen, int Tblue, int Talpha)
75      { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; ft=Color;ct=Global;}
76         DrawStyle(unsigned int color)
77         {
78                 red = (color & 0x00ff0000)>>16;
79                 green = (color & 0x0000ff00)>>8;
80                 blue = (color & 0x000000ff);
81                 alpha = (color & 0xff000000)>>24;
82                 ft=Color;ct=Global;
83         }
84
85         DrawStyle(const Colour &c)
86         {
87                 red = c.red;
88                 green = c.green;
89                 blue = c.blue;
90                 alpha = c.alpha;
91                 ft=Color;ct=Global;
92         }
93
94         enum FillType {
95                         Color,
96                         GradientLinear,
97                         GradientRadial,
98         };
99         enum CoordType {
100                 Global,
101                 Local
102         };
103
104         enum FillType ft;
105         enum CoordType ct; //not implemented yet
106         float x1,y1,x2,y2,r; // Parameter for gradient either relative to object or to global coordinate system
107         int num_colors; //max is 4, min is 0
108         Colour grad_col[4];
109         float grad_pos[3]; //Last position is alway 1.0 and first 0.0
110
111     static DrawStyle BLACK;
112     static DrawStyle RED;
113     static DrawStyle GREEN;
114     static DrawStyle YELLOW;
115     static DrawStyle BLUE;
116     static DrawStyle GREY;
117     static DrawStyle DARKGREY;
118     static DrawStyle VIDEOBLUE;
119     static DrawStyle VIEWBACKGROUND;
120     static DrawStyle VIEWTRANSPARENTBACKGROUND;
121     static DrawStyle LIVETVSYMBOLS;
122     static DrawStyle PROGRESSBAR;
123     static DrawStyle OSDBACKGROUND;
124     static DrawStyle TABVIEWBACKGROUND;
125     static DrawStyle TITLEBARBACKGROUND;
126     static DrawStyle SELECTBACKGROUND;
127     static DrawStyle SELECTHIGHLIGHT;
128     static DrawStyle SELECTDARKHIGHLIGHT;
129     static DrawStyle LIGHTTEXT;
130     static DrawStyle DARKTEXT;
131     static DrawStyle DANGER;
132     static DrawStyle BUTTONBACKGROUND;
133     static DrawStyle PROGRAMMEA;
134     static DrawStyle PROGRAMMEB;
135     static DrawStyle NOPROGRAMME;
136     static DrawStyle WALLPAPER; // this one is special, if transparent it means picture
137
138 };
139
140 #define COMPARE_TEST(x) if (rhs.x!=lhs.x) { \
141                                                         return rhs.x < lhs.x; \
142                                                 }
143
144 inline bool operator<(const DrawStyle& rhs, const DrawStyle& lhs)
145 {
146         COMPARE_TEST(rgba())
147         COMPARE_TEST(ft)
148
149         if (rhs.ft==DrawStyle::Color) return false;
150
151         COMPARE_TEST(num_colors)
152         COMPARE_TEST(x1)
153         COMPARE_TEST(x2)
154         COMPARE_TEST(y1)
155         COMPARE_TEST(y2)
156         if (rhs.ft==DrawStyle::GradientRadial) COMPARE_TEST(r)
157
158
159         for (int i=0;i<lhs.num_colors; i++) {
160                 COMPARE_TEST(grad_col[i].rgba())
161                 if (i>0) COMPARE_TEST(grad_pos[i-1])
162         }
163         COMPARE_TEST(ct)
164
165         return false;
166 }
167
168
169 #undef COMPARE_TEST
170
171 #define COMPARE_TEST(x) if (rhs.x!=lhs.x) return true;
172
173
174 inline bool operator!=(const DrawStyle& rhs, const DrawStyle& lhs)
175 {
176         COMPARE_TEST(rgba())
177         COMPARE_TEST(ft)
178
179         if (rhs.ft==DrawStyle::Color) return false;
180
181         COMPARE_TEST(num_colors)
182         COMPARE_TEST(x1)
183         COMPARE_TEST(x2)
184         COMPARE_TEST(y1)
185         COMPARE_TEST(y2)
186         if (rhs.ft==DrawStyle::GradientRadial) COMPARE_TEST(r)
187
188
189         for (int i=0;i<lhs.num_colors; i++) {
190                 COMPARE_TEST(grad_col[i].rgba())
191                 if (i>0) COMPARE_TEST(grad_pos[i-1])
192         }
193         COMPARE_TEST(ct)
194
195         return false;
196 }
197
198 #undef COMPARE_TEST
199
200
201 class SkinFactory {
202 public:
203         static int getNumberofSkins();
204         static const char* *getSkinNames();
205         static bool InitSkin(int n);
206 private:
207     static void InitDefaultSkin();
208     static void InitEnhancedSkin();
209     static void InitNoopacityInspiredSkin();
210 };
211
212 #endif