3
* eft-theme.c - definition of eft theme
5
* Copyright © 2006 Dennis Kaarsemaker <dennis@kaarsemaker.net>
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.
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.
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
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;
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);
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;
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,
52
/* Background and font */
53
.pixmap = &pixmap_usplash_640_400,
57
.progressbar_background = 0,
58
.progressbar_foreground = 15,
60
.text_foreground = 11,
64
/* Progress bar position and size in pixels */
65
.progressbar_x = 160, /* 640/2-320/2 */
67
.progressbar_width = 320,
68
.progressbar_height = 8,
70
/* Text box position and size in pixels */
83
.clear_progressbar = t_clear_progressbar_16,
84
.draw_progressbar = t_draw_progressbar_16,
85
.animate_step = t_animate_step_16,
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,
94
/* Background and font */
95
.pixmap = &pixmap_usplash_800_600,
99
.progressbar_background = 0,
100
.progressbar_foreground = 97,
101
.text_background = 0,
102
.text_foreground = 126,
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,
112
/* Text box position and size in pixels */
125
.clear_progressbar = t_clear_progressbar,
126
.draw_progressbar = t_draw_progressbar,
127
.animate_step = t_animate_step,
130
struct usplash_theme usplash_theme_1024_768 = {
131
.version = THEME_VERSION,
132
.next = &usplash_theme_1365_768_scaled,
133
.ratio = USPLASH_4_3,
135
/* Background and font */
136
.pixmap = &pixmap_usplash_1024_768,
138
/* Palette indexes */
140
.progressbar_background = 0,
141
.progressbar_foreground = 97,
142
.text_background = 0,
143
.text_foreground = 126,
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,
153
/* Text box position and size in pixels */
166
.clear_progressbar = t_clear_progressbar,
167
.draw_progressbar = t_draw_progressbar,
168
.animate_step = t_animate_step,
171
struct usplash_theme usplash_theme_1365_768_scaled = {
172
.version = THEME_VERSION,
174
.ratio = USPLASH_16_9,
176
/* Background and font */
177
.pixmap = &pixmap_usplash_1365_768_scaled,
179
/* Palette indexes */
181
.progressbar_background = 0,
182
.progressbar_foreground = 97,
183
.text_background = 0,
184
.text_foreground = 126,
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,
194
/* Text box position and size in pixels */
207
.clear_progressbar = t_clear_progressbar,
208
.draw_progressbar = t_draw_progressbar,
209
.animate_step = t_animate_step,
212
void t_init(struct usplash_theme *theme) {
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;
219
void t_clear_progressbar(struct usplash_theme *theme) {
220
t_draw_progressbar(theme, 0);
223
void t_clear_progressbar_16(struct usplash_theme *theme) {
224
t_draw_progressbar_16(theme, 0);
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);
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);
236
usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height,
237
&pixmap_throbber_fore, 0, 0);
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);
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);
249
usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back_16.height,
250
&pixmap_throbber_fore_16, 0, 0);
253
void t_animate_step(struct usplash_theme* theme, int pulsating) {
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;
262
t_draw_progressbar(theme, 0);
264
if(pulsate_step < num_steps/2+1)
265
x1 = 2 * step_width * pulsate_step;
267
x1 = 320 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);
269
usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
270
pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);
272
pulsate_step = (pulsate_step + 1) % num_steps;
276
void t_animate_step_16(struct usplash_theme* theme, int pulsating) {
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;
285
t_draw_progressbar_16(theme, 0);
287
if(pulsate_step < num_steps/2+1)
288
x1 = 2 * step_width * pulsate_step;
290
x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);
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);
295
pulsate_step = (pulsate_step + 1) % num_steps;