]> git.vomp.tv Git - vompclient.git/blob - colour.h
Windows readme and makefile updated!
[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, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 */
20
21 #ifndef COLOUR_H
22 #define COLOUR_H
23
24 class Colour
25 {
26   public:
27     Colour()
28       { red = 0; green = 0; blue = 0; alpha = 255; }
29
30     Colour(int Tred, int Tgreen, int Tblue)
31       { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; }
32
33     Colour(int Tred, int Tgreen, int Tblue, int Talpha)
34       { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; }
35
36     Colour(unsigned int color)
37         {
38                 red = (color & 0x00ff0000)>>16;
39                 green = (color & 0x0000ff00)>>8;
40                 blue = (color & 0x000000ff);
41                 alpha = (color & 0xff000000)>>24;
42         }
43
44     void set(int Tred, int Tgreen, int Tblue)
45       { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; }
46
47     void set(int Tred, int Tgreen, int Tblue, int Talpha)
48       { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; }
49
50     inline unsigned long rgba() const
51     {
52       return (alpha << 24) | (red << 16) | (green << 8) | blue;
53     }
54
55     int red;
56     int green;
57     int blue;
58     int alpha;
59
60
61
62
63 };
64
65 // TODO move to seperate File
66 class DrawStyle: public Colour
67 {
68 public:
69         DrawStyle()
70     { red = 0; green = 0; blue = 0; alpha = 255; ft=Color;ct=Global; }
71
72         DrawStyle(int Tred, int Tgreen, int Tblue)
73     { red = Tred; green = Tgreen; blue = Tblue; alpha = 255 ;ft=Color;ct=Global;  }
74
75         DrawStyle(int Tred, int Tgreen, int Tblue, int Talpha)
76      { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; ft=Color;ct=Global;}
77         DrawStyle(unsigned int color)
78         {
79                 red = (color & 0x00ff0000)>>16;
80                 green = (color & 0x0000ff00)>>8;
81                 blue = (color & 0x000000ff);
82                 alpha = (color & 0xff000000)>>24;
83                 ft=Color;ct=Global;
84         }
85
86         DrawStyle(const Colour &c)
87         {
88                 red = c.red;
89                 green = c.green;
90                 blue = c.blue;
91                 alpha = c.alpha;
92                 ft=Color;ct=Global;
93         }
94
95         enum FillType {
96                         Color,
97                         GradientLinear,
98                         GradientRadial,
99         };
100         enum CoordType {
101                 Global,
102                 Local
103         };
104
105         enum FillType ft;
106         enum CoordType ct; //not implemented yet
107         float x1,y1,x2,y2,r; // Parameter for gradient either relative to object or to global coordinate system
108         int num_colors; //max is 4, min is 0
109         Colour grad_col[4];
110         float grad_pos[3]; //Last position is alway 1.0 and first 0.0
111
112     static DrawStyle BLACK;
113     static DrawStyle RED;
114     static DrawStyle GREEN;
115     static DrawStyle YELLOW;
116     static DrawStyle BLUE;
117     static DrawStyle GREY;
118     static DrawStyle DARKGREY;
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 };
207
208 #endif