~ubuntu-branches/ubuntu/oneiric/mythbuntu-artwork-usplash/oneiric

« back to all changes in this revision

Viewing changes to usplash-theme-mythbuntu.c

  • Committer: Bazaar Package Importer
  • Author(s): Mario Limonciello
  • Date: 2007-04-23 00:08:23 UTC
  • Revision ID: james.westby@ubuntu.com-20070423000823-wssjewguemb8z0i9
Tags: 0.1
Initial release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* usplash
 
2
 *
 
3
 * eft-theme.c - definition of eft theme
 
4
 *
 
5
 * Copyright © 2006 Dennis Kaarsemaker <dennis@kaarsemaker.net>
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License
 
18
 * along with this program; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
20
 */
 
21
 
 
22
#include <usplash-theme.h>
 
23
/* Needed for the custom drawing functions */
 
24
#include <usplash_backend.h>
 
25
extern struct usplash_pixmap pixmap_usplash_640_400;
 
26
extern struct usplash_pixmap pixmap_usplash_800_600, pixmap_usplash_1024_768, pixmap_usplash_1365_768_scaled;
 
27
extern struct usplash_pixmap pixmap_throbber_back;
 
28
extern struct usplash_pixmap pixmap_throbber_back_16;
 
29
extern struct usplash_pixmap pixmap_throbber_fore;
 
30
extern struct usplash_pixmap pixmap_throbber_fore_16;
 
31
 
 
32
void t_init(struct usplash_theme* theme);
 
33
void t_clear_progressbar(struct usplash_theme* theme);
 
34
void t_clear_progressbar_16(struct usplash_theme* theme);
 
35
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
 
36
void t_draw_progressbar_16(struct usplash_theme* theme, int percentage);
 
37
void t_animate_step(struct usplash_theme* theme, int pulsating);
 
38
void t_animate_step_16(struct usplash_theme* theme, int pulsating);
 
39
 
 
40
struct usplash_theme usplash_theme_800_600;
 
41
struct usplash_theme usplash_theme_1024_768;
 
42
struct usplash_theme usplash_theme_1365_768_scaled;
 
43
 
 
44
/* Theme definition */
 
45
/* Theme definition */
 
46
struct usplash_theme usplash_theme = {
 
47
        .version = THEME_VERSION, /* ALWAYS set this to THEME_VERSION, 
 
48
                                 it's a compatibility check */
 
49
    .next = &usplash_theme_800_600,
 
50
    .ratio = USPLASH_16_9,
 
51
 
 
52
        /* Background and font */
 
53
        .pixmap = &pixmap_usplash_640_400,
 
54
 
 
55
        /* Palette indexes */
 
56
        .background             = 0,
 
57
        .progressbar_background = 0,
 
58
        .progressbar_foreground = 15,
 
59
        .text_background        = 0,
 
60
        .text_foreground        = 11,
 
61
        .text_success           = 13,
 
62
        .text_failure           = 13,
 
63
 
 
64
        /* Progress bar position and size in pixels */
 
65
        .progressbar_x      = 160, /* 640/2-320/2 */
 
66
        .progressbar_y      = 196,
 
67
        .progressbar_width  = 320,
 
68
        .progressbar_height = 8,
 
69
 
 
70
        /* Text box position and size in pixels */
 
71
        .text_x      = 96,
 
72
        .text_y      = 246,
 
73
        .text_width  = 360,
 
74
        .text_height = 100,
 
75
 
 
76
        /* Text details */
 
77
        .line_height  = 15,
 
78
        .line_length  = 32,
 
79
        .status_width = 35,
 
80
 
 
81
    /* Functions */
 
82
    .init = t_init,
 
83
    .clear_progressbar = t_clear_progressbar_16,
 
84
    .draw_progressbar = t_draw_progressbar_16,
 
85
    .animate_step = t_animate_step_16,
 
86
};
 
87
 
 
88
struct usplash_theme usplash_theme_800_600 = {
 
89
        .version = THEME_VERSION, /* ALWAYS set this to THEME_VERSION, 
 
90
                                 it's a compatibility check */
 
91
    .next = &usplash_theme_1024_768,
 
92
    .ratio = USPLASH_4_3,
 
93
 
 
94
        /* Background and font */
 
95
        .pixmap = &pixmap_usplash_800_600,
 
96
 
 
97
        /* Palette indexes */
 
98
        .background             = 0,
 
99
        .progressbar_background = 0,
 
100
        .progressbar_foreground = 97,
 
101
        .text_background        = 0,
 
102
        .text_foreground        = 126,
 
103
        .text_success           = 126,
 
104
        .text_failure           = 223,
 
105
 
 
106
        /* Progress bar position and size in pixels */
 
107
        .progressbar_x      = 240, /* 800/2-320/2 */
 
108
        .progressbar_y      = 371,
 
109
        .progressbar_width  = 320,
 
110
        .progressbar_height = 8,
 
111
 
 
112
        /* Text box position and size in pixels */
 
113
        .text_x      = 120,
 
114
        .text_y      = 407,
 
115
        .text_width  = 360,
 
116
        .text_height = 150,
 
117
 
 
118
        /* Text details */
 
119
        .line_height  = 15,
 
120
        .line_length  = 32,
 
121
        .status_width = 35,
 
122
 
 
123
    /* Functions */
 
124
    .init = t_init,
 
125
    .clear_progressbar = t_clear_progressbar,
 
126
    .draw_progressbar = t_draw_progressbar,
 
127
    .animate_step = t_animate_step,
 
128
};
 
129
 
 
130
struct usplash_theme usplash_theme_1024_768 = {
 
131
        .version = THEME_VERSION,
 
132
    .next = &usplash_theme_1365_768_scaled,
 
133
    .ratio = USPLASH_4_3,
 
134
 
 
135
        /* Background and font */
 
136
        .pixmap = &pixmap_usplash_1024_768,
 
137
 
 
138
        /* Palette indexes */
 
139
        .background             = 0,
 
140
        .progressbar_background = 0,
 
141
        .progressbar_foreground = 97,
 
142
        .text_background        = 0,
 
143
        .text_foreground        = 126,
 
144
        .text_success           = 126,
 
145
        .text_failure           = 223,
 
146
 
 
147
        /* Progress bar position and size in pixels */
 
148
        .progressbar_x      = 352, /* 1024/2 - 320/2 */
 
149
        .progressbar_y      = 400,
 
150
        .progressbar_width  = 320,
 
151
        .progressbar_height = 8,
 
152
 
 
153
        /* Text box position and size in pixels */
 
154
        .text_x      = 322,
 
155
        .text_y      = 475,
 
156
        .text_width  = 380,
 
157
        .text_height = 200,
 
158
 
 
159
        /* Text details */
 
160
        .line_height  = 15,
 
161
        .line_length  = 32,
 
162
        .status_width = 35,
 
163
 
 
164
    /* Functions */
 
165
    .init = t_init,
 
166
    .clear_progressbar = t_clear_progressbar,
 
167
    .draw_progressbar = t_draw_progressbar,
 
168
    .animate_step = t_animate_step,
 
169
};
 
170
 
 
171
struct usplash_theme usplash_theme_1365_768_scaled = {
 
172
        .version = THEME_VERSION,
 
173
    .next = NULL,
 
174
    .ratio = USPLASH_16_9,
 
175
 
 
176
        /* Background and font */
 
177
        .pixmap = &pixmap_usplash_1365_768_scaled,
 
178
 
 
179
        /* Palette indexes */
 
180
        .background             = 0,
 
181
        .progressbar_background = 0,
 
182
        .progressbar_foreground = 97,
 
183
        .text_background        = 0,
 
184
        .text_foreground        = 126,
 
185
        .text_success           = 126,
 
186
        .text_failure           = 223,
 
187
 
 
188
        /* Progress bar position and size in pixels */
 
189
        .progressbar_x      = 352, /* 1024/2 - 320/2 */
 
190
        .progressbar_y      = 475,
 
191
        .progressbar_width  = 320,
 
192
        .progressbar_height = 8,
 
193
 
 
194
        /* Text box position and size in pixels */
 
195
        .text_x      = 322,
 
196
        .text_y      = 475,
 
197
        .text_width  = 380,
 
198
        .text_height = 200,
 
199
 
 
200
        /* Text details */
 
201
        .line_height  = 15,
 
202
        .line_length  = 32,
 
203
        .status_width = 35,
 
204
 
 
205
    /* Functions */
 
206
    .init = t_init,
 
207
    .clear_progressbar = t_clear_progressbar,
 
208
    .draw_progressbar = t_draw_progressbar,
 
209
    .animate_step = t_animate_step,
 
210
};
 
211
 
 
212
void t_init(struct usplash_theme *theme) {
 
213
    int x, y;
 
214
    usplash_getdimensions(&x, &y);
 
215
    theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
 
216
    theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
 
217
}
 
218
 
 
219
void t_clear_progressbar(struct usplash_theme *theme) {
 
220
    t_draw_progressbar(theme, 0);
 
221
}
 
222
 
 
223
void t_clear_progressbar_16(struct usplash_theme *theme) {
 
224
    t_draw_progressbar_16(theme, 0);
 
225
}
 
226
 
 
227
void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
 
228
    int w = (pixmap_throbber_back.width * percentage / 100);
 
229
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);
 
230
    if(percentage == 0)
 
231
        return;
 
232
    if(percentage < 0)
 
233
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
 
234
                         pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
 
235
    else
 
236
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height, 
 
237
                         &pixmap_throbber_fore, 0, 0);
 
238
}
 
239
 
 
240
void t_draw_progressbar_16(struct usplash_theme *theme, int percentage) {
 
241
    int w = (pixmap_throbber_back_16.width * percentage / 100);
 
242
    usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back_16);
 
243
    if (percentage == 0)
 
244
        return;
 
245
    if (percentage < 0)
 
246
        usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back_16.width + w,
 
247
                         pixmap_throbber_back_16.height, &pixmap_throbber_fore_16, -w, 0);
 
248
    else
 
249
        usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back_16.height, 
 
250
                         &pixmap_throbber_fore_16, 0, 0);
 
251
}
 
252
 
 
253
void t_animate_step(struct usplash_theme* theme, int pulsating) {
 
254
 
 
255
    static int pulsate_step = 0;
 
256
    static int pulse_width = 28;
 
257
    static int step_width = 2;
 
258
    static int num_steps = (320 - 28)/2;
 
259
    int x1;
 
260
 
 
261
    if (pulsating) {
 
262
        t_draw_progressbar(theme, 0);
 
263
    
 
264
        if(pulsate_step < num_steps/2+1)
 
265
                x1 = 2 * step_width * pulsate_step;
 
266
        else
 
267
                x1 = 320 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);
 
268
 
 
269
        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
 
270
                         pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);
 
271
 
 
272
        pulsate_step = (pulsate_step + 1) % num_steps;
 
273
    }
 
274
}
 
275
 
 
276
void t_animate_step_16(struct usplash_theme* theme, int pulsating) {
 
277
 
 
278
    static int pulsate_step = 0;
 
279
    static int pulse_width = 28;
 
280
    static int step_width = 2;
 
281
    static int num_steps = (216 - 28)/2;
 
282
    int x1;
 
283
 
 
284
    if (pulsating) {
 
285
        t_draw_progressbar_16(theme, 0);
 
286
    
 
287
        if(pulsate_step < num_steps/2+1)
 
288
                x1 = 2 * step_width * pulsate_step;
 
289
        else
 
290
                x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);
 
291
 
 
292
        usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
 
293
                         pixmap_throbber_fore_16.height, &pixmap_throbber_fore_16, x1, 0);
 
294
 
 
295
        pulsate_step = (pulsate_step + 1) % num_steps;
 
296
    }
 
297
}