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>
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_fore;
30
void t_init(struct usplash_theme* theme);
31
void t_clear_progressbar(struct usplash_theme* theme);
32
void t_draw_progressbar(struct usplash_theme* theme, int percentage);
33
void t_animate_step(struct usplash_theme* theme, int pulsating);
35
struct usplash_theme usplash_theme_1024_768;
36
struct usplash_theme usplash_theme_1365_768_scaled;
38
/* Theme definition */
39
struct usplash_theme usplash_theme = {
40
.version = THEME_VERSION, /* ALWAYS set this to THEME_VERSION,
41
it's a compatibility check */
42
.next = &usplash_theme_1024_768,
45
/* Background and font */
46
.pixmap = &pixmap_usplash_800_600,
50
.progressbar_background = 0x7,
51
.progressbar_foreground = 0x156,
52
.text_background = 0x0,
53
.text_foreground = 0x15,
55
.text_failure = 0x144,
57
/* Progress bar position and size in pixels */
58
.progressbar_x = 292, /* 800/2-216/2 */
60
.progressbar_width = 216,
61
.progressbar_height = 8,
63
/* Text box position and size in pixels */
76
.clear_progressbar = t_clear_progressbar,
77
.draw_progressbar = t_draw_progressbar,
78
.animate_step = t_animate_step,
81
struct usplash_theme usplash_theme_1024_768 = {
82
.version = THEME_VERSION,
83
.next = &usplash_theme_1365_768_scaled,
86
/* Background and font */
87
.pixmap = &pixmap_usplash_1024_768,
91
.progressbar_background = 0x7,
92
.progressbar_foreground = 0x156,
93
.text_background = 0x0,
94
.text_foreground = 0x15,
96
.text_failure = 0x144,
98
/* Progress bar position and size in pixels */
99
.progressbar_x = 404, /* 1024/2 - 216/2 */
100
.progressbar_y = 475,
101
.progressbar_width = 216,
102
.progressbar_height = 8,
104
/* Text box position and size in pixels */
117
.clear_progressbar = t_clear_progressbar,
118
.draw_progressbar = t_draw_progressbar,
119
.animate_step = t_animate_step,
122
struct usplash_theme usplash_theme_1365_768_scaled = {
123
.version = THEME_VERSION,
125
.ratio = USPLASH_16_9,
127
/* Background and font */
128
.pixmap = &pixmap_usplash_1365_768_scaled,
130
/* Palette indexes */
132
.progressbar_background = 0x7,
133
.progressbar_foreground = 0x156,
134
.text_background = 0x0,
135
.text_foreground = 0x15,
136
.text_success = 0x33,
137
.text_failure = 0x144,
139
/* Progress bar position and size in pixels */
140
.progressbar_x = 404, /* 1024/2 - 216/2 */
141
.progressbar_y = 475,
142
.progressbar_width = 216,
143
.progressbar_height = 8,
145
/* Text box position and size in pixels */
158
.clear_progressbar = t_clear_progressbar,
159
.draw_progressbar = t_draw_progressbar,
160
.animate_step = t_animate_step,
163
void t_init(struct usplash_theme *theme) {
165
usplash_getdimensions(&x, &y);
166
theme->progressbar_x = (x - theme->pixmap->width)/2 + theme->progressbar_x;
167
theme->progressbar_y = (y - theme->pixmap->height)/2 + theme->progressbar_y;
170
void t_clear_progressbar(struct usplash_theme *theme) {
171
t_draw_progressbar(theme, 0);
174
void t_draw_progressbar(struct usplash_theme *theme, int percentage) {
175
int w = (pixmap_throbber_back.width * percentage / 100);
176
usplash_put(theme->progressbar_x, theme->progressbar_y, &pixmap_throbber_back);
180
usplash_put_part(theme->progressbar_x - w, theme->progressbar_y, pixmap_throbber_back.width + w,
181
pixmap_throbber_back.height, &pixmap_throbber_fore, -w, 0);
183
usplash_put_part(theme->progressbar_x, theme->progressbar_y, w, pixmap_throbber_back.height,
184
&pixmap_throbber_fore, 0, 0);
187
void t_animate_step(struct usplash_theme* theme, int pulsating) {
189
static int pulsate_step = 0;
190
static int pulse_width = 28;
191
static int step_width = 2;
192
static int num_steps = (216 - 28)/2;
196
t_draw_progressbar(theme, 0);
198
if(pulsate_step < num_steps/2+1)
199
x1 = 2 * step_width * pulsate_step;
201
x1 = 216 - pulse_width - 2 * step_width * (pulsate_step - num_steps/2+1);
203
usplash_put_part(theme->progressbar_x + x1, theme->progressbar_y, pulse_width,
204
pixmap_throbber_fore.height, &pixmap_throbber_fore, x1, 0);
206
pulsate_step = (pulsate_step + 1) % num_steps;