]> git.vomp.tv Git - vompclient.git/blob - colour.h
DrawStyle: Add consts, add white and transparent statics
[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 #include "defines.h"
24
25 class Colour
26 {
27   public:
28     Colour()
29     { red = 0; green = 0; blue = 0; alpha = 255; }
30
31     Colour(int Tred, int Tgreen, int Tblue)
32     { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; }
33
34     Colour(int Tred, int Tgreen, int Tblue, int Talpha)
35     { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; }
36
37     Colour(unsigned int color)
38     {
39       red = (color & 0x00ff0000) >> 16;
40       green = (color & 0x0000ff00) >> 8;
41       blue = (color & 0x000000ff);
42       alpha = (color & 0xff000000) >> 24;
43     }
44
45     void set(int Tred, int Tgreen, int Tblue)
46     { red = Tred; green = Tgreen; blue = Tblue; alpha = 255; }
47
48     void set(int Tred, int Tgreen, int Tblue, int Talpha)
49     { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; }
50
51     inline unsigned long rgba() const
52     {
53       return (alpha << 24) | (red << 16) | (green << 8) | blue;
54     }
55
56     int red;
57     int green;
58     int blue;
59     int alpha;
60 };
61
62
63 // TODO move to seperate File
64 class DrawStyle: public Colour
65 {
66   public:
67     DrawStyle()
68     { red = 0; green = 0; blue = 0; alpha = 255; ft = Color; ct = Global; }
69
70     DrawStyle(int Tred, int Tgreen, int Tblue)
71     { red = Tred; green = Tgreen; blue = Tblue; alpha = 255 ; ft = Color; ct = Global;  }
72
73     DrawStyle(int Tred, int Tgreen, int Tblue, int Talpha)
74     { red = Tred; green = Tgreen; blue = Tblue; alpha = Talpha; ft = Color; ct = Global; }
75
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     {
96       Color,
97       GradientLinear,
98       GradientRadial,
99     };
100
101     enum CoordType
102     {
103       Global,
104       Local
105     };
106
107     enum FillType ft;
108     enum CoordType ct; //not implemented yet
109     float x1, y1, x2, y2, r; // Parameter for gradient either relative to object or to global coordinate system
110     int num_colors; //max is 4, min is 0
111     Colour grad_col[4];
112     float grad_pos[3]; //Last position is alway 1.0 and first 0.0
113
114     static DrawStyle TRANSPARENT;
115     static DrawStyle WHITE;
116     static DrawStyle BLACK;
117     static DrawStyle RED;
118     static DrawStyle GREEN;
119     static DrawStyle YELLOW;
120     static DrawStyle BLUE;
121     static DrawStyle GREY;
122     static DrawStyle DARKGREY;
123     static DrawStyle VIDEOBLUE;
124     static DrawStyle VIEWBACKGROUND;
125     static DrawStyle VIEWTRANSPARENTBACKGROUND;
126     static DrawStyle LIVETVSYMBOLS;
127     static DrawStyle PROGRESSBAR;
128     static DrawStyle OSDBACKGROUND;
129     static DrawStyle TABVIEWBACKGROUND;
130     static DrawStyle TITLEBARBACKGROUND;
131     static DrawStyle SELECTBACKGROUND;
132     static DrawStyle SELECTHIGHLIGHT;
133     static DrawStyle SELECTDARKHIGHLIGHT;
134     static DrawStyle LIGHTTEXT;
135     static DrawStyle DARKTEXT;
136     static DrawStyle DANGER;
137     static DrawStyle BUTTONBACKGROUND;
138     static DrawStyle PROGRAMMEA;
139     static DrawStyle PROGRAMMEB;
140     static DrawStyle NOPROGRAMME;
141     static DrawStyle WALLPAPER; // this one is special, if transparent it means picture
142 };
143
144 #define COMPARE_TEST(x) if (rhs.x != lhs.x) { return rhs.x < lhs.x; }
145
146 inline bool operator<(const DrawStyle& rhs, const DrawStyle& lhs)
147 {
148   COMPARE_TEST(rgba())
149   COMPARE_TEST(ft)
150
151   if (rhs.ft == DrawStyle::Color) return false;
152
153   COMPARE_TEST(num_colors)
154   COMPARE_TEST(x1)
155   COMPARE_TEST(x2)
156   COMPARE_TEST(y1)
157   COMPARE_TEST(y2)
158
159   if (rhs.ft == DrawStyle::GradientRadial) COMPARE_TEST(r)
160
161   for (int i = 0; i < lhs.num_colors; i++)
162   {
163     COMPARE_TEST(grad_col[i].rgba())
164
165     if (i > 0) COMPARE_TEST(grad_pos[i - 1])
166   }
167
168   COMPARE_TEST(ct)
169
170   return false;
171 }
172
173 #undef COMPARE_TEST
174
175
176 #define COMPARE_TEST(x) if (rhs.x!=lhs.x) return true;
177
178 inline bool operator!=(const DrawStyle& rhs, const DrawStyle& lhs)
179 {
180   COMPARE_TEST(rgba())
181   COMPARE_TEST(ft)
182
183   if (rhs.ft == DrawStyle::Color) return false;
184
185   COMPARE_TEST(num_colors)
186   COMPARE_TEST(x1)
187   COMPARE_TEST(x2)
188   COMPARE_TEST(y1)
189   COMPARE_TEST(y2)
190
191   if (rhs.ft == DrawStyle::GradientRadial) COMPARE_TEST(r)
192
193   for (int i = 0; i < lhs.num_colors; i++)
194   {
195     COMPARE_TEST(grad_col[i].rgba())
196
197     if (i > 0) COMPARE_TEST(grad_pos[i - 1])
198   }
199
200   COMPARE_TEST(ct)
201
202   return false;
203 }
204
205 #undef COMPARE_TEST
206
207
208 class SkinFactory
209 {
210   public:
211
212     enum SkinNames
213     {
214 #ifdef GRADIENT_DRAWING
215       NoopacityInspired,
216       ClassicEnhanced,
217 #endif
218       Classic,
219       MaxSkins
220     };
221
222     static int getNumberofSkins();
223     static const char ** getSkinNames();
224     static bool InitSkin(int n);
225
226   private:
227     static void InitDefaultSkin();
228     static void InitEnhancedSkin();
229     static void InitNoopacityInspiredSkin();
230 };
231
232 #endif